From fb06d97727f523c300404268d9b7fc5b1f63d003 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Thu, 19 Sep 2024 15:12:41 -0400 Subject: [PATCH] BUG: Skip "CI (Build)" workflow for SuperBuild changes on "nightly-main" Skip the "CI (Build)" workflow if changes to "External_*.cmake" files are detected since the last Preview build. Pull request builds likely require an updated Docker image, which provides external dependencies, and building with outdated dependencies could lead to failures. To avoid this, the CI build is skipped when SuperBuild file changes may require an updated image. Additionally, since the GitHub action `dorny/paths-filter` does not suppor specifying the `base` input for pull request events, we replaced it with the `tj-actions/changed-files` action. This resolves the warning: "'base' input parameter is ignored when action is triggered by pull request event". --- .github/workflows/ci.yml | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd415780803..0e3da68709b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,10 +39,40 @@ jobs: - "Testing/**" - "CMakeLists.txt" - # Build Slicer if relevant paths were changed + # Retrieve changes in SuperBuild-related files relative to the 'nightly-main' branch + - name: "Detect SuperBuild Changes" + uses: tj-actions/changed-files@48d8f15b2aaa3d255ca5af3eba4870f807ce6b3c # v45.0.2 + id: superbuild-changes + with: + files: | + SuperBuild/External_* + base_sha: nightly-main + + # List any SuperBuild files that were changed + - name: "List Changed SuperBuild Files" + if: steps.superbuild-changes.outputs.any_changed == 'true' + run: | + echo "Changed files:" + for file in ${ALL_CHANGED_FILES}; do + echo " $file" + done + env: + ALL_CHANGED_FILES: ${{ steps.superbuild-changes.outputs.all_changed_files }} + + # Check prerequisites for the build + - name: "Check Prerequisites" + id: check-prereqisities + run: | + if [[ $SUPERBUILD_CHANGED == "true" ]]; then + echo "::warning ::Skipping Slicer build due to changes in SuperBuild files relative to 'nightly-main' branch." + fi + env: + SUPERBUILD_CHANGED: ${{ steps.superbuild-changes.outputs.any_changed }} + + # Build Slicer if relevant paths were changed and no SuperBuild changes were detected - name: "Build Slicer" id: slicer-build - if: steps.changes.outputs.paths-to-include == 'true' + if: ${{ steps.changes.outputs.paths-to-include == 'true' && steps.superbuild-changes.outputs.any_changed == 'false' }} uses: ./.github/actions/slicer-build # Upload the Slicer package artifact if the build was successful