|
| 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