From 832f8efaa8f9f2f8c82a8f208e3a1b113db6f14d Mon Sep 17 00:00:00 2001 From: Tabish Bidiwale Date: Mon, 19 Jan 2026 01:07:12 -0800 Subject: [PATCH] perf: add path filtering to Nix validation CI job 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. --- .github/workflows/ci.yml | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3bea232dc..2b887c745 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,29 @@ concurrency: cancel-in-progress: true jobs: + # Detect which files changed to enable path-based filtering + changes: + name: Detect changes + runs-on: ubuntu-latest + outputs: + nix: ${{ steps.filter.outputs.nix }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Check for Nix-related changes + uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + nix: + - 'flake.nix' + - 'flake.lock' + - 'package.json' + - 'pnpm-lock.yaml' + - 'scripts/update-flake.sh' + - '.github/workflows/ci.yml' + test_pr: name: Test runs-on: ubuntu-latest @@ -160,6 +183,8 @@ jobs: name: Nix Flake Validation runs-on: ubuntu-latest timeout-minutes: 10 + needs: changes + if: needs.changes.outputs.nix == 'true' steps: - name: Checkout code uses: actions/checkout@v4 @@ -262,10 +287,14 @@ jobs: echo "Lint job failed" exit 1 fi - if [[ "${{ needs.nix-flake-validate.result }}" != "success" ]]; then + # Nix validation may be skipped if no Nix-related files changed + if [[ "${{ needs.nix-flake-validate.result }}" != "success" && "${{ needs.nix-flake-validate.result }}" != "skipped" ]]; then echo "Nix flake validation job failed" exit 1 fi + if [[ "${{ needs.nix-flake-validate.result }}" == "skipped" ]]; then + echo "Nix flake validation skipped (no Nix-related changes)" + fi echo "All required checks passed!" required-checks-main: @@ -284,8 +313,12 @@ jobs: echo "Lint job failed" exit 1 fi - if [[ "${{ needs.nix-flake-validate.result }}" != "success" ]]; then + # Nix validation may be skipped if no Nix-related files changed + if [[ "${{ needs.nix-flake-validate.result }}" != "success" && "${{ needs.nix-flake-validate.result }}" != "skipped" ]]; then echo "Nix flake validation job failed" exit 1 fi + if [[ "${{ needs.nix-flake-validate.result }}" == "skipped" ]]; then + echo "Nix flake validation skipped (no Nix-related changes)" + fi echo "All required checks passed!"