Skip to content

Commit 70732f6

Browse files
lwshangclaude
andauthored
fix: use dorny/paths-filter so required checks pass on docs-only PRs (#427)
* fix: use dorny/paths-filter so required checks pass on docs-only PRs Replace workflow-level `paths-ignore` with job-level path filtering using `dorny/paths-filter`. When a PR only touches docs, markdown, or npm files the work jobs are skipped — but the workflow still triggers, so required status checks (fmt:required, lint:required, test:required) report as skipped instead of missing entirely. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: add comment explaining why test job checks discover's result Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d902c52 commit 70732f6

File tree

3 files changed

+92
-48
lines changed

3 files changed

+92
-48
lines changed

.github/workflows/checks.yml

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,33 @@ on:
44
push:
55
branches:
66
- main
7-
paths-ignore:
8-
# NOTE: docs/reference/cli.md is auto-generated and ideally should trigger
9-
# the cli-ref check when manually edited. However, GitHub Actions does not
10-
# support combining paths-ignore with negation patterns, so we accept the
11-
# tradeoff: manual edits to that file won't be caught in isolation, but
12-
# will be caught the next time any Rust source is changed and the checks run.
13-
- "**.md"
14-
- "docs-site/**"
15-
- "npm/**"
167
pull_request:
17-
paths-ignore:
18-
# See push paths-ignore NOTE above for the tradeoff explanation.
19-
- "**.md"
20-
- "docs-site/**"
21-
- "npm/**"
228

239
jobs:
10+
changes:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
src: ${{ steps.filter.outputs.src }}
14+
permissions:
15+
pull-requests: read
16+
steps:
17+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
18+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
19+
id: filter
20+
with:
21+
# 'src' is true when any changed file matches a positive pattern
22+
# and does not match a negative pattern (! prefix).
23+
filters: |
24+
src:
25+
- '**'
26+
- '!**.md'
27+
- '!docs-site/**'
28+
- '!npm/**'
29+
2430
compile:
2531
name: compile:required
32+
needs: changes
33+
if: needs.changes.outputs.src == 'true'
2634
runs-on: ubuntu-latest
2735

2836
steps:
@@ -42,7 +50,8 @@ jobs:
4250

4351
lint:
4452
name: lint:required
45-
needs: compile # Run after compilation to use the cache
53+
needs: [changes, compile]
54+
if: needs.changes.outputs.src == 'true'
4655
runs-on: ubuntu-latest
4756

4857
steps:
@@ -62,7 +71,8 @@ jobs:
6271

6372
format:
6473
name: fmt:required
65-
needs: compile
74+
needs: [changes, compile]
75+
if: needs.changes.outputs.src == 'true'
6676
runs-on: ubuntu-latest
6777

6878
steps:
@@ -80,6 +90,8 @@ jobs:
8090

8191
toml-format:
8292
name: toml-fmt:required
93+
needs: changes
94+
if: needs.changes.outputs.src == 'true'
8395
runs-on: ubuntu-latest
8496

8597
steps:
@@ -106,7 +118,8 @@ jobs:
106118
# generate the CLI reference file and check if it is up to date
107119
#
108120
name: cli-ref:required
109-
needs: compile
121+
needs: [changes, compile]
122+
if: needs.changes.outputs.src == 'true'
110123
runs-on: ubuntu-latest
111124

112125
steps:
@@ -140,7 +153,8 @@ jobs:
140153
# generate config schemas and check if they are up to date
141154
#
142155
name: icp-yaml-schema:required
143-
needs: compile
156+
needs: [changes, compile]
157+
if: needs.changes.outputs.src == 'true'
144158
runs-on: ubuntu-latest
145159

146160
steps:

.github/workflows/test.yml

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,7 @@ on:
44
push:
55
branches:
66
- main
7-
paths-ignore:
8-
- "**.md"
9-
- "docs/**"
10-
- "docs-site/**"
11-
- "npm/**"
127
pull_request:
13-
paths-ignore:
14-
- "**.md"
15-
- "docs/**"
16-
- "docs-site/**"
17-
- "npm/**"
188

199
env:
2010
# When getting Rust dependencies, retry on network error:
@@ -31,7 +21,30 @@ defaults:
3121
shell: bash
3222

3323
jobs:
24+
changes:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
src: ${{ steps.filter.outputs.src }}
28+
permissions:
29+
pull-requests: read
30+
steps:
31+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
32+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
33+
id: filter
34+
with:
35+
# 'src' is true when any changed file matches a positive pattern
36+
# and does not match a negative pattern (! prefix).
37+
filters: |
38+
src:
39+
- '**'
40+
- '!**.md'
41+
- '!docs/**'
42+
- '!docs-site/**'
43+
- '!npm/**'
44+
3445
discover:
46+
needs: changes
47+
if: needs.changes.outputs.src == 'true'
3548
runs-on: ubuntu-latest
3649
outputs:
3750
matrix: ${{ steps.set-matrix.outputs.matrix }}
@@ -42,6 +55,8 @@ jobs:
4255

4356
unit-tests:
4457
name: Unit tests on ${{ matrix.os }}
58+
needs: changes
59+
if: needs.changes.outputs.src == 'true'
4560
runs-on: ${{ matrix.os }}
4661

4762
strategy:
@@ -71,6 +86,9 @@ jobs:
7186
name: ${{ matrix.test }} on ${{ matrix.os }}
7287
# Wait until unit tests have run so we can reuse the cache
7388
needs: [discover, unit-tests]
89+
# Check discover's result (not changes.outputs.src) because this job
90+
# needs discover's matrix output, which is only available when it ran.
91+
if: needs.discover.result == 'success'
7492
runs-on: ${{ matrix.os }}
7593
strategy:
7694
fail-fast: false
@@ -144,10 +162,13 @@ jobs:
144162

145163
aggregate:
146164
name: test:required
147-
if: ${{ always() }}
165+
if: always() && needs.changes.outputs.src == 'true'
148166
runs-on: ubuntu-latest
149-
needs: [unit-tests, test]
167+
needs: [changes, unit-tests, test]
150168
steps:
151-
- name: check result
152-
if: ${{ needs.unit-tests.result != 'success' || needs.test.result != 'success' }}
169+
- name: check unit-tests result
170+
if: ${{ needs.unit-tests.result != 'success' }}
171+
run: exit 1
172+
- name: check test result
173+
if: ${{ needs.test.result != 'success' }}
153174
run: exit 1

.github/workflows/validate-examples.yml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,7 @@ on:
44
push:
55
branches:
66
- main
7-
paths-ignore:
8-
# NOTE: all docs/ markdown files are covered by "**.md" above. The only
9-
# docs/ files that still trigger this workflow are docs/schemas/*.json —
10-
# intentionally, since this workflow validates project manifests against
11-
# those schemas.
12-
- "**.md"
13-
- "docs-site/**"
14-
- "npm/**"
157
pull_request:
16-
paths-ignore:
17-
# See push paths-ignore NOTE above.
18-
- "**.md"
19-
- "docs-site/**"
20-
- "npm/**"
218

229
env:
2310
# When getting Rust dependencies, retry on network error:
@@ -26,8 +13,30 @@ env:
2613
CURL_HOME: .
2714

2815
jobs:
16+
changes:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
src: ${{ steps.filter.outputs.src }}
20+
permissions:
21+
pull-requests: read
22+
steps:
23+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
24+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
25+
id: filter
26+
with:
27+
# 'src' is true when any changed file matches a positive pattern
28+
# and does not match a negative pattern (! prefix).
29+
filters: |
30+
src:
31+
- '**'
32+
- '!**.md'
33+
- '!docs-site/**'
34+
- '!npm/**'
35+
2936
validate-examples:
3037
name: Validate Examples on ${{ matrix.os }}
38+
needs: changes
39+
if: needs.changes.outputs.src == 'true'
3140
runs-on: ${{ matrix.os }}
3241

3342
strategy:
@@ -54,10 +63,10 @@ jobs:
5463

5564
aggregate:
5665
name: validate-examples:required
57-
if: ${{ always() }}
66+
if: always() && needs.changes.outputs.src == 'true'
5867
runs-on: ubuntu-latest
59-
needs: [validate-examples]
68+
needs: [changes, validate-examples]
6069
steps:
61-
- name: check result
70+
- name: check validate-examples result
6271
if: ${{ needs.validate-examples.result != 'success' }}
6372
run: exit 1

0 commit comments

Comments
 (0)