Skip to content

Commit dbd4ed7

Browse files
authored
perf: add path filtering to Nix validation CI job (Fission-AI#518)
Skip Nix flake validation when no Nix-related files change. This speeds up CI for PRs that only touch source code, docs, or tests. Files that trigger Nix validation: - flake.nix, flake.lock - package.json, pnpm-lock.yaml - scripts/update-flake.sh - .github/workflows/ci.yml Uses dorny/paths-filter@v3 for change detection. Required-checks jobs updated to handle skipped status correctly.
1 parent 473093f commit dbd4ed7

1 file changed

Lines changed: 35 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,29 @@ concurrency:
1515
cancel-in-progress: true
1616

1717
jobs:
18+
# Detect which files changed to enable path-based filtering
19+
changes:
20+
name: Detect changes
21+
runs-on: ubuntu-latest
22+
outputs:
23+
nix: ${{ steps.filter.outputs.nix }}
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Check for Nix-related changes
29+
uses: dorny/paths-filter@v3
30+
id: filter
31+
with:
32+
filters: |
33+
nix:
34+
- 'flake.nix'
35+
- 'flake.lock'
36+
- 'package.json'
37+
- 'pnpm-lock.yaml'
38+
- 'scripts/update-flake.sh'
39+
- '.github/workflows/ci.yml'
40+
1841
test_pr:
1942
name: Test
2043
runs-on: ubuntu-latest
@@ -160,6 +183,8 @@ jobs:
160183
name: Nix Flake Validation
161184
runs-on: ubuntu-latest
162185
timeout-minutes: 10
186+
needs: changes
187+
if: needs.changes.outputs.nix == 'true'
163188
steps:
164189
- name: Checkout code
165190
uses: actions/checkout@v4
@@ -262,10 +287,14 @@ jobs:
262287
echo "Lint job failed"
263288
exit 1
264289
fi
265-
if [[ "${{ needs.nix-flake-validate.result }}" != "success" ]]; then
290+
# Nix validation may be skipped if no Nix-related files changed
291+
if [[ "${{ needs.nix-flake-validate.result }}" != "success" && "${{ needs.nix-flake-validate.result }}" != "skipped" ]]; then
266292
echo "Nix flake validation job failed"
267293
exit 1
268294
fi
295+
if [[ "${{ needs.nix-flake-validate.result }}" == "skipped" ]]; then
296+
echo "Nix flake validation skipped (no Nix-related changes)"
297+
fi
269298
echo "All required checks passed!"
270299
271300
required-checks-main:
@@ -284,8 +313,12 @@ jobs:
284313
echo "Lint job failed"
285314
exit 1
286315
fi
287-
if [[ "${{ needs.nix-flake-validate.result }}" != "success" ]]; then
316+
# Nix validation may be skipped if no Nix-related files changed
317+
if [[ "${{ needs.nix-flake-validate.result }}" != "success" && "${{ needs.nix-flake-validate.result }}" != "skipped" ]]; then
288318
echo "Nix flake validation job failed"
289319
exit 1
290320
fi
321+
if [[ "${{ needs.nix-flake-validate.result }}" == "skipped" ]]; then
322+
echo "Nix flake validation skipped (no Nix-related changes)"
323+
fi
291324
echo "All required checks passed!"

0 commit comments

Comments
 (0)