From 95e1db3186fc411270d3290a30283eca1ea9c11a Mon Sep 17 00:00:00 2001 From: Julian Auriac Date: Tue, 30 Sep 2025 15:48:22 +0200 Subject: [PATCH 1/5] Add a script to run the CI locally --- bin/build_and_run_all_tests | 13 ++++--- run-ci-local.sh | 70 +++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 4 deletions(-) create mode 100755 run-ci-local.sh diff --git a/bin/build_and_run_all_tests b/bin/build_and_run_all_tests index 2393a46ac..90e0945cd 100755 --- a/bin/build_and_run_all_tests +++ b/bin/build_and_run_all_tests @@ -35,16 +35,21 @@ set -xe # Make our work dirs -SRCDIR="${PWD}" +# # SRCDIR="${PWD}" +# Set SRCDIR only if not provided +if [[ -z "${SRCDIR:-}" ]]; then + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + SRCDIR="$(cd "$SCRIPT_DIR/.." && pwd)" +fi TEST_DIR="${TEST_DIR:-${PWD}}" cd "${TEST_DIR}" cd "$(mktemp -d pdibuild.XXXXX)" TEST_DIR="${PWD}" -cd "${SRCDIR}" -cd "$(dirname "$0")/.." -SRCDIR="${PWD}" +# # cd "${SRCDIR}" +# # cd "$(dirname "$0")/.." +# # SRCDIR="${PWD}" cd "${TEST_DIR}" diff --git a/run-ci-local.sh b/run-ci-local.sh new file mode 100755 index 000000000..e71191c78 --- /dev/null +++ b/run-ci-local.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# ----------- Config ------------------ +IMAGE="ghcr.io/pdidev/ubuntu/rolling/openmpi/all:v3" +SCRIPT_NAME="run.sh" +SCRIPT_DIR="./.ci_tmp" +REPORT_FILE="tests.xml" +TMP_DIR="/tmp_dir_test" +BINARY_PATH="./bin/build_and_run_all_tests" +# ------------------------------------ + +mkdir -p "$SCRIPT_DIR" +rm -f "$SCRIPT_DIR/$SCRIPT_NAME" "$REPORT_FILE" + +# Make sure the binary exists and is executable +if [[ ! -f "$BINARY_PATH" ]]; then + echo "โš ๏ธ Binary not found at $BINARY_PATH" + exit 1 +fi + +echo "๐Ÿ“ Generating $SCRIPT_NAME in $SCRIPT_DIR..." +cat < "$SCRIPT_DIR/$SCRIPT_NAME" +#!/bin/bash +set -xe + +JOBID="\$(echo "manual-run" | md5sum | cut -b 1)" +if [[ "01234567" == *"\${JOBID}"* ]]; then + export PDI_PLUGIN_PATH=/tmp/pdi_plugins +fi + +export MAKEFLAGS='-j 4' +export CTEST_FLAGS="--output-junit /tmp/tests.xml" +export TEST_DIR="/tmp_dir_test" +export SRCDIR="/src" + +chmod +x /tmp/build_and_run_all_tests +/tmp/build_and_run_all_tests +EOF + +chmod +x "$SCRIPT_DIR/$SCRIPT_NAME" + +# Step 1: Create a container and inject the script +echo "๐Ÿณ Creating and preparing container..." +CONTAINER_ID=$(podman create \ + --userns=keep-id \ + -v "$PWD":/src \ + --tmpfs "$TMP_DIR:exec" \ + "$IMAGE" \ + bash /tmp/run.sh) + +echo "๐Ÿ“ฆ Copying script and binary into container..." +podman cp "$SCRIPT_DIR/$SCRIPT_NAME" "$CONTAINER_ID:/tmp/run.sh" +podman cp "$BINARY_PATH" "$CONTAINER_ID:/tmp/build_and_run_all_tests" + +# DO NOT run podman exec here โ€” container isn't running yet + +echo "๐Ÿš€ Starting container and running script..." +podman start --attach "$CONTAINER_ID" + +echo "๐Ÿ“„ Attempting to extract test report from container..." +if podman cp "$CONTAINER_ID":/tmp/tests.xml "$REPORT_FILE"; then + echo "โœ… Test report saved as $REPORT_FILE" +else + echo "โš ๏ธ Test report not found in container." +fi + +echo "๐Ÿงน Cleaning up container..." +podman rm "$CONTAINER_ID" >/dev/null 2>&1 || true From d15a5edb3fc481d677f43f71e3038ac1743831fa Mon Sep 17 00:00:00 2001 From: Julian Auriac Date: Tue, 30 Sep 2025 16:04:18 +0200 Subject: [PATCH 2/5] Fix #596, clean for PR --- AUTHORS | 3 ++- bin/build_and_run_all_tests | 5 ---- run-ci-local.sh | 46 +++++++++++++++++++++++++++++-------- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/AUTHORS b/AUTHORS index adbd8c042..12fd23429 100644 --- a/AUTHORS +++ b/AUTHORS @@ -7,7 +7,8 @@ each sub-project (including PDI itself) is located in the dedicated sub-project AUTHORS file. Julian Auriac - CEA (julian.auriac@cea.fr) -* fix CI bug where tests.xml file could not be written +* Fix CI bug where tests.xml file could not be written +* Added local CI Julien Bigot - CEA (julien.bigot@cea.fr) * Maintainer (Dec. 2014 - ...) diff --git a/bin/build_and_run_all_tests b/bin/build_and_run_all_tests index 90e0945cd..cb5482220 100755 --- a/bin/build_and_run_all_tests +++ b/bin/build_and_run_all_tests @@ -35,7 +35,6 @@ set -xe # Make our work dirs -# # SRCDIR="${PWD}" # Set SRCDIR only if not provided if [[ -z "${SRCDIR:-}" ]]; then SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" @@ -47,10 +46,6 @@ cd "${TEST_DIR}" cd "$(mktemp -d pdibuild.XXXXX)" TEST_DIR="${PWD}" -# # cd "${SRCDIR}" -# # cd "$(dirname "$0")/.." -# # SRCDIR="${PWD}" - cd "${TEST_DIR}" diff --git a/run-ci-local.sh b/run-ci-local.sh index e71191c78..f917551b2 100755 --- a/run-ci-local.sh +++ b/run-ci-local.sh @@ -1,4 +1,32 @@ #!/usr/bin/env bash +#============================================================================= +# Copyright (C) 2025 Commissariat a l'energie atomique et aux energies alternatives (CEA) +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the names of CEA, nor the names of the contributors may be used to +# endorse or promote products derived from this software without specific +# prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +#============================================================================= set -euo pipefail @@ -16,11 +44,11 @@ rm -f "$SCRIPT_DIR/$SCRIPT_NAME" "$REPORT_FILE" # Make sure the binary exists and is executable if [[ ! -f "$BINARY_PATH" ]]; then - echo "โš ๏ธ Binary not found at $BINARY_PATH" + echo "Binary not found at $BINARY_PATH" exit 1 fi -echo "๐Ÿ“ Generating $SCRIPT_NAME in $SCRIPT_DIR..." +echo "Generating $SCRIPT_NAME in $SCRIPT_DIR..." cat < "$SCRIPT_DIR/$SCRIPT_NAME" #!/bin/bash set -xe @@ -42,7 +70,7 @@ EOF chmod +x "$SCRIPT_DIR/$SCRIPT_NAME" # Step 1: Create a container and inject the script -echo "๐Ÿณ Creating and preparing container..." +echo "Creating and preparing container..." CONTAINER_ID=$(podman create \ --userns=keep-id \ -v "$PWD":/src \ @@ -50,21 +78,21 @@ CONTAINER_ID=$(podman create \ "$IMAGE" \ bash /tmp/run.sh) -echo "๐Ÿ“ฆ Copying script and binary into container..." +echo "Copying script and binary into container..." podman cp "$SCRIPT_DIR/$SCRIPT_NAME" "$CONTAINER_ID:/tmp/run.sh" podman cp "$BINARY_PATH" "$CONTAINER_ID:/tmp/build_and_run_all_tests" # DO NOT run podman exec here โ€” container isn't running yet -echo "๐Ÿš€ Starting container and running script..." +echo "Starting container and running script..." podman start --attach "$CONTAINER_ID" -echo "๐Ÿ“„ Attempting to extract test report from container..." +echo "Attempting to extract test report from container..." if podman cp "$CONTAINER_ID":/tmp/tests.xml "$REPORT_FILE"; then - echo "โœ… Test report saved as $REPORT_FILE" + echo "Test report saved as $REPORT_FILE" else - echo "โš ๏ธ Test report not found in container." + echo "Test report not found in container." fi -echo "๐Ÿงน Cleaning up container..." +echo "Cleaning up container..." podman rm "$CONTAINER_ID" >/dev/null 2>&1 || true From c387276084df35c34cc02f6ef647a35b51071298 Mon Sep 17 00:00:00 2001 From: Julian Auriac Date: Mon, 27 Apr 2026 09:59:16 +0200 Subject: [PATCH 3/5] Update to disable building documentation --- run-ci-local.sh => run-local-CI.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) rename run-ci-local.sh => run-local-CI.sh (94%) diff --git a/run-ci-local.sh b/run-local-CI.sh similarity index 94% rename from run-ci-local.sh rename to run-local-CI.sh index f917551b2..7e8b0424b 100755 --- a/run-ci-local.sh +++ b/run-local-CI.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash #============================================================================= -# Copyright (C) 2025 Commissariat a l'energie atomique et aux energies alternatives (CEA) +# Copyright (C) 2025-2026 Commissariat a l'energie atomique et aux energies alternatives (CEA) # # All rights reserved. # @@ -62,6 +62,7 @@ export MAKEFLAGS='-j 4' export CTEST_FLAGS="--output-junit /tmp/tests.xml" export TEST_DIR="/tmp_dir_test" export SRCDIR="/src" +export CMAKE_FLAGS="-DBUILD_DOCUMENTATION=OFF" chmod +x /tmp/build_and_run_all_tests /tmp/build_and_run_all_tests @@ -69,7 +70,6 @@ EOF chmod +x "$SCRIPT_DIR/$SCRIPT_NAME" -# Step 1: Create a container and inject the script echo "Creating and preparing container..." CONTAINER_ID=$(podman create \ --userns=keep-id \ @@ -82,8 +82,6 @@ echo "Copying script and binary into container..." podman cp "$SCRIPT_DIR/$SCRIPT_NAME" "$CONTAINER_ID:/tmp/run.sh" podman cp "$BINARY_PATH" "$CONTAINER_ID:/tmp/build_and_run_all_tests" -# DO NOT run podman exec here โ€” container isn't running yet - echo "Starting container and running script..." podman start --attach "$CONTAINER_ID" From daf266115f54c1c58ea0dc4d066381bc22ca7f7d Mon Sep 17 00:00:00 2001 From: Julian Auriac Date: Mon, 27 Apr 2026 10:30:51 +0200 Subject: [PATCH 4/5] Add another script to run the indent checker locally, and update target image to v4 --- run-local-CI-indent.sh | 23 +++++++++++++++++++++++ run-local-CI.sh | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 run-local-CI-indent.sh diff --git a/run-local-CI-indent.sh b/run-local-CI-indent.sh new file mode 100755 index 000000000..bfb0065d5 --- /dev/null +++ b/run-local-CI-indent.sh @@ -0,0 +1,23 @@ +set -euo pipefail + +IMAGE="ghcr.io/pdidev/run_clang_format:v4" + +echo "Collecting files from git..." + +FILES=$(git ls-files \ + | grep -v '^vendor/' \ + | grep -E '\.(c|h|cc|hh|cpp|hpp|cxx|hxx)$') + +if [ -z "$FILES" ]; then + echo "No files to check." + exit 0 +fi + +echo "Running clang-format container..." + +podman run --rm \ + --userns=keep-id \ + -v "$PWD":/src \ + -w /src \ + "$IMAGE" \ + $FILES diff --git a/run-local-CI.sh b/run-local-CI.sh index 7e8b0424b..cb739ef9d 100755 --- a/run-local-CI.sh +++ b/run-local-CI.sh @@ -31,7 +31,7 @@ set -euo pipefail # ----------- Config ------------------ -IMAGE="ghcr.io/pdidev/ubuntu/rolling/openmpi/all:v3" +IMAGE="ghcr.io/pdidev/ubuntu/rolling/openmpi/all:v4" SCRIPT_NAME="run.sh" SCRIPT_DIR="./.ci_tmp" REPORT_FILE="tests.xml" From b2fe0f15eb7a32f4cc4120e4c976fc702b70e109 Mon Sep 17 00:00:00 2001 From: Julian Auriac Date: Thu, 30 Apr 2026 16:09:18 +0200 Subject: [PATCH 5/5] Modify run-local-CI-indent.sh to enable automatic indent through '-i' option --- run-local-CI-indent.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/run-local-CI-indent.sh b/run-local-CI-indent.sh index bfb0065d5..105076e06 100755 --- a/run-local-CI-indent.sh +++ b/run-local-CI-indent.sh @@ -20,4 +20,5 @@ podman run --rm \ -v "$PWD":/src \ -w /src \ "$IMAGE" \ + "$@" \ $FILES