-
Notifications
You must be signed in to change notification settings - Fork 25.2k
CI: add SwiftPM iOS e2e workflows (RNTester, HelloWorld, new app) #57659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
387bc99
da5340e
18322da
0df922c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| name: Test iOS SwiftPM - Hello World | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| flavor: | ||
| description: 'Which build configuration(s) to test' | ||
| type: choice | ||
| options: | ||
| - both | ||
| - Debug | ||
| - Release | ||
| default: both | ||
| schedule: | ||
| # Nightly at 07:00 UTC (low-traffic hour). | ||
| - cron: '0 7 * * *' | ||
|
|
||
| jobs: | ||
| prebuild_apple_dependencies: | ||
| uses: ./.github/workflows/prebuild-ios-dependencies.yml | ||
| with: | ||
| # e2e only compiles for the iOS simulator — no need for device/catalyst/tv/xr slices. | ||
| slices: '["ios-simulator"]' | ||
| secrets: inherit | ||
|
|
||
| prebuild_react_native_core: | ||
| needs: [prebuild_apple_dependencies] | ||
| if: ${{ needs.prebuild_apple_dependencies.result == 'success' }} | ||
| uses: ./.github/workflows/prebuild-ios-core.yml | ||
| with: | ||
| use-hermes-prebuilt: ${{ !endsWith(github.ref_name, '-stable') }} | ||
| slices: '["ios-simulator"]' | ||
| secrets: inherit | ||
|
Comment on lines
+22
to
+36
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you have to depend on the job that creates the XCFramework and download the XCFramework directly and use that one. We don't want to run the prebuild for these jobs. We want to consume the prebuilds we are creating. |
||
|
|
||
| set_flavors: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| flavors: ${{ steps.compute.outputs.flavors }} | ||
| steps: | ||
| - id: compute | ||
| env: | ||
| FLAVOR: ${{ github.event.inputs.flavor }} | ||
| run: | | ||
| case "$FLAVOR" in | ||
| Debug) echo 'flavors=["Debug"]' >> "$GITHUB_OUTPUT" ;; | ||
| Release) echo 'flavors=["Release"]' >> "$GITHUB_OUTPUT" ;; | ||
| *) echo 'flavors=["Debug","Release"]' >> "$GITHUB_OUTPUT" ;; | ||
| esac | ||
|
|
||
| test: | ||
| needs: [prebuild_react_native_core, set_flavors] | ||
| if: ${{ needs.prebuild_react_native_core.result == 'success' }} | ||
| runs-on: macos-15-large | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| flavor: ${{ fromJSON(needs.set_flavors.outputs.flavors) }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| - name: Setup xcode | ||
| uses: ./.github/actions/setup-xcode | ||
| - name: Setup node.js | ||
| uses: ./.github/actions/setup-node | ||
| - name: Run yarn install | ||
| uses: ./.github/actions/yarn-install | ||
| - name: Set Hermes prebuilt version | ||
| shell: bash | ||
| run: node ./scripts/releases/use-hermes-prebuilt.js | ||
| - name: Run yarn install again, with the correct hermes version | ||
| uses: ./.github/actions/yarn-install | ||
| - name: Ensure CocoaPods (needed by `spm add --deintegrate`) | ||
| shell: bash | ||
| run: pod --version || sudo gem install cocoapods --no-document | ||
| # `spm add --artifacts` validates BOTH the debug/ and release/ slots, so | ||
| # download both flavors regardless of which one this cell builds. | ||
| - name: Download ReactCore (Debug) | ||
| uses: actions/download-artifact@v7 | ||
| with: | ||
| name: ReactCoreDebug.xcframework.tar.gz | ||
| path: /tmp/rc-debug | ||
| - name: Download ReactCore (Release) | ||
| uses: actions/download-artifact@v7 | ||
| with: | ||
| name: ReactCoreRelease.xcframework.tar.gz | ||
| path: /tmp/rc-release | ||
|
Comment on lines
+80
to
+89
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you don't have to download both. You can have a matrix and run Debug and Release in parallel. |
||
| - name: Download ReactNativeDependencies (Debug) | ||
| uses: actions/download-artifact@v7 | ||
| with: | ||
| name: ReactNativeDependenciesDebug.xcframework.tar.gz | ||
| path: /tmp/deps-debug | ||
| - name: Download ReactNativeDependencies (Release) | ||
| uses: actions/download-artifact@v7 | ||
| with: | ||
| name: ReactNativeDependenciesRelease.xcframework.tar.gz | ||
| path: /tmp/deps-release | ||
| - name: Prime SPM artifacts (Debug + Release) | ||
| shell: bash | ||
| run: | | ||
| node scripts/e2e/spm-prime-artifacts.js --artifacts /tmp/spm-artifacts --flavor Debug \ | ||
| --core-tarball /tmp/rc-debug/ReactCoreDebug.xcframework.tar.gz \ | ||
| --deps-tarball /tmp/deps-debug/ReactNativeDependenciesDebug.xcframework.tar.gz | ||
| node scripts/e2e/spm-prime-artifacts.js --artifacts /tmp/spm-artifacts --flavor Release \ | ||
| --core-tarball /tmp/rc-release/ReactCoreRelease.xcframework.tar.gz \ | ||
| --deps-tarball /tmp/deps-release/ReactNativeDependenciesRelease.xcframework.tar.gz | ||
| - name: Convert to SwiftPM + build | ||
| shell: bash | ||
| run: | | ||
| node scripts/e2e/spm-ios-e2e.js \ | ||
| --app helloworld \ | ||
| --flavor "${{ matrix.flavor }}" \ | ||
| --artifacts /tmp/spm-artifacts | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| name: Test iOS SwiftPM - New App | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| flavor: | ||
| description: 'Which build configuration(s) to test' | ||
| type: choice | ||
| options: | ||
| - both | ||
| - Debug | ||
| - Release | ||
| default: both | ||
| schedule: | ||
| # Nightly at 08:00 UTC (low-traffic hour). | ||
| - cron: '0 8 * * *' | ||
|
|
||
| jobs: | ||
| prebuild_apple_dependencies: | ||
| uses: ./.github/workflows/prebuild-ios-dependencies.yml | ||
| with: | ||
| # e2e only compiles for the iOS simulator — no need for device/catalyst/tv/xr slices. | ||
| slices: '["ios-simulator"]' | ||
| secrets: inherit | ||
|
|
||
| prebuild_react_native_core: | ||
| needs: [prebuild_apple_dependencies] | ||
| if: ${{ needs.prebuild_apple_dependencies.result == 'success' }} | ||
| uses: ./.github/workflows/prebuild-ios-core.yml | ||
| with: | ||
| use-hermes-prebuilt: ${{ !endsWith(github.ref_name, '-stable') }} | ||
| slices: '["ios-simulator"]' | ||
| secrets: inherit | ||
|
Comment on lines
+22
to
+36
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
|
|
||
| # Produces the `react-native-package` artifact (a local react-native .tgz) the | ||
| # fresh app installs. Mirrors test-all.yml's build_npm_package (dry-run upload). | ||
| build_npm_package: | ||
| runs-on: 8-core-ubuntu | ||
| container: | ||
| image: reactnativecommunity/react-native-android:latest | ||
| env: | ||
| TERM: 'dumb' | ||
| LC_ALL: C.UTF8 | ||
| GRADLE_OPTS: '-Dorg.gradle.daemon=false' | ||
| REACT_NATIVE_DOWNLOADS_DIR: /opt/react-native-downloads | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| - name: Build NPM Package | ||
| uses: ./.github/actions/build-npm-package | ||
| with: | ||
| release-type: dry-run | ||
| gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }} | ||
| skip-apple-prebuilts: 'true' | ||
|
Comment on lines
+40
to
+57
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we rerun the build npm package when running the template app e2e tests. we should not do it here either. |
||
|
|
||
| set_flavors: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| flavors: ${{ steps.compute.outputs.flavors }} | ||
| steps: | ||
| - id: compute | ||
| env: | ||
| FLAVOR: ${{ github.event.inputs.flavor }} | ||
| run: | | ||
| case "$FLAVOR" in | ||
| Debug) echo 'flavors=["Debug"]' >> "$GITHUB_OUTPUT" ;; | ||
| Release) echo 'flavors=["Release"]' >> "$GITHUB_OUTPUT" ;; | ||
| *) echo 'flavors=["Debug","Release"]' >> "$GITHUB_OUTPUT" ;; | ||
| esac | ||
|
|
||
| test: | ||
| needs: [prebuild_react_native_core, build_npm_package, set_flavors] | ||
| if: ${{ needs.prebuild_react_native_core.result == 'success' && needs.build_npm_package.result == 'success' }} | ||
| runs-on: macos-15-large | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| flavor: ${{ fromJSON(needs.set_flavors.outputs.flavors) }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| - name: Setup xcode | ||
| uses: ./.github/actions/setup-xcode | ||
| - name: Setup node.js | ||
| uses: ./.github/actions/setup-node | ||
| - name: Run yarn install | ||
| uses: ./.github/actions/yarn-install | ||
| - name: Set Hermes prebuilt version | ||
| shell: bash | ||
| run: node ./scripts/releases/use-hermes-prebuilt.js | ||
| - name: Run yarn install again, with the correct hermes version | ||
| uses: ./.github/actions/yarn-install | ||
| - name: Ensure CocoaPods (needed by `spm add --deintegrate`) | ||
| shell: bash | ||
| run: pod --version || sudo gem install cocoapods --no-document | ||
| - name: Configure git (Verdaccio publish + build) | ||
| shell: bash | ||
| run: | | ||
| git config --global user.email "react-native-bot@meta.com" | ||
| git config --global user.name "React Native Bot" | ||
| - name: Download React Native package | ||
| uses: actions/download-artifact@v7 | ||
| with: | ||
| name: react-native-package | ||
| path: /tmp/react-native-tmp | ||
| # `spm add --artifacts` validates BOTH the debug/ and release/ slots, so | ||
| # download both flavors regardless of which one this cell builds. | ||
| - name: Download ReactCore (Debug) | ||
| uses: actions/download-artifact@v7 | ||
| with: | ||
| name: ReactCoreDebug.xcframework.tar.gz | ||
| path: /tmp/rc-debug | ||
| - name: Download ReactCore (Release) | ||
| uses: actions/download-artifact@v7 | ||
| with: | ||
| name: ReactCoreRelease.xcframework.tar.gz | ||
| path: /tmp/rc-release | ||
|
Comment on lines
+111
to
+120
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above, Debug and release should run in parallel. |
||
| - name: Download ReactNativeDependencies (Debug) | ||
| uses: actions/download-artifact@v7 | ||
| with: | ||
| name: ReactNativeDependenciesDebug.xcframework.tar.gz | ||
| path: /tmp/deps-debug | ||
| - name: Download ReactNativeDependencies (Release) | ||
| uses: actions/download-artifact@v7 | ||
| with: | ||
| name: ReactNativeDependenciesRelease.xcframework.tar.gz | ||
| path: /tmp/deps-release | ||
| - name: Prime SPM artifacts (Debug + Release) | ||
| shell: bash | ||
| run: | | ||
| node scripts/e2e/spm-prime-artifacts.js --artifacts /tmp/spm-artifacts --flavor Debug \ | ||
| --core-tarball /tmp/rc-debug/ReactCoreDebug.xcframework.tar.gz \ | ||
| --deps-tarball /tmp/deps-debug/ReactNativeDependenciesDebug.xcframework.tar.gz | ||
| node scripts/e2e/spm-prime-artifacts.js --artifacts /tmp/spm-artifacts --flavor Release \ | ||
| --core-tarball /tmp/rc-release/ReactCoreRelease.xcframework.tar.gz \ | ||
| --deps-tarball /tmp/deps-release/ReactNativeDependenciesRelease.xcframework.tar.gz | ||
| - name: Convert to SwiftPM + build | ||
| shell: bash | ||
| run: | | ||
| mapfile -t RN_PKGS < <(find /tmp/react-native-tmp -type f -name "*.tgz") | ||
| if [[ ${#RN_PKGS[@]} -ne 1 ]]; then | ||
| echo "Expected exactly one react-native .tgz in /tmp/react-native-tmp, found ${#RN_PKGS[@]}:" >&2 | ||
| printf ' %s\n' "${RN_PKGS[@]}" >&2 | ||
| exit 1 | ||
| fi | ||
| REACT_NATIVE_PKG="${RN_PKGS[0]}" | ||
| echo "react-native tarball: $REACT_NATIVE_PKG" | ||
| node scripts/e2e/spm-ios-e2e.js \ | ||
| --app newapp \ | ||
| --flavor "${{ matrix.flavor }}" \ | ||
| --artifacts /tmp/spm-artifacts \ | ||
| --rn-tarball "$REACT_NATIVE_PKG" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would just create the workflow and call it from test-all. I would not add a cron job here. We should rely on the nightly trigger.