Skip to content

Commit 2d139e5

Browse files
authored
Improve unit test path filtering rules (#2052)
* Improve path-filtering rules on unit test action See docs about how jobs that are skipped still report "success", which is necessary for jobs that are required to succeed based on branch protection rules. https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution * Code must be checked out for paths-filter to run * Only run on default pull request events Defaults are that it will run when a PR is opened, reopened, or synchronized (new commits pushed).
1 parent 96d0adb commit 2d139e5

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

.github/workflows/nodejs.yml

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,36 @@
22
name: Node CI
33

44
on:
5-
push:
6-
paths-ignore:
7-
- '**/*.md'
8-
- '**/*.asciidoc'
9-
- '**/*.txt'
10-
- 'docs/**'
11-
- '.ci/**'
12-
- '.buildkite/**'
13-
- 'scripts/**'
14-
- 'catalog-info.yaml'
15-
pull_request:
16-
paths-ignore:
17-
- '**/*.md'
18-
- '**/*.asciidoc'
19-
- '**/*.txt'
20-
- 'docs/**'
21-
- '.ci/**'
22-
- '.buildkite/**'
23-
- 'scripts/**'
24-
- 'catalog-info.yaml'
5+
pull_request: {}
256

267
jobs:
8+
paths-filter:
9+
name: Detect files changed
10+
runs-on: ubuntu-latest
11+
outputs:
12+
skip: '${{ steps.changes.outputs.skip }}'
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: dorny/paths-filter/@v2.11.1
16+
id: changes
17+
with:
18+
filters: |
19+
skip:
20+
- '**/*.md'
21+
- '**/*.asciidoc'
22+
- '**/*.txt'
23+
- 'docs/**'
24+
- '.ci/**'
25+
- '.buildkite/**'
26+
- 'scripts/**'
27+
- 'catalog-info.yaml'
28+
2729
test:
2830
name: Test
2931
runs-on: ${{ matrix.os }}
32+
needs: paths-filter
33+
# only run if files not in `skip` filter were changed
34+
if: needs.paths-filter.outputs.skip != 'true'
3035

3136
strategy:
3237
fail-fast: false
@@ -35,7 +40,7 @@ jobs:
3540
os: [ubuntu-latest, windows-latest, macOS-latest]
3641

3742
steps:
38-
- uses: actions/checkout@v3
43+
- uses: actions/checkout@v4
3944

4045
- name: Use Node.js ${{ matrix.node-version }}
4146
uses: actions/setup-node@v3

0 commit comments

Comments
 (0)