diff --git a/.github/workflow-scripts/__tests__/template-app-ci-state-test.js b/.github/workflow-scripts/__tests__/template-app-ci-state-test.js new file mode 100644 index 000000000000..7868340994d2 --- /dev/null +++ b/.github/workflow-scripts/__tests__/template-app-ci-state-test.js @@ -0,0 +1,277 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @noflow + * @format + */ + +const { + configurationResults, + prepareTestState, + recordConfigurationResult, + reportConfigurationResults, +} = require('../template-app-ci-state'); +const fs = require('node:fs'); +const os = require('node:os'); +const path = require('node:path'); + +const bothFlavors = ['Debug', 'Release']; + +function results(outputs, flavors = bothFlavors, previousResults = {}) { + return configurationResults({outputs, flavors, previousResults}); +} + +describe('template app configuration retries', () => { + it('does not retry when both configurations pass', () => { + expect( + results({'debug-result': 'passed', 'release-result': 'passed'}), + ).toEqual({ + results: {Debug: 'passed', Release: 'passed'}, + failedFlavors: [], + status: 'success', + }); + }); + + it.each(bothFlavors)('retries only the failed %s configuration', flavor => { + const outputs = {'debug-result': 'passed', 'release-result': 'passed'}; + outputs[`${flavor.toLowerCase()}-result`] = 'failed'; + expect(results(outputs).failedFlavors).toEqual([flavor]); + }); + + it('retains a successful build while retrying the other configuration', () => { + const first = results({ + 'debug-result': 'passed', + 'release-result': 'failed', + }); + const second = results( + {'release-result': 'passed'}, + first.failedFlavors, + first.results, + ); + expect(second.status).toBe('success'); + expect(second.results).toEqual({Debug: 'passed', Release: 'passed'}); + }); + + it('keeps a configuration retryable after its result step is lost', () => { + const first = results({'debug-result': 'passed'}); + const second = results({}, first.failedFlavors, first.results); + expect(second).toEqual({ + results: {Debug: 'passed', Release: 'failed'}, + failedFlavors: ['Release'], + status: 'failure', + }); + }); + + it('does not reuse an old pass for a configuration attempted again', () => { + expect( + results({}, ['Debug'], {Debug: 'passed', Release: 'passed'}), + ).toEqual({ + results: {Debug: 'failed', Release: 'passed'}, + failedFlavors: ['Debug'], + status: 'failure', + }); + }); + + it('never treats an omitted configuration without an earlier pass as passed', () => { + expect( + results({'release-result': 'passed'}, ['Release']).failedFlavors, + ).toEqual(['Debug']); + }); + + it.each([[], ['Debug', 'Debug'], ['Profile'], 'Debug'])( + 'rejects an invalid retry matrix %p', + flavors => { + expect(() => results({}, flavors)).toThrow('unique Debug/Release'); + }, + ); + + it('writes independent outputs for both matrix legs', () => { + const core = {setOutput: jest.fn()}; + recordConfigurationResult({core, flavor: 'Release', passed: false}); + recordConfigurationResult({core, flavor: 'Debug', passed: true}); + expect(core.setOutput.mock.calls).toEqual([ + ['release-result', 'failed'], + ['debug-result', 'passed'], + ]); + }); + + it('rejects an unknown configuration when recording results', () => { + expect(() => + recordConfigurationResult({ + core: {setOutput: jest.fn()}, + flavor: 'Profile', + passed: true, + }), + ).toThrow('Unknown template app configuration'); + }); +}); + +describe('template app final reporting', () => { + function core() { + const result = { + setOutput: jest.fn(), + setFailed: jest.fn(), + warning: jest.fn(), + summary: {addRaw: jest.fn(), write: jest.fn().mockResolvedValue()}, + }; + result.summary.addRaw.mockReturnValue(result.summary); + return result; + } + + async function report(jobResult, outputs, failOnError = false) { + const result = core(); + await reportConfigurationResults({ + context: { + serverUrl: 'https://github.com', + repo: {owner: 'react', repo: 'react-native'}, + runId: 1, + }, + core: result, + needs: {test: {result: jobResult, outputs}}, + job: 'test', + flavors: ['Release'], + previousResults: {Debug: 'passed', Release: 'failed'}, + failOnError, + attempt: 1, + }); + return result; + } + + it('reports success after the previously unsuccessful lane passes', async () => { + const result = await report('success', {'release-result': 'passed'}, true); + expect(result.setOutput).toHaveBeenCalledWith('status', 'success'); + expect(result.setOutput).toHaveBeenCalledWith('failed-flavors', '[]'); + expect(result.setFailed).not.toHaveBeenCalled(); + }); + + it('reports intermediate failures without failing the report job', async () => { + const result = await report('success', {'release-result': 'failed'}); + expect(result.setOutput).toHaveBeenCalledWith('status', 'failure'); + expect(result.setOutput).toHaveBeenCalledWith( + 'failed-flavors', + '["Release"]', + ); + expect(result.setFailed).not.toHaveBeenCalled(); + expect(result.warning).toHaveBeenCalled(); + }); + + it('fails the final attempt when a configuration still has not passed', async () => { + const result = await report('success', {'release-result': 'failed'}, true); + expect(result.setFailed).toHaveBeenCalled(); + }); + + it.each(['failure', 'cancelled', 'skipped'])( + 'does not hide a %s matrix job behind a passed result output', + async jobResult => { + const result = await report( + jobResult, + {'release-result': 'passed'}, + true, + ); + expect(result.setOutput).toHaveBeenCalledWith('status', 'failure'); + expect(result.setOutput).toHaveBeenCalledWith( + 'failed-flavors', + '["Release"]', + ); + expect(result.setFailed).toHaveBeenCalled(); + }, + ); + + it('treats missing app/setup results as failure on the final attempt', async () => { + const result = await report('failure', {}, true); + expect(result.setFailed).toHaveBeenCalledWith( + expect.stringContaining('job failure'), + ); + }); +}); + +describe('template app per-flow state', () => { + let directory; + let flowsDirectory; + let statePath; + let first; + let second; + + beforeEach(() => { + directory = fs.mkdtempSync(path.join(os.tmpdir(), 'template-app-ci-test-')); + flowsDirectory = path.join(directory, 'flows'); + fs.mkdirSync(flowsDirectory); + first = path.join(flowsDirectory, 'first.yml'); + second = path.join(flowsDirectory, 'second.yaml'); + fs.writeFileSync(first, 'appId: x\n---\n- launchApp\n'); + fs.writeFileSync(second, 'appId: x\n---\n- launchApp\n'); + statePath = path.join(directory, 'results.json'); + }); + + afterEach(() => { + fs.rmSync(directory, {recursive: true, force: true}); + }); + + function writeState(states) { + const flows = Object.fromEntries( + states.map(([flow, status]) => [ + path.relative(process.cwd(), flow).split(path.sep).join('/'), + {status, attempts: 1}, + ]), + ); + fs.writeFileSync(statePath, JSON.stringify({version: 1, flows})); + } + + it('runs the flows when the state artifact is missing', () => { + expect(prepareTestState(statePath, flowsDirectory)).toBe(true); + }); + + it('skips execution only when every expected flow has passed', () => { + writeState([ + [first, 'passed'], + [second, 'passed'], + ]); + expect(prepareTestState(statePath, flowsDirectory)).toBe(false); + }); + + it.each(['failed', 'pending'])( + 'runs unfinished flows with status %s', + status => { + writeState([ + [first, 'passed'], + [second, status], + ]); + expect(prepareTestState(statePath, flowsDirectory)).toBe(true); + }, + ); + + it('does not skip a flow missing from an otherwise successful state', () => { + writeState([[first, 'passed']]); + expect(prepareTestState(statePath, flowsDirectory)).toBe(true); + }); + + it('ignores helper flows, which are not independently executed', () => { + const helpers = path.join(flowsDirectory, 'helpers'); + fs.mkdirSync(helpers); + fs.writeFileSync(path.join(helpers, 'fragment.yml'), '- tapOn: x'); + writeState([ + [first, 'passed'], + [second, 'passed'], + ]); + expect(prepareTestState(statePath, flowsDirectory)).toBe(false); + }); + + it.each(['{invalid', 'null', '{"version":2,"flows":{}}'])( + 'discards invalid downloaded state %s before executing Maestro', + state => { + fs.writeFileSync(statePath, state); + expect(prepareTestState(statePath, flowsDirectory)).toBe(true); + expect(fs.existsSync(statePath)).toBe(false); + }, + ); + + it('does not interpret an empty flow directory as successful coverage', () => { + fs.unlinkSync(first); + fs.unlinkSync(second); + writeState([]); + expect(prepareTestState(statePath, flowsDirectory)).toBe(true); + }); +}); diff --git a/.github/workflow-scripts/template-app-ci-state.js b/.github/workflow-scripts/template-app-ci-state.js new file mode 100644 index 000000000000..f93ec4b3d150 --- /dev/null +++ b/.github/workflow-scripts/template-app-ci-state.js @@ -0,0 +1,131 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @noflow + * @format + */ + +const {collectFlows, loadState} = require('./maestro-ios'); +const {reportTestResults} = require('./report-test-results'); +const fs = require('node:fs'); +const path = require('node:path'); + +const FLAVORS = ['Debug', 'Release']; + +function recordConfigurationResult({core, flavor, passed}) { + if (!FLAVORS.includes(flavor)) { + throw new Error(`Unknown template app configuration: ${flavor}`); + } + // Each matrix leg writes only its own result, so a passing leg cannot + // overwrite the failure of another configuration. + core.setOutput( + `${flavor.toLowerCase()}-result`, + passed ? 'passed' : 'failed', + ); +} + +function configurationResults({flavors, previousResults, outputs}) { + if ( + !Array.isArray(flavors) || + flavors.length === 0 || + flavors.some(flavor => !FLAVORS.includes(flavor)) || + new Set(flavors).size !== flavors.length + ) { + throw new Error( + 'Expected a non-empty array of unique Debug/Release configurations', + ); + } + + const results = Object.fromEntries( + FLAVORS.map(flavor => { + const result = flavors.includes(flavor) + ? outputs[`${flavor.toLowerCase()}-result`] + : previousResults[flavor]; + // Missing results include runner/setup/reporting failures. They must + // remain eligible for another attempt rather than becoming a pass. + return [flavor, result === 'passed' ? 'passed' : 'failed']; + }), + ); + const failedFlavors = FLAVORS.filter(flavor => results[flavor] !== 'passed'); + return { + results, + failedFlavors, + status: failedFlavors.length === 0 ? 'success' : 'failure', + }; +} + +async function reportConfigurationResults({ + context, + core, + needs, + job, + flavors, + previousResults, + failOnError, + attempt, +}) { + const current = needs[job]; + const result = configurationResults({ + flavors, + previousResults, + outputs: current.outputs ?? {}, + }); + // A failed matrix job also needs a retry if its final result step was lost. + // Configuration results remain authoritative for omitted successful legs. + if (current.result !== 'success' && result.status === 'success') { + for (const flavor of flavors) { + result.results[flavor] = 'failed'; + } + result.failedFlavors = FLAVORS.filter( + flavor => result.results[flavor] !== 'passed', + ); + result.status = 'failure'; + } + core.setOutput('results', JSON.stringify(result.results)); + core.setOutput('failed-flavors', JSON.stringify(result.failedFlavors)); + await reportTestResults({ + context, + core, + needs: { + [job]: { + ...current, + outputs: {...current.outputs, status: result.status}, + }, + }, + failOnError, + attempt, + }); +} + +function prepareTestState(statePath, flowPath) { + let state; + try { + state = loadState(statePath); + } catch { + // A missing/invalid state download is recoverable: execute the flows + // again, and replace malformed JSON before the Maestro runner reads it. + fs.rmSync(statePath, {force: true}); + return true; + } + const flows = collectFlows(flowPath); + return !( + flows.length > 0 && + flows.every(flow => { + const key = path + .relative(process.cwd(), path.resolve(flow)) + .split(path.sep) + .join('/'); + return state.flows[key]?.status === 'passed'; + }) + ); +} + +module.exports = { + configurationResults, + prepareTestState, + recordConfigurationResult, + reportConfigurationResults, +}; diff --git a/.github/workflows/build-android-templateapp.yml b/.github/workflows/build-android-templateapp.yml index 104e7e47ab2b..d550af1154aa 100644 --- a/.github/workflows/build-android-templateapp.yml +++ b/.github/workflows/build-android-templateapp.yml @@ -8,7 +8,7 @@ on: jobs: build: - runs-on: 4-core-ubuntu + runs-on: ubuntu-latest container: image: reactnativecommunity/react-native-android:latest env: diff --git a/.github/workflows/build-ios-templateapp.yml b/.github/workflows/build-ios-templateapp.yml new file mode 100644 index 000000000000..281b5f6b9ccb --- /dev/null +++ b/.github/workflows/build-ios-templateapp.yml @@ -0,0 +1,169 @@ +name: Build iOS Template App + +permissions: + contents: read + actions: read + +on: + workflow_call: + inputs: + flavors: + description: 'JSON array of configurations to build' + type: string + default: '["Debug", "Release"]' + previous-results: + description: 'Results retained from an earlier build attempt in this run' + type: string + default: '{}' + fail-on-error: + type: boolean + default: false + outputs: + status: + description: 'Whether both configurations have built successfully' + value: ${{ jobs.report.outputs.status }} + results: + description: 'Build results for both configurations, including earlier attempts' + value: ${{ jobs.report.outputs.results }} + failed-flavors: + description: 'JSON array of configurations that still need a successful build' + value: ${{ jobs.report.outputs.failed-flavors }} + +jobs: + build: + runs-on: macos-26 + outputs: + debug-result: ${{ steps.report-status.outputs.debug-result }} + release-result: ${{ steps.report-status.outputs.release-result }} + failure-debug: ${{ steps.report-status.outputs.failure-debug }} + failure-release: ${{ steps.report-status.outputs.failure-release }} + strategy: + fail-fast: false + matrix: + flavor: ${{ fromJSON(inputs.flavors) }} + steps: + - name: Checkout + uses: actions/checkout@v6 + - name: Setup node.js + uses: ./.github/actions/setup-node + - name: Run yarn + uses: ./.github/actions/yarn-install + - name: Setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6.10 + - name: Download React Native Package + uses: ./.github/actions/download-artifact + with: + name: react-native-package + path: /tmp/react-native-tmp + - name: Print /tmp folder + run: ls -lR /tmp/react-native-tmp + - name: Download ReactNativeDependencies + uses: ./.github/actions/download-artifact + with: + name: ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz + path: /tmp/third-party + - name: Print third-party folder + shell: bash + run: ls -lR /tmp/third-party + - name: Download React Native Prebuilds + uses: ./.github/actions/download-artifact + with: + name: ReactCore${{ matrix.flavor }}.xcframework.tar.gz + path: /tmp/ReactCore + - name: Print ReactCore folder + shell: bash + run: ls -lR /tmp/ReactCore + - name: Configure git + shell: bash + run: | + git config --global user.email "react-native-bot@meta.com" + git config --global user.name "React Native Bot" + - name: Build the app + run: | + REACT_NATIVE_PKG=$(find /tmp/react-native-tmp -type f -name "*.tgz") + echo "React Native tgs is $REACT_NATIVE_PKG" + + # For stable branches, we want to use the stable branch of the template + # In all the other cases, we want to use "main" + BRANCH=${{ github.base_ref || github.ref_name }} + if ! [[ $BRANCH == *-stable* ]]; then + BRANCH=main + fi + + node ./scripts/e2e/init-project-e2e.js --projectName RNTestProject --currentBranch $BRANCH --directory /tmp/RNTestProject --pathToLocalReactNative $REACT_NATIVE_PKG + + cd /tmp/RNTestProject/ios + bundle install + NEW_ARCH_ENABLED=1 + + export RCT_USE_LOCAL_RN_DEP=/tmp/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz + # Disable prebuilds for now, as they are causing issues with E2E tests for 0.82-stable branch + export RCT_TESTONLY_RNCORE_TARBALL_PATH="/tmp/ReactCore/ReactCore${{ matrix.flavor }}.xcframework.tar.gz" + RN_STRICT_API=1 RCT_NEW_ARCH_ENABLED=$NEW_ARCH_ENABLED bundle exec pod install + + xcodebuild \ + -scheme "RNTestProject" \ + -workspace RNTestProject.xcworkspace \ + -configuration "${{ matrix.flavor }}" \ + -sdk "iphonesimulator" \ + -destination "generic/platform=iOS Simulator" \ + -derivedDataPath "/tmp/RNTestProject" + - name: Verify app supports the arm64 simulator + run: lipo /tmp/RNTestProject/Build/Products/${{ matrix.flavor }}-iphonesimulator/RNTestProject.app/RNTestProject -verify_arch arm64 + - name: Upload app + uses: ./.github/actions/upload-artifact + with: + name: RNTestProject-${{ matrix.flavor }} + overwrite: true + path: /tmp/RNTestProject/Build/Products/${{ matrix.flavor }}-iphonesimulator/RNTestProject.app + - name: Report status + id: report-status + if: always() + uses: actions/github-script@v8 + env: + STEP_RESULTS: ${{ toJSON(steps) }} + JOB_STATUS: ${{ job.status }} + TEST_FLAVOR: ${{ matrix.flavor }} + with: + script: | + const {recordJobFailure} = require('./.github/workflow-scripts/report-test-results'); + const {recordConfigurationResult} = require('./.github/workflow-scripts/template-app-ci-state'); + recordConfigurationResult({core, flavor: process.env.TEST_FLAVOR, + passed: process.env.JOB_STATUS === 'success'}); + await recordJobFailure({github, context, core, + steps: JSON.parse(process.env.STEP_RESULTS), + flavor: process.env.TEST_FLAVOR, + runnerName: process.env.RUNNER_NAME, + jobStatus: process.env.JOB_STATUS, + attempt: Number(process.env.GITHUB_RUN_ATTEMPT)}); + + report: + needs: build + if: ${{ !cancelled() }} + runs-on: ubuntu-latest + outputs: + status: ${{ steps.check.outputs.status }} + results: ${{ steps.check.outputs.results }} + failed-flavors: ${{ steps.check.outputs.failed-flavors }} + steps: + - name: Checkout + uses: actions/checkout@v6 + - name: Report configuration results + id: check + uses: actions/github-script@v8 + env: + JOB_RESULTS: ${{ toJSON(needs) }} + FLAVORS: ${{ inputs.flavors }} + PREVIOUS_RESULTS: ${{ inputs.previous-results }} + FAIL_ON_ERROR: ${{ inputs.fail-on-error }} + with: + script: | + const {reportConfigurationResults} = require('./.github/workflow-scripts/template-app-ci-state'); + await reportConfigurationResults({context, core, + needs: JSON.parse(process.env.JOB_RESULTS), job: 'build', + flavors: JSON.parse(process.env.FLAVORS), + previousResults: JSON.parse(process.env.PREVIOUS_RESULTS), + failOnError: process.env.FAIL_ON_ERROR === 'true', + attempt: Number(process.env.GITHUB_RUN_ATTEMPT)}); diff --git a/.github/workflows/e2e-android-rntester.yml b/.github/workflows/e2e-android-rntester.yml index 1452f518029e..ebb44e2b543f 100644 --- a/.github/workflows/e2e-android-rntester.yml +++ b/.github/workflows/e2e-android-rntester.yml @@ -20,7 +20,7 @@ on: jobs: test: - runs-on: 4-core-ubuntu + runs-on: ubuntu-latest outputs: status: ${{ steps.report-status.outputs.status }} failure-debug: ${{ steps.report-status.outputs.failure-debug }} diff --git a/.github/workflows/e2e-android-templateapp.yml b/.github/workflows/e2e-android-templateapp.yml index 5253d49bd876..d211c7210942 100644 --- a/.github/workflows/e2e-android-templateapp.yml +++ b/.github/workflows/e2e-android-templateapp.yml @@ -20,7 +20,7 @@ on: jobs: test: - runs-on: 4-core-ubuntu + runs-on: ubuntu-latest outputs: status: ${{ steps.report-status.outputs.status }} failure-debug: ${{ steps.report-status.outputs.failure-debug }} diff --git a/.github/workflows/e2e-ios-templateapp.yml b/.github/workflows/e2e-ios-templateapp.yml index 22795a58ef0a..fd94134e41e9 100644 --- a/.github/workflows/e2e-ios-templateapp.yml +++ b/.github/workflows/e2e-ios-templateapp.yml @@ -7,135 +7,50 @@ permissions: on: workflow_call: inputs: + flavors: + description: 'JSON array of configurations to test' + type: string + default: '["Debug", "Release"]' + previous-results: + description: 'Results retained from an earlier test attempt in this run' + type: string + default: '{}' + retry-attempt: + type: number + default: 0 fail-on-error: type: boolean default: false outputs: status: - description: 'The result of the E2E tests (success or failure)' + description: 'Whether both configurations have passed E2E' value: ${{ jobs.report.outputs.status }} + results: + description: 'Test results for both configurations, including earlier attempts' + value: ${{ jobs.report.outputs.results }} + failed-flavors: + description: 'JSON array of configurations that still need successful E2E' + value: ${{ jobs.report.outputs.failed-flavors }} jobs: - build: - runs-on: macos-26-large - outputs: - failure-debug: ${{ steps.report-status.outputs.failure-debug }} - failure-release: ${{ steps.report-status.outputs.failure-release }} - strategy: - fail-fast: false - matrix: - flavor: [Debug, Release] - steps: - - name: Checkout - uses: actions/checkout@v6 - - name: Setup node.js - uses: ./.github/actions/setup-node - - name: Run yarn - uses: ./.github/actions/yarn-install - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.6.10 - - name: Download React Native Package - uses: ./.github/actions/download-artifact - with: - name: react-native-package - path: /tmp/react-native-tmp - - name: Print /tmp folder - run: ls -lR /tmp/react-native-tmp - - name: Download ReactNativeDependencies - uses: ./.github/actions/download-artifact - with: - name: ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz - path: /tmp/third-party - - name: Print third-party folder - shell: bash - run: ls -lR /tmp/third-party - - name: Download React Native Prebuilds - uses: ./.github/actions/download-artifact - with: - name: ReactCore${{ matrix.flavor }}.xcframework.tar.gz - path: /tmp/ReactCore - - name: Print ReactCore folder - shell: bash - run: ls -lR /tmp/ReactCore - - name: Configure git - shell: bash - run: | - git config --global user.email "react-native-bot@meta.com" - git config --global user.name "React Native Bot" - - name: Build the app - run: | - REACT_NATIVE_PKG=$(find /tmp/react-native-tmp -type f -name "*.tgz") - echo "React Native tgs is $REACT_NATIVE_PKG" - - # For stable branches, we want to use the stable branch of the template - # In all the other cases, we want to use "main" - BRANCH=${{ github.ref_name }} - if ! [[ $BRANCH == *-stable* ]]; then - BRANCH=main - fi - - node ./scripts/e2e/init-project-e2e.js --projectName RNTestProject --currentBranch $BRANCH --directory /tmp/RNTestProject --pathToLocalReactNative $REACT_NATIVE_PKG - - cd /tmp/RNTestProject/ios - bundle install - NEW_ARCH_ENABLED=1 - - export RCT_USE_LOCAL_RN_DEP=/tmp/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz - # Disable prebuilds for now, as they are causing issues with E2E tests for 0.82-stable branch - export RCT_TESTONLY_RNCORE_TARBALL_PATH="/tmp/ReactCore/ReactCore${{ matrix.flavor }}.xcframework.tar.gz" - RN_STRICT_API=1 RCT_NEW_ARCH_ENABLED=$NEW_ARCH_ENABLED bundle exec pod install - - xcodebuild \ - -scheme "RNTestProject" \ - -workspace RNTestProject.xcworkspace \ - -configuration "${{ matrix.flavor }}" \ - -sdk "iphonesimulator" \ - -destination "generic/platform=iOS Simulator" \ - -derivedDataPath "/tmp/RNTestProject" - - name: Upload app - uses: ./.github/actions/upload-artifact - with: - name: RNTestProject-${{ matrix.flavor }} - overwrite: true - path: /tmp/RNTestProject/Build/Products/${{ matrix.flavor }}-iphonesimulator/RNTestProject.app - - name: Report status - id: report-status - if: always() - uses: actions/github-script@v8 - env: - STEP_RESULTS: ${{ toJSON(steps) }} - JOB_STATUS: ${{ job.status }} - TEST_FLAVOR: ${{ matrix.flavor }} - with: - script: | - const {recordJobFailure} = require('./.github/workflow-scripts/report-test-results'); - await recordJobFailure({github, context, core, - steps: JSON.parse(process.env.STEP_RESULTS), - flavor: process.env.TEST_FLAVOR, - runnerName: process.env.RUNNER_NAME, - jobStatus: process.env.JOB_STATUS, - attempt: Number(process.env.GITHUB_RUN_ATTEMPT)}); - test: - needs: build - runs-on: macos-26-large + # Standard arm64 runner: run the simulator natively, as RNTester does. + runs-on: macos-26 outputs: + debug-result: ${{ steps.report-status.outputs.debug-result }} + release-result: ${{ steps.report-status.outputs.release-result }} status: ${{ steps.report-status.outputs.status }} failure-debug: ${{ steps.report-status.outputs.failure-debug }} failure-release: ${{ steps.report-status.outputs.failure-release }} strategy: fail-fast: false matrix: - flavor: [Debug, Release] + flavor: ${{ fromJSON(inputs.flavors) }} steps: - name: Checkout uses: actions/checkout@v6 - name: Setup node.js uses: ./.github/actions/setup-node - - name: Run yarn - uses: ./.github/actions/yarn-install - name: Download app uses: ./.github/actions/download-artifact with: @@ -143,20 +58,37 @@ jobs: path: /tmp/RNTestProjectBuild/RNTestProject.app - name: Check downloaded folder content run: ls -l /tmp/RNTestProjectBuild/RNTestProject.app + - name: Download previous per-flow test state + if: inputs.retry-attempt > 0 + continue-on-error: true + uses: ./.github/actions/download-artifact + with: + name: e2e_ios_templateapp_state_${{ matrix.flavor }}_${{ github.run_attempt }} + path: /tmp/maestro-ios-state + - name: Check for unfinished E2E flows + id: test-state + uses: actions/github-script@v8 + with: + script: | + const {prepareTestState} = require('./.github/workflow-scripts/template-app-ci-state'); + core.setOutput('should-run', prepareTestState('/tmp/maestro-ios-state/results.json', './scripts/e2e/.maestro/')); + - name: Run yarn + if: steps.test-state.outputs.should-run == 'true' + uses: ./.github/actions/yarn-install - name: Download React Native Package - if: ${{ matrix.flavor == 'Debug' }} + if: ${{ steps.test-state.outputs.should-run == 'true' && matrix.flavor == 'Debug' }} uses: ./.github/actions/download-artifact with: name: react-native-package path: /tmp/react-native-tmp - name: Configure git - if: ${{ matrix.flavor == 'Debug' }} + if: ${{ steps.test-state.outputs.should-run == 'true' && matrix.flavor == 'Debug' }} shell: bash run: | git config --global user.email "react-native-bot@meta.com" git config --global user.name "React Native Bot" - name: Prepare project for Metro - if: ${{ matrix.flavor == 'Debug' }} + if: ${{ steps.test-state.outputs.should-run == 'true' && matrix.flavor == 'Debug' }} # In Debug the app loads its bundle from Metro, which must run from an # initialized project. Re-initialize it here (JS only — no pods); the # native app itself comes prebuilt from the `build` job. @@ -164,7 +96,7 @@ jobs: REACT_NATIVE_PKG=$(find /tmp/react-native-tmp -type f -name "*.tgz") echo "React Native tgs is $REACT_NATIVE_PKG" - BRANCH=${{ github.ref_name }} + BRANCH=${{ github.base_ref || github.ref_name }} if ! [[ $BRANCH == *-stable* ]]; then BRANCH=main fi @@ -172,6 +104,7 @@ jobs: node ./scripts/e2e/init-project-e2e.js --projectName RNTestProject --currentBranch $BRANCH --directory /tmp/RNTestProject --pathToLocalReactNative $REACT_NATIVE_PKG - name: Run E2E Tests id: run-tests + if: steps.test-state.outputs.should-run == 'true' continue-on-error: true uses: ./.github/actions/maestro-ios with: @@ -180,17 +113,34 @@ jobs: maestro-flow: ./scripts/e2e/.maestro/ flavor: ${{ matrix.flavor }} working-directory: /tmp/RNTestProject + device-model: iPhone-17-Pro + device-os: iOS-26-2 + test-state-path: /tmp/maestro-ios-state/results.json + - name: Store per-flow test state + if: ${{ !cancelled() && steps.test-state.outputs.should-run == 'true' }} + uses: ./.github/actions/upload-artifact + with: + name: e2e_ios_templateapp_state_${{ matrix.flavor }}_${{ github.run_attempt }} + overwrite: true + if-no-files-found: warn + path: /tmp/maestro-ios-state/results.json - name: Report status id: report-status if: always() uses: actions/github-script@v8 env: + SHOULD_RUN: ${{ steps.test-state.outputs.should-run }} + TEST_OUTCOME: ${{ steps.run-tests.outcome }} STEP_RESULTS: ${{ toJSON(steps) }} JOB_STATUS: ${{ job.status }} TEST_FLAVOR: ${{ matrix.flavor }} with: script: | const {recordJobFailure} = require('./.github/workflow-scripts/report-test-results'); + const {recordConfigurationResult} = require('./.github/workflow-scripts/template-app-ci-state'); + recordConfigurationResult({core, flavor: process.env.TEST_FLAVOR, + passed: process.env.JOB_STATUS === 'success' && + (process.env.SHOULD_RUN === 'false' || process.env.TEST_OUTCOME === 'success')}); await recordJobFailure({github, context, core, steps: JSON.parse(process.env.STEP_RESULTS), flavor: process.env.TEST_FLAVOR, @@ -199,24 +149,30 @@ jobs: attempt: Number(process.env.GITHUB_RUN_ATTEMPT)}); report: - needs: [build, test] - if: always() + needs: test + if: ${{ !cancelled() }} runs-on: ubuntu-latest outputs: status: ${{ steps.check.outputs.status }} + results: ${{ steps.check.outputs.results }} + failed-flavors: ${{ steps.check.outputs.failed-flavors }} steps: - name: Checkout uses: actions/checkout@v6 - - name: Report failed jobs + - name: Report configuration results id: check uses: actions/github-script@v8 env: JOB_RESULTS: ${{ toJSON(needs) }} + FLAVORS: ${{ inputs.flavors }} + PREVIOUS_RESULTS: ${{ inputs.previous-results }} FAIL_ON_ERROR: ${{ inputs.fail-on-error }} with: script: | - const {reportTestResults} = require('./.github/workflow-scripts/report-test-results'); - await reportTestResults({context, core, - needs: JSON.parse(process.env.JOB_RESULTS), + const {reportConfigurationResults} = require('./.github/workflow-scripts/template-app-ci-state'); + await reportConfigurationResults({context, core, + needs: JSON.parse(process.env.JOB_RESULTS), job: 'test', + flavors: JSON.parse(process.env.FLAVORS), + previousResults: JSON.parse(process.env.PREVIOUS_RESULTS), failOnError: process.env.FAIL_ON_ERROR === 'true', attempt: Number(process.env.GITHUB_RUN_ATTEMPT)}); diff --git a/.github/workflows/prebuild-ios-core.yml b/.github/workflows/prebuild-ios-core.yml index ae1fdb916675..b2666a2c9ff7 100644 --- a/.github/workflows/prebuild-ios-core.yml +++ b/.github/workflows/prebuild-ios-core.yml @@ -25,12 +25,27 @@ jobs: steps: - name: Checkout uses: actions/checkout@v6 + - name: Set Hermes version + shell: bash + env: + USE_HERMES_PREBUILT: ${{ inputs.use-hermes-prebuilt }} + run: | + if [ "$USE_HERMES_PREBUILT" == "true" ]; then + HERMES_VERSION=$(curl --fail --silent --show-error --retry 3 https://registry.npmjs.org/hermes-compiler/latest-v1 | jq -er '.version') + else + HERMES_VERSION=$(sed -n 's/^HERMES_VERSION_NAME=//p' packages/react-native/sdks/hermes-engine/version.properties) + fi + test -n "$HERMES_VERSION" + echo "HERMES_VERSION=$HERMES_VERSION" >> "$GITHUB_ENV" - name: Restore cache if present id: restore-ios-slice + if: inputs.version-type == '' uses: actions/cache/restore@v5 with: - key: v3-ios-core-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift', 'packages/react-native/scripts/ios-prebuild/*.js', 'packages/react-native/scripts/ios-prebuild.js', 'packages/react-native/React/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*') }} - path: packages/react-native/ + key: v4-ios-core-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashFiles('.github/workflows/prebuild-ios-*.yml', '.github/actions/setup-*/action.yml', '.github/actions/yarn-install/action.yml', 'package.json', 'yarn.lock', 'babel.config.js', 'scripts/build/**/*', 'scripts/releases/ios-prebuild/**/*', 'scripts/releases/prepare-ios-prebuilds.js', 'packages/react-native/package.json', 'packages/react-native/Package.swift', 'packages/react-native/scripts/**/*', 'packages/react-native-codegen/**/*', 'packages/react-native/React/**/*', 'packages/react-native/ReactApple/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*', 'packages/react-native/src/private/specs*/**/*', 'packages/react-native/src/**/Native*.js', 'packages/react-native/src/**/*NativeComponent.js', 'packages/react-native/third-party-podspecs/**/PrivacyInfo.xcprivacy', 'packages/react-native/sdks/hermes-engine/version.properties', '!packages/react-native/Libraries/**/*.js', '!packages/react-native/Libraries/**/*.js.flow', '!packages/react-native/Libraries/**/*.ts', '!packages/react-native/Libraries/**/*.tsx') }}-${{ env.HERMES_VERSION }} + path: | + packages/react-native/.build/output/spm/${{ matrix.flavor }}/Build/Products + packages/react-native/.build/headers - name: Setup node.js if: steps.restore-ios-slice.outputs.cache-hit != 'true' uses: ./.github/actions/setup-node @@ -40,19 +55,6 @@ jobs: - name: Yarn Install if: steps.restore-ios-slice.outputs.cache-hit != 'true' uses: ./.github/actions/yarn-install - - name: Set Hermes version - shell: bash - run: | - # Non-stable RN builds resolve Hermes from npm's latest-v1 dist-tag. - # TODO: rename 'latest-v1' to 'latest' once V1 is the only Hermes on npm. - # Stable builds use the version pinned in version.properties. - if [ "${{ inputs.use-hermes-prebuilt }}" == "true" ]; then - HERMES_VERSION="latest-v1" - else - HERMES_VERSION=$(sed -n 's/^HERMES_VERSION_NAME=//p' packages/react-native/sdks/hermes-engine/version.properties) - fi - echo "Using Hermes version: $HERMES_VERSION" - echo "HERMES_VERSION=$HERMES_VERSION" >> $GITHUB_ENV - name: Set React Native version shell: bash run: | @@ -108,9 +110,9 @@ jobs: packages/react-native/.build/output/spm/${{ matrix.flavor }}/Build/Products - name: Save Cache uses: actions/cache/save@v5 - if: ${{ github.ref == 'refs/heads/main' }} # To avoid that the cache explode + if: ${{ github.ref == 'refs/heads/0.89-stable' && inputs.version-type == '' && steps.restore-ios-slice.outputs.cache-hit != 'true' }} with: - key: v3-ios-core-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift', 'packages/react-native/scripts/ios-prebuild/*.js', 'packages/react-native/scripts/ios-prebuild.js', 'packages/react-native/React/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*') }} + key: ${{ steps.restore-ios-slice.outputs.cache-primary-key }} path: | packages/react-native/.build/output/spm/${{ matrix.flavor }}/Build/Products packages/react-native/.build/headers @@ -128,12 +130,28 @@ jobs: steps: - name: Checkout uses: actions/checkout@v6 + - name: Set Hermes version + shell: bash + env: + USE_HERMES_PREBUILT: ${{ inputs.use-hermes-prebuilt }} + run: | + if [ "$USE_HERMES_PREBUILT" == "true" ]; then + HERMES_VERSION=$(curl --fail --silent --show-error --retry 3 https://registry.npmjs.org/hermes-compiler/latest-v1 | jq -er '.version') + else + HERMES_VERSION=$(sed -n 's/^HERMES_VERSION_NAME=//p' packages/react-native/sdks/hermes-engine/version.properties) + fi + test -n "$HERMES_VERSION" + echo "HERMES_VERSION=$HERMES_VERSION" >> "$GITHUB_ENV" - name: Restore cache if present id: restore-ios-xcframework + if: inputs.version-type == '' uses: actions/cache/restore@v5 with: - path: packages/react-native/.build/output/xcframeworks - key: v4-ios-core-xcframework-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift', 'packages/react-native/scripts/ios-prebuild/*.js', 'packages/react-native/scripts/ios-prebuild.js', 'packages/react-native/React/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*') }} + path: | + packages/react-native/.build/output/xcframeworks/ReactCore${{matrix.flavor}}.xcframework.tar.gz + packages/react-native/.build/output/xcframeworks/ReactCore${{matrix.flavor}}.framework.dSYM.tar.gz + packages/react-native/.build/output/xcframeworks/ReactNativeHeaders${{matrix.flavor}}.xcframework.tar.gz + key: v5-ios-core-xcframework-${{ matrix.flavor }}-${{ hashFiles('.github/workflows/prebuild-ios-*.yml', '.github/actions/setup-*/action.yml', '.github/actions/yarn-install/action.yml', 'package.json', 'yarn.lock', 'babel.config.js', 'scripts/build/**/*', 'scripts/releases/ios-prebuild/**/*', 'scripts/releases/prepare-ios-prebuilds.js', 'packages/react-native/package.json', 'packages/react-native/Package.swift', 'packages/react-native/scripts/**/*', 'packages/react-native-codegen/**/*', 'packages/react-native/React/**/*', 'packages/react-native/ReactApple/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*', 'packages/react-native/src/private/specs*/**/*', 'packages/react-native/src/**/Native*.js', 'packages/react-native/src/**/*NativeComponent.js', 'packages/react-native/third-party-podspecs/**/PrivacyInfo.xcprivacy', 'packages/react-native/sdks/hermes-engine/version.properties', '!packages/react-native/Libraries/**/*.js', '!packages/react-native/Libraries/**/*.js.flow', '!packages/react-native/Libraries/**/*.ts', '!packages/react-native/Libraries/**/*.tsx') }}-${{ env.HERMES_VERSION }} - name: Setup node.js if: steps.restore-ios-xcframework.outputs.cache-hit != 'true' uses: ./.github/actions/setup-node @@ -175,20 +193,6 @@ jobs: tar -xzf /tmp/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz -C /tmp/third-party/ mkdir -p packages/react-native/third-party/ mv /tmp/third-party/packages/react-native/third-party/ReactNativeDependencies.xcframework packages/react-native/third-party/ReactNativeDependencies.xcframework - - name: Set Hermes version - if: steps.restore-ios-xcframework.outputs.cache-hit != 'true' - shell: bash - run: | - # Non-stable RN builds resolve Hermes from npm's latest-v1 dist-tag. - # TODO: rename 'latest-v1' to 'latest' once V1 is the only Hermes on npm. - # Stable builds use the version pinned in version.properties. - if [ "${{ inputs.use-hermes-prebuilt }}" == "true" ]; then - HERMES_VERSION="latest-v1" - else - HERMES_VERSION=$(sed -n 's/^HERMES_VERSION_NAME=//p' packages/react-native/sdks/hermes-engine/version.properties) - fi - echo "Using Hermes version: $HERMES_VERSION" - echo "HERMES_VERSION=$HERMES_VERSION" >> $GITHUB_ENV - name: Stage Hermes headers if: steps.restore-ios-xcframework.outputs.cache-hit != 'true' working-directory: packages/react-native @@ -260,11 +264,11 @@ jobs: name: ReactNativeHeaders${{ matrix.flavor }}.xcframework.tar.gz path: packages/react-native/.build/output/xcframeworks/ReactNativeHeaders${{matrix.flavor}}.xcframework.tar.gz - name: Save cache if present - if: ${{ github.ref == 'refs/heads/main' }} # To avoid that the cache explode + if: ${{ github.ref == 'refs/heads/0.89-stable' && inputs.version-type == '' && steps.restore-ios-xcframework.outputs.cache-hit != 'true' }} uses: actions/cache/save@v5 with: path: | packages/react-native/.build/output/xcframeworks/ReactCore${{matrix.flavor}}.xcframework.tar.gz packages/react-native/.build/output/xcframeworks/ReactCore${{matrix.flavor}}.framework.dSYM.tar.gz packages/react-native/.build/output/xcframeworks/ReactNativeHeaders${{matrix.flavor}}.xcframework.tar.gz - key: v4-ios-core-xcframework-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift', 'packages/react-native/scripts/ios-prebuild/*.js', 'packages/react-native/scripts/ios-prebuild.js', 'packages/react-native/React/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*') }} + key: ${{ steps.restore-ios-xcframework.outputs.cache-primary-key }} diff --git a/.github/workflows/prebuild-ios-dependencies.yml b/.github/workflows/prebuild-ios-dependencies.yml index d4afaed08eb5..328799fb2b08 100644 --- a/.github/workflows/prebuild-ios-dependencies.yml +++ b/.github/workflows/prebuild-ios-dependencies.yml @@ -17,7 +17,7 @@ jobs: uses: actions/cache/restore@v5 with: path: packages/react-native/third-party/ - key: v3-ios-dependencies-${{ hashfiles('scripts/releases/ios-prebuild/configuration.js') }} + key: v4-ios-dependencies-${{ hashfiles('scripts/releases/ios-prebuild/**/*', 'scripts/releases/prepare-ios-prebuilds.js', 'packages/react-native/scripts/ios-configure-glog.sh', 'packages/react-native/third-party-podspecs/**/PrivacyInfo.xcprivacy', '.github/workflows/prebuild-ios-dependencies.yml') }} enableCrossOsArchive: true - name: Yarn Install if: steps.restore-ios-prebuilds.outputs.cache-hit != 'true' @@ -37,9 +37,9 @@ jobs: path: packages/react-native/third-party/ - name: Save Cache uses: actions/cache/save@v5 - if: ${{ github.ref == 'refs/heads/main' }} # To avoid that the cache explode + if: ${{ github.ref == 'refs/heads/0.89-stable' && steps.restore-ios-prebuilds.outputs.cache-hit != 'true' }} with: - key: v3-ios-dependencies-${{ hashfiles('scripts/releases/ios-prebuild/configuration.js') }} + key: ${{ steps.restore-ios-prebuilds.outputs.cache-primary-key }} enableCrossOsArchive: true path: packages/react-native/third-party/ @@ -72,7 +72,7 @@ jobs: uses: actions/cache/restore@v5 with: path: packages/react-native/third-party/.build/Build/Products - key: v3-ios-dependencies-slice-folder-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashfiles('scripts/releases/ios-prebuild/configuration.js', 'scripts/releases/ios-prebuild/build.js') }} + key: v4-ios-dependencies-slice-folder-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashfiles('scripts/releases/ios-prebuild/**/*', 'scripts/releases/prepare-ios-prebuilds.js', 'packages/react-native/scripts/ios-configure-glog.sh', 'packages/react-native/third-party-podspecs/**/PrivacyInfo.xcprivacy', '.github/workflows/prebuild-ios-dependencies.yml', '.github/actions/setup-xcode/action.yml') }} - name: Setup xcode if: steps.restore-slice-folder.outputs.cache-hit != 'true' uses: ./.github/actions/setup-xcode @@ -99,10 +99,9 @@ jobs: packages/react-native/third-party/.build/Build/Products - name: Save Cache uses: actions/cache/save@v5 - if: ${{ github.ref == 'refs/heads/main' }} # To avoid that the cache explode + if: ${{ github.ref == 'refs/heads/0.89-stable' && steps.restore-slice-folder.outputs.cache-hit != 'true' }} with: - key: v3-ios-dependencies-slice-folder-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashfiles('scripts/releases/ios-prebuild/configuration.js', 'scripts/releases/ios-prebuild/build.js') }} - enableCrossOsArchive: true + key: ${{ steps.restore-slice-folder.outputs.cache-primary-key }} path: | packages/react-native/third-party/.build/Build/Products @@ -129,8 +128,10 @@ jobs: uses: actions/cache/restore@v5 with: path: | - packages/react-native/third-party/ - key: v5-ios-dependencies-xcframework-${{ matrix.flavor }}-${{ hashfiles('scripts/releases/ios-prebuild/configuration.js', 'scripts/releases/ios-prebuild/build.js', 'scripts/releases/ios-prebuild/compose-framework.js', 'packages/react-native/scripts/ios-prebuild/headers-xcframework.js', 'packages/react-native/scripts/ios-prebuild/headers-spec.js') }} + packages/react-native/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz + packages/react-native/third-party/ReactNativeDependenciesHeaders${{ matrix.flavor }}.xcframework.tar.gz + packages/react-native/third-party/Symbols/ReactNativeDependencies${{ matrix.flavor }}.framework.dSYM.tar.gz + key: v6-ios-dependencies-xcframework-${{ matrix.flavor }}-${{ hashfiles('scripts/releases/ios-prebuild/**/*', 'scripts/releases/prepare-ios-prebuilds.js', 'packages/react-native/scripts/ios-configure-glog.sh', 'packages/react-native/third-party-podspecs/**/PrivacyInfo.xcprivacy', '.github/workflows/prebuild-ios-dependencies.yml', '.github/actions/setup-xcode/action.yml', 'packages/react-native/scripts/ios-prebuild/headers-xcframework.js', 'packages/react-native/scripts/ios-prebuild/headers-spec.js') }} # If cache hit, we already have our binary. We don't need to do anything. - name: Yarn Install if: steps.restore-xcframework.outputs.cache-hit != 'true' @@ -197,11 +198,11 @@ jobs: path: | packages/react-native/third-party/Symbols/ReactNativeDependencies${{ matrix.flavor }}.framework.dSYM.tar.gz - name: Save XCFramework in Cache - if: ${{ github.ref == 'refs/heads/main' }} # To avoid that the cache explode + if: ${{ github.ref == 'refs/heads/0.89-stable' && steps.restore-xcframework.outputs.cache-hit != 'true' }} uses: actions/cache/save@v5 with: path: | packages/react-native/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz packages/react-native/third-party/ReactNativeDependenciesHeaders${{ matrix.flavor }}.xcframework.tar.gz - packages/react-native/third-party/ReactNativeDependencies${{ matrix.flavor }}.framework.dSYM.tar.gz - key: v5-ios-dependencies-xcframework-${{ matrix.flavor }}-${{ hashfiles('scripts/releases/ios-prebuild/configuration.js', 'scripts/releases/ios-prebuild/build.js', 'scripts/releases/ios-prebuild/compose-framework.js', 'packages/react-native/scripts/ios-prebuild/headers-xcframework.js', 'packages/react-native/scripts/ios-prebuild/headers-spec.js') }} + packages/react-native/third-party/Symbols/ReactNativeDependencies${{ matrix.flavor }}.framework.dSYM.tar.gz + key: ${{ steps.restore-xcframework.outputs.cache-primary-key }} diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml index 2c67bb36dc05..81acb66a3e81 100644 --- a/.github/workflows/test-all.yml +++ b/.github/workflows/test-all.yml @@ -20,30 +20,6 @@ concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: - set_release_type: - runs-on: ubuntu-latest - if: github.repository == 'react/react-native' - outputs: - RELEASE_TYPE: ${{ steps.set_release_type.outputs.RELEASE_TYPE }} - env: - EVENT_NAME: ${{ github.event_name }} - REF: ${{ github.ref }} - steps: - - id: set_release_type - run: | - if [[ $EVENT_NAME == "schedule" ]]; then - echo "Setting release type to nightly" - echo "RELEASE_TYPE=nightly" >> $GITHUB_OUTPUT - elif [[ $EVENT_NAME == "push" && $REF == refs/tags/v* ]]; then - echo "Setting release type to release" - echo "RELEASE_TYPE=release" >> $GITHUB_OUTPUT - else - echo "Setting release type to dry-run" - echo "RELEASE_TYPE=dry-run" >> $GITHUB_OUTPUT - fi - - echo "Should I run E2E tests? ${{ inputs.run-e2e-tests }}" - check_code_changes: runs-on: ubuntu-latest if: github.repository == 'react/react-native' @@ -51,6 +27,7 @@ jobs: any_code_change: ${{ steps.filter_exclusions.outputs.any_code_change == 'true' || github.event_name != 'pull_request' }} should_test_android: ${{ steps.filter_exclusions.outputs.should_test_android == 'true' || github.event_name != 'pull_request' }} should_test_ios: ${{ steps.filter_exclusions.outputs.should_test_ios == 'true' || github.event_name != 'pull_request' }} + should_test_fantom: ${{ steps.filter_exclusions.outputs.should_test_fantom == 'true' || github.event_name != 'pull_request' }} debugger_shell: ${{ steps.filter_inclusions.outputs.debugger_shell }} steps: - name: Checkout @@ -65,6 +42,7 @@ jobs: - '**' - '!**/__docs__/**' - '!**/*.md' + - '!**/LICENSE' should_test_android: # Not an isolated iOS change - '**' @@ -88,6 +66,24 @@ jobs: - '!packages/react-native/**/*.gradle*' - '!packages/react-native-popup-menu-android/**' - '!packages/rn-tester/android/**' + should_test_fantom: + - '**' + - '!**/__docs__/**' + - '!**/*.md' + - '!**/LICENSE' + - '!gradle/**' + - '!gradle*' + - '!packages/gradle-plugin/**' + - '!packages/react-native/ReactAndroid/**' + - '!packages/react-native/**/*.java' + - '!packages/react-native/**/*.kt' + - '!packages/react-native/**/*.gradle*' + - '!packages/react-native-popup-menu-android/**' + - '!packages/react-native/React/**' + - '!packages/react-native/ReactApple/**' + - '!packages/react-native/**/*.m' + - '!packages/react-native/**/*.mm' + - '!packages/react-native/**/*.podspec' - name: Check for code changes (inclusion patterns) uses: dorny/paths-filter@209e61402dbca8aa44f967535da6666b284025ed id: filter_inclusions @@ -109,7 +105,7 @@ jobs: uses: ./.github/workflows/prebuild-ios-core.yml if: ${{ needs.prebuild_apple_dependencies.result == 'success' }} with: - use-hermes-prebuilt: ${{ !endsWith(github.ref_name, '-stable') }} + use-hermes-prebuilt: ${{ !endsWith(github.base_ref || github.ref_name, '-stable') }} secrets: inherit needs: [prebuild_apple_dependencies] @@ -127,7 +123,7 @@ jobs: flavor: Debug test_ios_rntester_dynamic_frameworks: - runs-on: macos-15-large + runs-on: macos-15 needs: check_code_changes if: | needs.check_code_changes.outputs.any_code_change == 'true' && @@ -147,7 +143,7 @@ jobs: run-unit-tests: false # tests for dynamic frameworks are already run in the test_ios_rntester job; this is to just a test build from source (no prebuilds) test_ios_rntester: - runs-on: macos-15-large + runs-on: macos-15 needs: [prebuild_apple_dependencies, prebuild_react_native_core] if: ${{ needs.prebuild_react_native_core.result == 'success' }} continue-on-error: true @@ -205,23 +201,66 @@ jobs: with: platform: ios - test_e2e_ios_templateapp: - needs: [build_npm_package, prebuild_apple_dependencies, check_code_changes] + build_ios_templateapp: + needs: + [ + build_npm_package, + prebuild_apple_dependencies, + prebuild_react_native_core, + check_code_changes, + ] if: needs.check_code_changes.outputs.should_test_ios == 'true' + uses: ./.github/workflows/build-ios-templateapp.yml + secrets: inherit + + build_ios_templateapp_retry_1: + needs: build_ios_templateapp + if: ${{ !cancelled() && (needs.build_ios_templateapp.outputs.status == 'failure' || needs.build_ios_templateapp.result == 'failure') }} + uses: ./.github/workflows/build-ios-templateapp.yml + with: + flavors: ${{ needs.build_ios_templateapp.outputs.failed-flavors || '["Debug", "Release"]' }} + previous-results: ${{ needs.build_ios_templateapp.outputs.results || '{}' }} + secrets: inherit + + build_ios_templateapp_retry_2: + needs: build_ios_templateapp_retry_1 + if: ${{ !cancelled() && (needs.build_ios_templateapp_retry_1.outputs.status == 'failure' || needs.build_ios_templateapp_retry_1.result == 'failure') }} + uses: ./.github/workflows/build-ios-templateapp.yml + with: + flavors: ${{ needs.build_ios_templateapp_retry_1.outputs.failed-flavors || '["Debug", "Release"]' }} + previous-results: ${{ needs.build_ios_templateapp_retry_1.outputs.results || '{}' }} + fail-on-error: true + secrets: inherit + + test_e2e_ios_templateapp: + needs: + [ + build_ios_templateapp, + build_ios_templateapp_retry_1, + build_ios_templateapp_retry_2, + ] + if: ${{ !cancelled() && (needs.build_ios_templateapp.outputs.status == 'success' || needs.build_ios_templateapp_retry_1.outputs.status == 'success' || needs.build_ios_templateapp_retry_2.outputs.status == 'success') }} uses: ./.github/workflows/e2e-ios-templateapp.yml secrets: inherit test_e2e_ios_templateapp_retry_1: needs: test_e2e_ios_templateapp - if: ${{ always() && needs.test_e2e_ios_templateapp.outputs.status == 'failure' }} + if: ${{ !cancelled() && (needs.test_e2e_ios_templateapp.outputs.status == 'failure' || needs.test_e2e_ios_templateapp.result == 'failure') }} uses: ./.github/workflows/e2e-ios-templateapp.yml + with: + flavors: ${{ needs.test_e2e_ios_templateapp.outputs.failed-flavors || '["Debug", "Release"]' }} + previous-results: ${{ needs.test_e2e_ios_templateapp.outputs.results || '{}' }} + retry-attempt: 1 secrets: inherit test_e2e_ios_templateapp_retry_2: needs: test_e2e_ios_templateapp_retry_1 - if: ${{ always() && needs.test_e2e_ios_templateapp_retry_1.outputs.status == 'failure' }} + if: ${{ !cancelled() && (needs.test_e2e_ios_templateapp_retry_1.outputs.status == 'failure' || needs.test_e2e_ios_templateapp_retry_1.result == 'failure') }} uses: ./.github/workflows/e2e-ios-templateapp.yml with: + flavors: ${{ needs.test_e2e_ios_templateapp_retry_1.outputs.failed-flavors || '["Debug", "Release"]' }} + previous-results: ${{ needs.test_e2e_ios_templateapp_retry_1.outputs.results || '{}' }} + retry-attempt: 2 fail-on-error: true secrets: inherit @@ -290,8 +329,8 @@ jobs: build_fantom_runner: runs-on: 8-core-ubuntu - needs: [set_release_type, check_code_changes, lint] - if: needs.check_code_changes.outputs.any_code_change == 'true' + needs: [check_code_changes, lint] + if: needs.check_code_changes.outputs.should_test_fantom == 'true' container: image: reactnativecommunity/react-native-android:latest env: @@ -309,7 +348,7 @@ jobs: - name: Build Fantom Runner uses: ./.github/actions/build-fantom-runner with: - release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }} + release-type: dry-run gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }} run_fantom_tests: @@ -333,7 +372,7 @@ jobs: build_android: runs-on: 8-core-ubuntu - needs: [set_release_type, check_code_changes] + needs: check_code_changes if: | needs.check_code_changes.outputs.any_code_change == 'true' && needs.check_code_changes.outputs.should_test_android == 'true' @@ -354,7 +393,7 @@ jobs: - name: Build Android uses: ./.github/actions/build-android with: - release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }} + release-type: dry-run gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }} test_e2e_android_rntester: @@ -392,7 +431,6 @@ jobs: runs-on: 8-core-ubuntu needs: [ - set_release_type, check_code_changes, build_android, prebuild_apple_dependencies, @@ -420,12 +458,12 @@ jobs: - name: Build NPM Package uses: ./.github/actions/build-npm-package with: - release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }} + release-type: dry-run gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }} skip-apple-prebuilts: ${{ needs.check_code_changes.outputs.should_test_ios == 'false' }} test_android_helloworld: - runs-on: 4-core-ubuntu + runs-on: ubuntu-latest needs: [build_npm_package, build_android] if: ${{ always() && needs.build_android.result == 'success' && needs.build_npm_package.result == 'success' }} container: diff --git a/.github/workflows/test-ios-spm-helloworld.yml b/.github/workflows/test-ios-spm-helloworld.yml index 12713e06dc9f..dabff304f82b 100644 --- a/.github/workflows/test-ios-spm-helloworld.yml +++ b/.github/workflows/test-ios-spm-helloworld.yml @@ -8,7 +8,7 @@ on: jobs: test: - runs-on: macos-15-large + runs-on: macos-15 strategy: fail-fast: false matrix: diff --git a/.github/workflows/test-ios-spm-newapp.yml b/.github/workflows/test-ios-spm-newapp.yml index 8fafbf48fa55..bf8a68a00608 100644 --- a/.github/workflows/test-ios-spm-newapp.yml +++ b/.github/workflows/test-ios-spm-newapp.yml @@ -8,7 +8,7 @@ on: jobs: test: - runs-on: macos-15-large + runs-on: macos-15 strategy: fail-fast: false matrix: diff --git a/.github/workflows/test-ios-spm-rntester.yml b/.github/workflows/test-ios-spm-rntester.yml index cce98b0ba3d4..5b5b1fcfee93 100644 --- a/.github/workflows/test-ios-spm-rntester.yml +++ b/.github/workflows/test-ios-spm-rntester.yml @@ -8,7 +8,7 @@ on: jobs: test: - runs-on: macos-15-large + runs-on: macos-15 strategy: fail-fast: false matrix: