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