Skip to content

Commit cccc3a9

Browse files
committed
ci(check): filter jobs by changes
1 parent c21fa27 commit cccc3a9

1 file changed

Lines changed: 55 additions & 9 deletions

File tree

.github/workflows/check.yaml

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,50 @@ concurrency:
1717
group: checks-${{ github.ref }}
1818

1919
jobs:
20+
changes:
21+
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
22+
23+
name: Detect changes
24+
25+
runs-on: ubuntu-latest
26+
27+
permissions:
28+
pull-requests: read
29+
30+
outputs:
31+
source: ${{ steps.filter.outputs.source }}
32+
docs: ${{ steps.filter.outputs.docs }}
33+
bundles: ${{ steps.filter.outputs.bundles }}
34+
35+
steps:
36+
- uses: actions/checkout@v6
37+
38+
- uses: dorny/paths-filter@v3
39+
id: filter
40+
with:
41+
filters: |
42+
source:
43+
- 'src/**'
44+
- 'test/**'
45+
- 'package.json'
46+
- 'pnpm-lock.yaml'
47+
- 'pnpm-workspace.yaml'
48+
- 'tsconfig*.json'
49+
- 'vitest.config.*'
50+
docs:
51+
- 'website/**'
52+
- 'docs/**'
53+
- 'src/**'
54+
- 'pnpm-workspace.yaml'
55+
bundles:
56+
- 'src/**'
57+
- 'scripts/**'
58+
- 'package.json'
59+
- 'pnpm-lock.yaml'
60+
- 'pnpm-workspace.yaml'
61+
- 'tsdown.config.*'
62+
- '.bun-version'
63+
2064
build:
2165
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
2266

@@ -66,11 +110,11 @@ jobs:
66110
run: pnpm run format
67111

68112
test_local:
69-
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
113+
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && (github.event_name == 'push' || needs.changes.outputs.source == 'true') }}
70114

71115
name: Local Tests
72116

73-
needs: [build]
117+
needs: [build, changes]
74118

75119
strategy:
76120
fail-fast: false
@@ -105,11 +149,11 @@ jobs:
105149
run: pnpm run test:local
106150

107151
test_api:
108-
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
152+
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && (github.event_name == 'push' || needs.changes.outputs.source == 'true') }}
109153

110154
name: API Tests
111155

112-
needs: [build]
156+
needs: [build, changes]
113157

114158
runs-on: ubuntu-latest
115159

@@ -134,11 +178,11 @@ jobs:
134178
run: pnpm run test:api
135179

136180
test_python_support:
137-
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
181+
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && (github.event_name == 'push' || needs.changes.outputs.source == 'true') }}
138182

139183
name: Python Support
140184

141-
needs: [build]
185+
needs: [build, changes]
142186

143187
strategy:
144188
fail-fast: false
@@ -174,10 +218,12 @@ jobs:
174218
run: pnpm run test:python
175219

176220
docs:
177-
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
221+
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && (github.event_name == 'push' || needs.changes.outputs.docs == 'true') }}
178222

179223
name: Docs build
180224

225+
needs: [changes]
226+
181227
runs-on: ubuntu-latest
182228

183229
steps:
@@ -198,11 +244,11 @@ jobs:
198244
pnpm run build
199245
200246
build_bundles:
201-
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
247+
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && (github.event_name == 'push' || needs.changes.outputs.bundles == 'true') }}
202248

203249
name: Bundles (${{ matrix.label }})
204250

205-
needs: [build]
251+
needs: [build, changes]
206252

207253
strategy:
208254
fail-fast: false

0 commit comments

Comments
 (0)