Skip to content

Commit b4e9df6

Browse files
jbigotJAuriac
andcommitted
Add a script to run the CI locally
Co-authored-by: Julian Auriac <julian.auriac@cea.fr>
1 parent e0ab74f commit b4e9df6

3 files changed

Lines changed: 147 additions & 2 deletions

File tree

AUTHORS

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ spirit, we list here in alphabetical order a condensed list of their contributio
44
Julian Auriac - CEA (julian.auriac@cea.fr)
55
* Add mock PDI
66
* Fix CI bug where tests.xml file could not be written
7-
* Improvement of a Decl'HDF5 test to work on OSX
8-
* Addition of API tests
7+
* Add local CI
8+
* Improve a Decl'HDF5 test to work on OSX
9+
* Add API tests
910

1011
Julien Bigot - CEA (julien.bigot@cea.fr)
1112
* Initial design and implementation

bin/run-local-CI-indent.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env bash
2+
#=============================================================================
3+
# Copyright (C) 2025-2026 Commissariat a l'energie atomique et aux energies alternatives (CEA)
4+
#
5+
# All rights reserved.
6+
#
7+
# Redistribution and use in source and binary forms, with or without
8+
# modification, are permitted provided that the following conditions are met:
9+
# * Redistributions of source code must retain the above copyright notice,
10+
# this list of conditions and the following disclaimer.
11+
# * Redistributions in binary form must reproduce the above copyright notice,
12+
# this list of conditions and the following disclaimer in the documentation
13+
# and/or other materials provided with the distribution.
14+
# * Neither the names of CEA, nor the names of the contributors may be used to
15+
# endorse or promote products derived from this software without specific
16+
# prior written permission.
17+
#
18+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
# POSSIBILITY OF SUCH DAMAGE.
29+
#=============================================================================
30+
31+
# Use "./run-local-CI-indent.sh" to run check
32+
# Use "./run-local-CI-indent.sh -i" to apply fix
33+
34+
set -euo pipefail
35+
36+
IMAGE="ghcr.io/pdidev/run_clang_format:v4"
37+
38+
# Use podman if available, else fall back to docker
39+
if command -v podman &>/dev/null; then
40+
CONTAINER_CMD="podman"
41+
USERNS_ARGS="--userns=keep-id"
42+
elif command -v docker &>/dev/null; then
43+
CONTAINER_CMD="docker"
44+
USERNS_ARGS="--user $(id -u):$(id -g)"
45+
else
46+
echo "Error: neither podman nor docker found in PATH." >&2
47+
exit 1
48+
fi
49+
50+
REPO_ROOT=$(git rev-parse --show-toplevel)
51+
52+
echo -e "Collecting files from repository\n"
53+
54+
FILES=$(git -C "$REPO_ROOT" ls-files \
55+
| grep -v '^vendor/' \
56+
| grep -E '\.(c|h|cc|hh|cpp|hpp|cxx|hxx)$')
57+
58+
if [ -z "$FILES" ]; then
59+
echo "No files to check."
60+
exit 0
61+
fi
62+
63+
echo -e "Running clang-format container (using $CONTAINER_CMD)\n"
64+
65+
$CONTAINER_CMD run --rm \
66+
$USERNS_ARGS \
67+
-v "$REPO_ROOT":/src \
68+
-w /src \
69+
"$IMAGE" \
70+
"$@" \
71+
$FILES
72+
73+
echo "Done"

bin/run-local-CI.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env bash
2+
#=============================================================================
3+
# Copyright (C) 2025-2026 Commissariat a l'energie atomique et aux energies alternatives (CEA)
4+
#
5+
# All rights reserved.
6+
#
7+
# Redistribution and use in source and binary forms, with or without
8+
# modification, are permitted provided that the following conditions are met:
9+
# * Redistributions of source code must retain the above copyright notice,
10+
# this list of conditions and the following disclaimer.
11+
# * Redistributions in binary form must reproduce the above copyright notice,
12+
# this list of conditions and the following disclaimer in the documentation
13+
# and/or other materials provided with the distribution.
14+
# * Neither the names of CEA, nor the names of the contributors may be used to
15+
# endorse or promote products derived from this software without specific
16+
# prior written permission.
17+
#
18+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
# POSSIBILITY OF SUCH DAMAGE.
29+
#=============================================================================
30+
31+
# Use "./run-local-CI.sh" to run CI locally from a container
32+
33+
set -euo pipefail
34+
35+
# ----------- Config ------------------
36+
IMAGE="ghcr.io/pdidev/ubuntu/rolling/openmpi/all:v4"
37+
TMP_DIR="/tmp_dir_test"
38+
BINARY_PATH="bin/build_and_run_all_tests"
39+
# ------------------------------------
40+
41+
if command -v podman &>/dev/null; then
42+
CONTAINER_CMD="podman"
43+
USERNS_ARGS="--userns=keep-id"
44+
elif command -v docker &>/dev/null; then
45+
CONTAINER_CMD="docker"
46+
USERNS_ARGS="--user $(id -u):$(id -g)"
47+
else
48+
echo "Error: neither podman nor docker found in PATH." >&2
49+
exit 1
50+
fi
51+
52+
REPO_ROOT=$(git rev-parse --show-toplevel)
53+
54+
if [[ ! -f "$REPO_ROOT/$BINARY_PATH" ]]; then
55+
echo "Script not found at $REPO_ROOT/$BINARY_PATH"
56+
exit 1
57+
fi
58+
59+
echo -e "Running CI tests (using $CONTAINER_CMD)\n"
60+
61+
$CONTAINER_CMD run --rm \
62+
$USERNS_ARGS \
63+
-v "$REPO_ROOT":/src \
64+
--tmpfs "$TMP_DIR:exec" \
65+
-e MAKEFLAGS="-j 4" \
66+
-e TEST_DIR="/tmp_dir_test" \
67+
-e CMAKE_FLAGS="-DBUILD_DOCUMENTATION=OFF" \
68+
"$IMAGE" \
69+
/src/bin/build_and_run_all_tests
70+
71+
echo -e "\nDone"

0 commit comments

Comments
 (0)