Skip to content

Commit 8a19c48

Browse files
abueideclaude
andauthored
chore(ci): add path-based filtering to skip unnecessary E2E jobs (#52)
Uses dorny/paths-filter to detect which areas of the codebase changed and only runs relevant CI jobs. Segkit-only PRs skip all E2E tests (~30min saved), Android-only PRs skip iOS/RN E2E, etc. The status-check job now treats skipped jobs as success. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 75ab3ad commit 8a19c48

1 file changed

Lines changed: 60 additions & 11 deletions

File tree

.github/workflows/pr-checks.yml

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,43 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
# Linting and formatting checks
14+
# Detect which paths changed to skip unnecessary jobs
15+
detect-changes:
16+
name: Detect Changes
17+
runs-on: ubuntu-latest
18+
outputs:
19+
segkit: ${{ steps.filter.outputs.segkit }}
20+
android: ${{ steps.filter.outputs.android }}
21+
ios: ${{ steps.filter.outputs.ios }}
22+
rn: ${{ steps.filter.outputs.rn }}
23+
shell: ${{ steps.filter.outputs.shell }}
24+
ci: ${{ steps.filter.outputs.ci }}
25+
steps:
26+
- uses: actions/checkout@v6
27+
- uses: dorny/paths-filter@v3
28+
id: filter
29+
with:
30+
filters: |
31+
segkit:
32+
- 'segkit/**'
33+
android:
34+
- 'plugins/android/**'
35+
- 'examples/android/**'
36+
- 'plugins/tests/android/**'
37+
ios:
38+
- 'plugins/ios/**'
39+
- 'examples/ios/**'
40+
- 'plugins/tests/ios/**'
41+
rn:
42+
- 'plugins/react-native/**'
43+
- 'examples/react-native/**'
44+
- 'plugins/tests/react-native/**'
45+
shell:
46+
- 'plugins/**/scripts/**'
47+
ci:
48+
- '.github/**'
49+
50+
# Linting and formatting checks (always runs)
1551
lint:
1652
name: Lint
1753
runs-on: ubuntu-24.04
@@ -30,6 +66,8 @@ jobs:
3066
# Shell script unit tests (no SDK required)
3167
test-shell-scripts:
3268
name: Shell Script Tests
69+
needs: [detect-changes]
70+
if: needs.detect-changes.outputs.shell == 'true' || needs.detect-changes.outputs.ci == 'true'
3371
runs-on: ubuntu-24.04
3472
timeout-minutes: 10
3573
steps:
@@ -66,6 +104,8 @@ jobs:
66104
# Device config tests (no SDK build, just config validation)
67105
test-device-config:
68106
name: Device Config Tests
107+
needs: [detect-changes]
108+
if: needs.detect-changes.outputs.android == 'true' || needs.detect-changes.outputs.ios == 'true' || needs.detect-changes.outputs.ci == 'true'
69109
runs-on: ubuntu-24.04
70110
timeout-minutes: 10
71111
steps:
@@ -96,6 +136,8 @@ jobs:
96136

97137
# Android example E2E test (max device only on PRs)
98138
android-e2e:
139+
needs: [detect-changes]
140+
if: needs.detect-changes.outputs.android == 'true' || needs.detect-changes.outputs.rn == 'true' || needs.detect-changes.outputs.ci == 'true'
99141
uses: ./.github/workflows/e2e-android.yml
100142
with:
101143
devices: '["max"]'
@@ -108,6 +150,8 @@ jobs:
108150

109151
# iOS example E2E test (max device only on PRs)
110152
ios-e2e:
153+
needs: [detect-changes]
154+
if: needs.detect-changes.outputs.ios == 'true' || needs.detect-changes.outputs.rn == 'true' || needs.detect-changes.outputs.ci == 'true'
111155
uses: ./.github/workflows/e2e-ios.yml
112156
with:
113157
matrix-include: '[{"device":"max","os":"macos-26"}]'
@@ -118,13 +162,15 @@ jobs:
118162

119163
# React Native E2E tests (max device only on PRs, plus web)
120164
react-native-e2e:
165+
needs: [detect-changes]
166+
if: needs.detect-changes.outputs.rn == 'true' || needs.detect-changes.outputs.ci == 'true'
121167
uses: ./.github/workflows/e2e-react-native.yml
122168
with:
123169
matrix-include: '[{"platform":"android","device":"max","os":"ubuntu-24.04"},{"platform":"ios","device":"max","os":"macos-26"},{"platform":"web","device":"none","os":"ubuntu-24.04"}]'
124170
timeout-minutes: 45
125171
artifact-prefix: react-native
126172

127-
# Summary status check
173+
# Summary status check (treats skipped jobs as success)
128174
status-check:
129175
name: All PR Checks Passed
130176
runs-on: ubuntu-latest
@@ -142,13 +188,16 @@ jobs:
142188
echo " React Native E2E: ${{ needs.react-native-e2e.result }}"
143189
echo ""
144190
145-
if [[ "${{ needs.lint.result }}" != "success" ]] || \
146-
[[ "${{ needs.test-shell-scripts.result }}" != "success" ]] || \
147-
[[ "${{ needs.test-device-config.result }}" != "success" ]] || \
148-
[[ "${{ needs.android-e2e.result }}" != "success" ]] || \
149-
[[ "${{ needs.ios-e2e.result }}" != "success" ]] || \
150-
[[ "${{ needs.react-native-e2e.result }}" != "success" ]]; then
151-
echo "::error::One or more PR checks failed"
152-
exit 1
153-
fi
191+
for result in \
192+
"${{ needs.lint.result }}" \
193+
"${{ needs.test-shell-scripts.result }}" \
194+
"${{ needs.test-device-config.result }}" \
195+
"${{ needs.android-e2e.result }}" \
196+
"${{ needs.ios-e2e.result }}" \
197+
"${{ needs.react-native-e2e.result }}"; do
198+
if [[ "$result" != "success" && "$result" != "skipped" ]]; then
199+
echo "::error::One or more PR checks failed"
200+
exit 1
201+
fi
202+
done
154203
echo "::notice::All PR checks passed!"

0 commit comments

Comments
 (0)