Skip to content

Commit e1a7965

Browse files
committed
CI: detect-changes workflow to only check the affected components on the CI side
1 parent cf8636c commit e1a7965

File tree

6 files changed

+373
-66
lines changed

6 files changed

+373
-66
lines changed

.github/file-filters.yml

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,53 @@ high_risk_code: &high_risk_code
1616
- 'scripts/sentry-xcode.sh'
1717
- 'scripts/sentry-xcode-debug-files.sh'
1818
- 'sentry.gradle'
19-
19+
20+
# --- Platform-specific filters for CI optimization ---
21+
# Used by detect-changes.yml to skip platform-irrelevant CI jobs.
22+
23+
# Changes that affect iOS native code
24+
ios_native:
25+
- 'packages/core/ios/**'
26+
- 'packages/core/RNSentryCocoaTester/**'
27+
- 'packages/core/RNSentry.podspec'
28+
- 'samples/react-native/ios/**'
29+
- 'samples/react-native/scripts/*ios*'
30+
- 'samples/react-native/scripts/pod-install.sh'
31+
- 'samples/react-native/Gemfile'
32+
- 'samples/react-native-macos/**'
33+
- 'samples/expo/ios/**'
34+
35+
# Changes that affect Android native code
36+
android_native:
37+
- 'packages/core/android/**'
38+
- 'packages/core/RNSentryAndroidTester/**'
39+
- 'packages/core/sentry.gradle'
40+
- 'samples/react-native/android/**'
41+
- 'samples/react-native/scripts/*android*'
42+
- 'samples/expo/android/**'
43+
44+
# Changes to JS/TS source code (affects ALL platforms)
45+
js_source:
46+
- 'packages/core/src/**'
47+
- 'packages/core/plugin/**'
48+
- 'packages/core/scripts/**'
49+
- 'packages/core/package.json'
50+
- 'packages/core/tsconfig.json'
51+
52+
# Changes to JS/TS test files only
53+
js_test:
54+
- 'packages/core/test/**'
55+
56+
# Changes to E2E test infrastructure
57+
e2e_tests:
58+
- 'dev-packages/e2e-tests/**'
59+
60+
# Changes to performance test infrastructure
61+
perf_tests:
62+
- 'performance-tests/**'
63+
64+
# CI workflow or infrastructure changes (should trigger everything)
65+
ci:
66+
- '.github/workflows/**'
67+
- '.github/actions/**'
68+
- '.github/file-filters.yml'
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Detect Changes
2+
on:
3+
workflow_call:
4+
outputs:
5+
# Raw filter outputs
6+
ios_native:
7+
description: 'Whether iOS native files changed'
8+
value: ${{ jobs.changes.outputs.ios_native }}
9+
android_native:
10+
description: 'Whether Android native files changed'
11+
value: ${{ jobs.changes.outputs.android_native }}
12+
js_source:
13+
description: 'Whether JS/TS source files changed'
14+
value: ${{ jobs.changes.outputs.js_source }}
15+
js_test:
16+
description: 'Whether JS/TS test files changed'
17+
value: ${{ jobs.changes.outputs.js_test }}
18+
e2e_tests:
19+
description: 'Whether E2E test files changed'
20+
value: ${{ jobs.changes.outputs.e2e_tests }}
21+
perf_tests:
22+
description: 'Whether performance test files changed'
23+
value: ${{ jobs.changes.outputs.perf_tests }}
24+
ci:
25+
description: 'Whether CI workflow files changed'
26+
value: ${{ jobs.changes.outputs.ci }}
27+
# Convenience: should iOS-related jobs run?
28+
needs_ios:
29+
description: 'Whether iOS jobs should run'
30+
value: ${{ jobs.changes.outputs.needs_ios }}
31+
# Convenience: should Android-related jobs run?
32+
needs_android:
33+
description: 'Whether Android jobs should run'
34+
value: ${{ jobs.changes.outputs.needs_android }}
35+
36+
jobs:
37+
changes:
38+
name: Detect file changes
39+
runs-on: ubuntu-latest
40+
outputs:
41+
ios_native: ${{ steps.filter.outputs.ios_native }}
42+
android_native: ${{ steps.filter.outputs.android_native }}
43+
js_source: ${{ steps.filter.outputs.js_source }}
44+
js_test: ${{ steps.filter.outputs.js_test }}
45+
e2e_tests: ${{ steps.filter.outputs.e2e_tests }}
46+
perf_tests: ${{ steps.filter.outputs.perf_tests }}
47+
ci: ${{ steps.filter.outputs.ci }}
48+
needs_ios: ${{ steps.evaluate.outputs.needs_ios }}
49+
needs_android: ${{ steps.evaluate.outputs.needs_android }}
50+
steps:
51+
- uses: actions/checkout@v4
52+
53+
- name: Detect changed paths
54+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
55+
id: filter
56+
with:
57+
filters: .github/file-filters.yml
58+
59+
- name: Evaluate platform needs
60+
id: evaluate
61+
env:
62+
IOS_NATIVE: ${{ steps.filter.outputs.ios_native }}
63+
ANDROID_NATIVE: ${{ steps.filter.outputs.android_native }}
64+
JS_SOURCE: ${{ steps.filter.outputs.js_source }}
65+
CI_CHANGED: ${{ steps.filter.outputs.ci }}
66+
E2E_TESTS: ${{ steps.filter.outputs.e2e_tests }}
67+
PERF_TESTS: ${{ steps.filter.outputs.perf_tests }}
68+
IS_MAIN_OR_RELEASE: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) }}
69+
run: |
70+
echo "--- Change Detection Summary ---"
71+
echo "ios_native=$IOS_NATIVE"
72+
echo "android_native=$ANDROID_NATIVE"
73+
echo "js_source=$JS_SOURCE"
74+
echo "ci=$CI_CHANGED"
75+
echo "e2e_tests=$E2E_TESTS"
76+
echo "perf_tests=$PERF_TESTS"
77+
echo "is_main_or_release=$IS_MAIN_OR_RELEASE"
78+
79+
# iOS is needed if:
80+
# - iOS native code changed
81+
# - JS source changed (may affect native bridges)
82+
# - CI config changed (need to validate workflows)
83+
# - E2E or perf tests changed (they test both platforms)
84+
# - Push to main or release branch (always run everything)
85+
if [[ "$IOS_NATIVE" == "true" \
86+
|| "$JS_SOURCE" == "true" \
87+
|| "$CI_CHANGED" == "true" \
88+
|| "$E2E_TESTS" == "true" \
89+
|| "$PERF_TESTS" == "true" \
90+
|| "$IS_MAIN_OR_RELEASE" == "true" ]]; then
91+
echo "needs_ios=true" >> "$GITHUB_OUTPUT"
92+
echo "=> needs_ios=true"
93+
else
94+
echo "needs_ios=false" >> "$GITHUB_OUTPUT"
95+
echo "=> needs_ios=false"
96+
fi
97+
98+
# Android is needed if:
99+
# - Android native code changed
100+
# - JS source changed (may affect native bridges)
101+
# - CI config changed (need to validate workflows)
102+
# - E2E or perf tests changed (they test both platforms)
103+
# - Push to main or release branch (always run everything)
104+
if [[ "$ANDROID_NATIVE" == "true" \
105+
|| "$JS_SOURCE" == "true" \
106+
|| "$CI_CHANGED" == "true" \
107+
|| "$E2E_TESTS" == "true" \
108+
|| "$PERF_TESTS" == "true" \
109+
|| "$IS_MAIN_OR_RELEASE" == "true" ]]; then
110+
echo "needs_android=true" >> "$GITHUB_OUTPUT"
111+
echo "=> needs_android=true"
112+
else
113+
echo "needs_android=false" >> "$GITHUB_OUTPUT"
114+
echo "=> needs_android=false"
115+
fi

0 commit comments

Comments
 (0)