Skip to content

Commit 2745f26

Browse files
authored
CI: detect-changes workflow to only check the affected components on the CI side (#5843)
* CI: detect-changes workflow to only check the affected components on the CI side * Updated performance test approach * Smallish workflow update * Detect changes to sample apps * fix(ci): Include sample app and perf test changes in step-level platform gates The step-level platform-check in sample-application, sample-application-expo, and e2e-v2 workflows gated on needs_ios/needs_android, which only track SDK source and native code changes. When only sample app or performance test files changed, the job-level condition correctly triggered (via needs_sample_react_native, needs_sample_expo), but every platform step was skipped — runners allocated, zero meaningful work done, false green reported. Fix by checking sample_react_native/sample_expo/perf_tests as the first condition in each platform-check step. If the relevant files changed, all platforms proceed without skipping. Affected workflows: - sample-application.yml: build and test jobs (sample_react_native) - sample-application-expo.yml: build job (sample_expo) - e2e-v2.yml: metrics job (perf_tests) * fix(ci): Remove leading space in ruby/setup-ruby working-directory for Expo sample The working-directory value had a leading space (' samples/expo') due to an unnecessary ternary expression. Since the step is already guarded by an if condition checking matrix.platform == 'ios', the ternary was redundant. Simplified to the plain path 'samples/expo'. * Fixes
1 parent cd1db44 commit 2745f26

File tree

6 files changed

+480
-70
lines changed

6 files changed

+480
-70
lines changed

.github/file-filters.yml

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,62 @@ 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 to the SDK's iOS native code only (packages/core).
24+
# Does NOT include sample apps — sample changes have their own filters below.
25+
ios_native:
26+
- 'packages/core/ios/**'
27+
- 'packages/core/RNSentryCocoaTester/**'
28+
- 'packages/core/RNSentry.podspec'
29+
30+
# Changes to the SDK's Android native code only (packages/core).
31+
# Does NOT include sample apps — sample changes have their own filters below.
32+
android_native:
33+
- 'packages/core/android/**'
34+
- 'packages/core/RNSentryAndroidTester/**'
35+
- 'packages/core/sentry.gradle'
36+
37+
# Changes to JS/TS source code (affects ALL platforms)
38+
js_source:
39+
- 'packages/core/src/**'
40+
- 'packages/core/plugin/**'
41+
- 'packages/core/scripts/**'
42+
- 'packages/core/package.json'
43+
- 'packages/core/tsconfig.json'
44+
- 'yarn.lock'
45+
- 'package.json'
46+
- '.yarnrc.yml'
47+
48+
# Changes to JS/TS test files only
49+
js_test:
50+
- 'packages/core/test/**'
51+
52+
# Changes to the React Native sample app.
53+
# Triggers: sample-application.yml, buildandtest.yml (job_bundle).
54+
# Does NOT trigger: native-tests.yml, e2e-v2.yml, sample-application-expo.yml.
55+
sample_react_native:
56+
- 'samples/react-native/**'
57+
- 'samples/react-native-macos/**'
58+
59+
# Changes to the Expo sample app.
60+
# Triggers: sample-application-expo.yml only.
61+
# Does NOT trigger: native-tests.yml, e2e-v2.yml, sample-application.yml.
62+
sample_expo:
63+
- 'samples/expo/**'
64+
65+
# Changes to E2E test infrastructure
66+
e2e_tests:
67+
- 'dev-packages/e2e-tests/**'
68+
69+
# Changes to performance test infrastructure
70+
perf_tests:
71+
- 'performance-tests/**'
72+
73+
# CI workflow or infrastructure changes (should trigger everything)
74+
ci:
75+
- '.github/workflows/**'
76+
- '.github/actions/**'
77+
- '.github/file-filters.yml'
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
name: Detect Changes
2+
on:
3+
workflow_call:
4+
inputs:
5+
# Pass the caller's event name and ref so we can detect push-to-main/release.
6+
# Inside a reusable workflow github.event_name is always 'workflow_call',
7+
# so the caller must forward the real values explicitly.
8+
caller_event_name:
9+
description: 'The triggering event name from the caller (github.event_name)'
10+
required: true
11+
type: string
12+
caller_ref:
13+
description: 'The triggering ref from the caller (github.ref)'
14+
required: true
15+
type: string
16+
outputs:
17+
# Raw filter outputs — exposed for fine-grained use by callers
18+
ios_native:
19+
description: 'Whether SDK iOS native files changed'
20+
value: ${{ jobs.changes.outputs.ios_native }}
21+
android_native:
22+
description: 'Whether SDK Android native files changed'
23+
value: ${{ jobs.changes.outputs.android_native }}
24+
js_source:
25+
description: 'Whether JS/TS source files changed'
26+
value: ${{ jobs.changes.outputs.js_source }}
27+
js_test:
28+
description: 'Whether JS/TS test files changed'
29+
value: ${{ jobs.changes.outputs.js_test }}
30+
sample_react_native:
31+
description: 'Whether the React Native sample app changed'
32+
value: ${{ jobs.changes.outputs.sample_react_native }}
33+
sample_expo:
34+
description: 'Whether the Expo sample app changed'
35+
value: ${{ jobs.changes.outputs.sample_expo }}
36+
e2e_tests:
37+
description: 'Whether E2E test infrastructure changed'
38+
value: ${{ jobs.changes.outputs.e2e_tests }}
39+
perf_tests:
40+
description: 'Whether performance test infrastructure changed'
41+
value: ${{ jobs.changes.outputs.perf_tests }}
42+
ci:
43+
description: 'Whether CI workflow/action files changed'
44+
value: ${{ jobs.changes.outputs.ci }}
45+
# Convenience outputs consumed by individual workflows
46+
needs_ios:
47+
description: 'Whether iOS jobs should run (native tests, E2E, sample builds)'
48+
value: ${{ jobs.changes.outputs.needs_ios }}
49+
needs_android:
50+
description: 'Whether Android jobs should run (native tests, E2E, sample builds)'
51+
value: ${{ jobs.changes.outputs.needs_android }}
52+
needs_sample_react_native:
53+
description: 'Whether the React Native sample app workflow should run'
54+
value: ${{ jobs.changes.outputs.needs_sample_react_native }}
55+
needs_sample_expo:
56+
description: 'Whether the Expo sample app workflow should run'
57+
value: ${{ jobs.changes.outputs.needs_sample_expo }}
58+
59+
jobs:
60+
changes:
61+
name: Detect file changes
62+
runs-on: ubuntu-latest
63+
outputs:
64+
ios_native: ${{ steps.filter.outputs.ios_native }}
65+
android_native: ${{ steps.filter.outputs.android_native }}
66+
js_source: ${{ steps.filter.outputs.js_source }}
67+
js_test: ${{ steps.filter.outputs.js_test }}
68+
sample_react_native: ${{ steps.filter.outputs.sample_react_native }}
69+
sample_expo: ${{ steps.filter.outputs.sample_expo }}
70+
e2e_tests: ${{ steps.filter.outputs.e2e_tests }}
71+
perf_tests: ${{ steps.filter.outputs.perf_tests }}
72+
ci: ${{ steps.filter.outputs.ci }}
73+
needs_ios: ${{ steps.evaluate.outputs.needs_ios }}
74+
needs_android: ${{ steps.evaluate.outputs.needs_android }}
75+
needs_sample_react_native: ${{ steps.evaluate.outputs.needs_sample_react_native }}
76+
needs_sample_expo: ${{ steps.evaluate.outputs.needs_sample_expo }}
77+
steps:
78+
- uses: actions/checkout@v4
79+
80+
- name: Detect changed paths
81+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
82+
id: filter
83+
with:
84+
filters: .github/file-filters.yml
85+
86+
- name: Evaluate what needs to run
87+
id: evaluate
88+
env:
89+
IOS_NATIVE: ${{ steps.filter.outputs.ios_native }}
90+
ANDROID_NATIVE: ${{ steps.filter.outputs.android_native }}
91+
JS_SOURCE: ${{ steps.filter.outputs.js_source }}
92+
SAMPLE_RN: ${{ steps.filter.outputs.sample_react_native }}
93+
SAMPLE_EXPO: ${{ steps.filter.outputs.sample_expo }}
94+
CI_CHANGED: ${{ steps.filter.outputs.ci }}
95+
E2E_TESTS: ${{ steps.filter.outputs.e2e_tests }}
96+
IS_MAIN_OR_RELEASE: ${{ inputs.caller_event_name == 'push' && (inputs.caller_ref == 'refs/heads/main' || startsWith(inputs.caller_ref, 'refs/heads/release/')) }}
97+
run: |
98+
echo "--- Change Detection Summary ---"
99+
echo "ios_native=$IOS_NATIVE"
100+
echo "android_native=$ANDROID_NATIVE"
101+
echo "js_source=$JS_SOURCE"
102+
echo "sample_react_native=$SAMPLE_RN"
103+
echo "sample_expo=$SAMPLE_EXPO"
104+
echo "ci=$CI_CHANGED"
105+
echo "e2e_tests=$E2E_TESTS"
106+
echo "is_main_or_release=$IS_MAIN_OR_RELEASE"
107+
108+
# iOS/Android native test suites and E2E builds run when:
109+
# - The SDK's own native code changed (packages/core/ios or android)
110+
# - JS source changed (may affect native bridges)
111+
# - CI config changed (need to validate workflows themselves)
112+
# - E2E test infra changed (they test both platforms end-to-end)
113+
# - Push to main or release branch (always run everything)
114+
# Sample app changes do NOT trigger the full native test suite —
115+
# they only trigger their own sample-application workflows.
116+
# Performance test changes do NOT trigger native tests either —
117+
# they only trigger the metrics job in e2e-v2.yml.
118+
if [[ "$IOS_NATIVE" == "true" \
119+
|| "$JS_SOURCE" == "true" \
120+
|| "$CI_CHANGED" == "true" \
121+
|| "$E2E_TESTS" == "true" \
122+
|| "$IS_MAIN_OR_RELEASE" == "true" ]]; then
123+
echo "needs_ios=true" >> "$GITHUB_OUTPUT"
124+
echo "=> needs_ios=true"
125+
else
126+
echo "needs_ios=false" >> "$GITHUB_OUTPUT"
127+
echo "=> needs_ios=false"
128+
fi
129+
130+
if [[ "$ANDROID_NATIVE" == "true" \
131+
|| "$JS_SOURCE" == "true" \
132+
|| "$CI_CHANGED" == "true" \
133+
|| "$E2E_TESTS" == "true" \
134+
|| "$IS_MAIN_OR_RELEASE" == "true" ]]; then
135+
echo "needs_android=true" >> "$GITHUB_OUTPUT"
136+
echo "=> needs_android=true"
137+
else
138+
echo "needs_android=false" >> "$GITHUB_OUTPUT"
139+
echo "=> needs_android=false"
140+
fi
141+
142+
# React Native sample workflow runs when the RN sample itself changed,
143+
# or when anything that the sample depends on changed (SDK source, CI).
144+
if [[ "$SAMPLE_RN" == "true" \
145+
|| "$JS_SOURCE" == "true" \
146+
|| "$IOS_NATIVE" == "true" \
147+
|| "$ANDROID_NATIVE" == "true" \
148+
|| "$CI_CHANGED" == "true" \
149+
|| "$IS_MAIN_OR_RELEASE" == "true" ]]; then
150+
echo "needs_sample_react_native=true" >> "$GITHUB_OUTPUT"
151+
echo "=> needs_sample_react_native=true"
152+
else
153+
echo "needs_sample_react_native=false" >> "$GITHUB_OUTPUT"
154+
echo "=> needs_sample_react_native=false"
155+
fi
156+
157+
# Expo sample workflow runs when the Expo sample itself changed,
158+
# or when anything that the sample depends on changed (SDK source, CI).
159+
if [[ "$SAMPLE_EXPO" == "true" \
160+
|| "$JS_SOURCE" == "true" \
161+
|| "$IOS_NATIVE" == "true" \
162+
|| "$ANDROID_NATIVE" == "true" \
163+
|| "$CI_CHANGED" == "true" \
164+
|| "$IS_MAIN_OR_RELEASE" == "true" ]]; then
165+
echo "needs_sample_expo=true" >> "$GITHUB_OUTPUT"
166+
echo "=> needs_sample_expo=true"
167+
else
168+
echo "needs_sample_expo=false" >> "$GITHUB_OUTPUT"
169+
echo "=> needs_sample_expo=false"
170+
fi

0 commit comments

Comments
 (0)