-
Notifications
You must be signed in to change notification settings - Fork 11
Fix #596, add a script to run the CI locally #595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
95e1db3
d15a5ed
bcf9ed7
c387276
daf2661
b2fe0f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add podman support in addition to docker in |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| 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 |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it have to be so complex? In my case a simple: IMAGE_NAME=ghcr.io/pdidev/spack/latest/clang/openmpi/all:v4
podman/docker run --rm -ti -v ${PWD}:/src:ro ${IMAGE_NAME} /src/bin/build_and_run_all_testsdoes the trick. Do we need more?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The key phrase is "in my case", as all pdi contributors maybe shouldn't have to know about containers' directory mounting and the behaviour of the online CI. Two scripts (placed in the bin folder or a hidden folder for example, the second one being the indent script) could enable to test a local change, independently of the local environment, with an additional option to specify the image used.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. totally agree that a script makes sense. I just think it can be simpler
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correction, the previous commands are not sufficient on their own, a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ideally we shouldn't modify the user filesystem |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| #!/usr/bin/env bash | ||
| #============================================================================= | ||
| # Copyright (C) 2025-2026 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 | ||
|
|
||
| # ----------- Config ------------------ | ||
| IMAGE="ghcr.io/pdidev/ubuntu/rolling/openmpi/all:v4" | ||
| 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 <<EOF > "$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" | ||
| export CMAKE_FLAGS="-DBUILD_DOCUMENTATION=OFF" | ||
|
|
||
| chmod +x /tmp/build_and_run_all_tests | ||
| /tmp/build_and_run_all_tests | ||
| EOF | ||
|
|
||
| chmod +x "$SCRIPT_DIR/$SCRIPT_NAME" | ||
|
|
||
| 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" | ||
|
|
||
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?