ci: fix separation of docker build and test phases

This commit is contained in:
2025-11-09 11:02:38 +01:00
parent 3c82f2934c
commit d991dd38a0
3 changed files with 20 additions and 41 deletions
+6 -16
View File
@@ -6,28 +6,18 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_PATH="$(cd "$SCRIPT_DIR/../../" && pwd)"
DOCKERFILE_PATH="$SCRIPT_DIR/../occt.Dockerfile"
# Check for --unit-testing argument
RUN_UNIT_TESTS=false
if [[ "${1-}" == "--unit-testing" ]]; then
RUN_UNIT_TESTS=true
fi
echo "Building image..."
if ! docker build -f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" "$PROJECT_PATH"; then
echo "Image build failed." >&2
exit 1
fi
echo "Listing /usr/local/bin..."
if ! docker run --rm "$IMAGE_NAME" ls /usr/local/bin; then
echo "Listing /usr/local/bin failed." >&2
exit 1
fi
echo "Building base image..."
docker build --target base -f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" "$PROJECT_PATH"
if [ "$RUN_UNIT_TESTS" = true ]; then
echo "Building unit-testing stage..."
docker build --target unit-testing -f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" "$PROJECT_PATH"
echo "Running unit tests..."
if ! docker run --rm "$IMAGE_NAME" ctest --test-dir /app/build/unit-tests -V; then
echo "Unit tests failed." >&2
exit 1
fi
docker run --rm "$IMAGE_NAME" ctest --test-dir /app/build/unit-tests -V
fi