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!"