ci: skip lint and test on docs-only changes
Use dorny/paths-filter to detect Go file changes. When only docs or markdown files change, Lint and Test jobs are skipped. GitHub treats skipped required checks as passing, unblocking docs-only PRs. Previously, path filters in the on: trigger prevented the workflow from running at all, leaving required checks stuck as 'Waiting for status'.
- commit
- 50d5ee85687cb8df63ac16879208ee519f9c4acd
- author
- brice · · 2026-04-03 18:51 UTC
- parent
- cbca441
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +25 -20
M .github/workflows/ci.yml +25 -20
| @@ -3,31 +3,34 @@ name: CI | |||
| 3 | 3 | on: | |
| 4 | 4 | push: | |
| 5 | 5 | branches: [main] | |
| 6 | - | paths: | |
| 7 | - | - '**.go' | |
| 8 | - | - 'go.mod' | |
| 9 | - | - 'go.sum' | |
| 10 | - | - '.golangci.yml' | |
| 11 | - | - 'Makefile' | |
| 12 | - | - '.github/workflows/**' | |
| 13 | - | - '!**.md' | |
| 14 | - | - '!docs/**' | |
| 15 | - | - '!LICENSE' | |
| 16 | 6 | pull_request: | |
| 17 | - | paths: | |
| 18 | - | - '**.go' | |
| 19 | - | - 'go.mod' | |
| 20 | - | - 'go.sum' | |
| 21 | - | - '.golangci.yml' | |
| 22 | - | - 'Makefile' | |
| 23 | - | - '.github/workflows/**' | |
| 24 | - | - '!**.md' | |
| 25 | - | - '!docs/**' | |
| 26 | - | - '!LICENSE' | |
| 27 | 7 | ||
| 28 | 8 | jobs: | |
| 9 | + | changes: | |
| 10 | + | name: Detect changes | |
| 11 | + | runs-on: ubuntu-latest | |
| 12 | + | permissions: | |
| 13 | + | pull-requests: read | |
| 14 | + | outputs: | |
| 15 | + | go: ${{ steps.filter.outputs.go }} | |
| 16 | + | steps: | |
| 17 | + | - uses: actions/checkout@v6 | |
| 18 | + | - uses: dorny/paths-filter@v3 | |
| 19 | + | id: filter | |
| 20 | + | with: | |
| 21 | + | filters: | | |
| 22 | + | go: | |
| 23 | + | - '**.go' | |
| 24 | + | - 'go.mod' | |
| 25 | + | - 'go.sum' | |
| 26 | + | - '.golangci.yml' | |
| 27 | + | - 'Makefile' | |
| 28 | + | - '.github/workflows/**' | |
| 29 | + | ||
| 29 | 30 | lint: | |
| 30 | 31 | name: Lint | |
| 32 | + | needs: changes | |
| 33 | + | if: needs.changes.outputs.go == 'true' | |
| 31 | 34 | runs-on: ubuntu-latest | |
| 32 | 35 | steps: | |
| 33 | 36 | - uses: actions/checkout@v6 | |
| @@ -51,6 +54,8 @@ jobs: | |||
| 51 | 54 | ||
| 52 | 55 | test: | |
| 53 | 56 | name: Test | |
| 57 | + | needs: changes | |
| 58 | + | if: needs.changes.outputs.go == 'true' | |
| 54 | 59 | runs-on: ubuntu-latest | |
| 55 | 60 | steps: | |
| 56 | 61 | - uses: actions/checkout@v6 | |
| @@ -3,31 +3,34 @@ name: CI | |||||
| 3 | on: | 3 | on: | ||
| 4 | push: | 4 | push: | ||
| 5 | branches: [main] | 5 | branches: [main] | ||
| 6 | - | paths: | |||
| 7 | - | - '**.go' | |||
| 8 | - | - 'go.mod' | |||
| 9 | - | - 'go.sum' | |||
| 10 | - | - '.golangci.yml' | |||
| 11 | - | - 'Makefile' | |||
| 12 | - | - '.github/workflows/**' | |||
| 13 | - | - '!**.md' | |||
| 14 | - | - '!docs/**' | |||
| 15 | - | - '!LICENSE' | |||
| 16 | pull_request: | 6 | pull_request: | ||
| 17 | - | paths: | |||
| 18 | - | - '**.go' | |||
| 19 | - | - 'go.mod' | |||
| 20 | - | - 'go.sum' | |||
| 21 | - | - '.golangci.yml' | |||
| 22 | - | - 'Makefile' | |||
| 23 | - | - '.github/workflows/**' | |||
| 24 | - | - '!**.md' | |||
| 25 | - | - '!docs/**' | |||
| 26 | - | - '!LICENSE' | |||
| 27 | 7 | ||||
| 28 | jobs: | 8 | jobs: | ||
| 9 | + | changes: | |||
| 10 | + | name: Detect changes | |||
| 11 | + | runs-on: ubuntu-latest | |||
| 12 | + | permissions: | |||
| 13 | + | pull-requests: read | |||
| 14 | + | outputs: | |||
| 15 | + | go: ${{ steps.filter.outputs.go }} | |||
| 16 | + | steps: | |||
| 17 | + | - uses: actions/checkout@v6 | |||
| 18 | + | - uses: dorny/paths-filter@v3 | |||
| 19 | + | id: filter | |||
| 20 | + | with: | |||
| 21 | + | filters: | | |||
| 22 | + | go: | |||
| 23 | + | - '**.go' | |||
| 24 | + | - 'go.mod' | |||
| 25 | + | - 'go.sum' | |||
| 26 | + | - '.golangci.yml' | |||
| 27 | + | - 'Makefile' | |||
| 28 | + | - '.github/workflows/**' | |||
| 29 | + | ||||
| 29 | lint: | 30 | lint: | ||
| 30 | name: Lint | 31 | name: Lint | ||
| 32 | + | needs: changes | |||
| 33 | + | if: needs.changes.outputs.go == 'true' | |||
| 31 | runs-on: ubuntu-latest | 34 | runs-on: ubuntu-latest | ||
| 32 | steps: | 35 | steps: | ||
| 33 | - uses: actions/checkout@v6 | 36 | - uses: actions/checkout@v6 | ||
| @@ -51,6 +54,8 @@ jobs: | |||||
| 51 | 54 | ||||
| 52 | test: | 55 | test: | ||
| 53 | name: Test | 56 | name: Test | ||
| 57 | + | needs: changes | |||
| 58 | + | if: needs.changes.outputs.go == 'true' | |||
| 54 | runs-on: ubuntu-latest | 59 | runs-on: ubuntu-latest | ||
| 55 | steps: | 60 | steps: | ||
| 56 | - uses: actions/checkout@v6 | 61 | - uses: actions/checkout@v6 | ||