-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Gate CI test jobs via change scanning instead of workflow-level paths-ignore #8979
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: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,19 +7,11 @@ on: | |
| - dev | ||
| - main | ||
| - releasing/* | ||
| paths-ignore: # skip if only docs are modified | ||
| - '**.md' | ||
| - '**.rst' | ||
| - 'docs/**' | ||
| pull_request: | ||
| branches: | ||
| - dev | ||
| - main | ||
| - releasing/* | ||
| paths-ignore: # skip if only docs are modified | ||
| - '**.md' | ||
| - '**.rst' | ||
| - 'docs/**' | ||
|
|
||
| concurrency: | ||
| # automatically cancel the previously triggered workflows when there's a newer version | ||
|
|
@@ -52,7 +44,59 @@ env: | |
| # When support is dropped for a version it is important to update these as appropriate. | ||
|
|
||
| jobs: | ||
| changes: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| outputs: | ||
| run_tests: ${{ steps.diff.outputs.run_tests }} | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
Comment on lines
+54
to
+56
coderabbitai[bot] marked this conversation as resolved.
|
||
| persist-credentials: false | ||
| - id: diff | ||
| name: Determine if non-doc changes exist | ||
| env: | ||
| BASE_REF: ${{ github.base_ref }} | ||
| EVENT_NAME: ${{ github.event_name }} | ||
| EVENT_BEFORE: ${{ github.event.before }} | ||
| EVENT_SHA: ${{ github.sha }} | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| # Default to running tests on any failure (fail-open for safety) | ||
| trap 'echo "run_tests=true" >> "$GITHUB_OUTPUT"' ERR | ||
|
|
||
| if [[ "$EVENT_NAME" == "pull_request" ]]; then | ||
| base_ref="origin/$BASE_REF" | ||
| git fetch origin "$BASE_REF" --depth=1 | ||
| changed_files=$(git diff --name-only "$base_ref"..."$EVENT_SHA") | ||
| else | ||
| before="$EVENT_BEFORE" | ||
| if [[ -z "$before" || "$before" == "0000000000000000000000000000000000000000" ]]; then | ||
| echo "run_tests=true" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| changed_files=$(git diff --name-only "$before"..."$EVENT_SHA") | ||
| fi | ||
|
|
||
| run_tests=false | ||
| while IFS= read -r file; do | ||
| [[ -z "$file" ]] && continue | ||
| if [[ "$file" == docs/* || "$file" == *.md || "$file" == *.rst ]]; then | ||
| continue | ||
| fi | ||
| run_tests=true | ||
| break | ||
| done <<< "$changed_files" | ||
|
|
||
| echo "run_tests=$run_tests" >> "$GITHUB_OUTPUT" | ||
|
Comment on lines
+66
to
+95
Contributor
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. 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: git ls-files .github/workflows && echo '---' && sed -n '1,220p' .github/workflows/cicd_tests.ymlRepository: Project-MONAI/MONAI Length of output: 8407 🌐 Web query:
💡 Result: GitHub treats a skipped job as a successful status for the purposes of branch protection [1][2][3]. When a job is skipped—for example, due to a conditional Citations:
🏁 Script executed: rg -n "needs: changes|timeout-minutes:|if: needs\.changes\.outputs\.run_tests" .github/workflows/cicd_tests.ymlRepository: Project-MONAI/MONAI Length of output: 520 Fail open when diff detection breaks 🧰 Tools🪛 zizmor (1.26.1)[warning] 47-84: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block (excessive-permissions) [error] 62-62: code injection via template expansion (template-injection): may expand into attacker-controllable code (template-injection) [error] 63-63: code injection via template expansion (template-injection): may expand into attacker-controllable code (template-injection) 🤖 Prompt for AI Agents |
||
|
|
||
| static-checks: # Perform static type and other checks using runtests.sh | ||
| needs: changes | ||
| if: needs.changes.outputs.run_tests == 'true' | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
|
|
@@ -84,6 +128,8 @@ jobs: | |
| $(pwd)/runtests.sh --build --${{ matrix.opt }} -j $(nproc --all) | ||
|
|
||
| min-dep: # Test with minumum dependencies installed for different OS, Python, and PyTorch combinations | ||
| needs: changes | ||
| if: needs.changes.outputs.run_tests == 'true' | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
|
|
@@ -167,6 +213,8 @@ jobs: | |
| NGC_TEAM: ${{ secrets.NGC_TEAM }} | ||
|
|
||
| full-dep: # Test with full dependencies installed for different OS runners | ||
| needs: changes | ||
| if: needs.changes.outputs.run_tests == 'true' | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
|
|
@@ -238,6 +286,8 @@ jobs: | |
| shell: bash | ||
|
|
||
| packaging: # Test package generation | ||
| needs: changes | ||
| if: needs.changes.outputs.run_tests == 'true' | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| QUICKTEST: True | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.