Skip to content

Commit 8b73712

Browse files
committed
Extract E2E tests into reusable workflows to reduce duplication
Move each E2E test job into its own reusable workflow with an internal `report` job that reliably captures the test result across all matrix combinations. This eliminates the matrix output race condition from the previous approach and reduces test-all.yml by ~690 lines. Each reusable workflow: - Runs the matrix E2E tests in a `test` job - Has a non-matrix `report` job that checks `needs.test.result` and exposes a `status` output (success/failure) The callers in test-all.yml are now ~5 lines each instead of ~30-90.
1 parent a91dc39 commit 8b73712

5 files changed

Lines changed: 336 additions & 689 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: E2E Android RNTester
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
status:
7+
description: "The result of the E2E tests (success or failure)"
8+
value: ${{ jobs.report.outputs.status }}
9+
10+
jobs:
11+
test:
12+
runs-on: 4-core-ubuntu
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
flavor: [debug, release]
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v6
20+
- name: Setup node.js
21+
uses: ./.github/actions/setup-node
22+
- name: Install node dependencies
23+
uses: ./.github/actions/yarn-install
24+
- name: Download APK
25+
uses: actions/download-artifact@v7
26+
with:
27+
name: rntester-${{ matrix.flavor }}
28+
path: ./packages/rn-tester/android/app/build/outputs/apk/${{ matrix.flavor }}/
29+
- name: Print folder structure
30+
run: ls -lR ./packages/rn-tester/android/app/build/outputs/apk/${{ matrix.flavor }}/
31+
- name: Run E2E Tests
32+
uses: ./.github/actions/maestro-android
33+
timeout-minutes: 60
34+
with:
35+
app-path: ./packages/rn-tester/android/app/build/outputs/apk/${{ matrix.flavor }}/app-x86-${{ matrix.flavor }}.apk
36+
app-id: com.facebook.react.uiapp
37+
maestro-flow: ./packages/rn-tester/.maestro
38+
flavor: ${{ matrix.flavor }}
39+
40+
report:
41+
needs: test
42+
if: always()
43+
runs-on: ubuntu-latest
44+
outputs:
45+
status: ${{ steps.check.outputs.status }}
46+
steps:
47+
- id: check
48+
run: |
49+
if [[ "${{ needs.test.result }}" == "failure" ]]; then
50+
echo "status=failure" >> $GITHUB_OUTPUT
51+
else
52+
echo "status=success" >> $GITHUB_OUTPUT
53+
fi
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: E2E Android Template App
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
status:
7+
description: "The result of the E2E tests (success or failure)"
8+
value: ${{ jobs.report.outputs.status }}
9+
10+
jobs:
11+
test:
12+
runs-on: 4-core-ubuntu
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
flavor: [debug, release]
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v6
20+
- name: Setup node.js
21+
uses: ./.github/actions/setup-node
22+
- name: Run yarn
23+
uses: ./.github/actions/yarn-install
24+
- name: Set up JDK 17
25+
uses: actions/setup-java@v5
26+
with:
27+
java-version: '17'
28+
distribution: 'zulu'
29+
- name: Download Maven Local
30+
uses: actions/download-artifact@v7
31+
with:
32+
name: maven-local
33+
path: /tmp/react-native-tmp/maven-local
34+
- name: Download React Native Package
35+
uses: actions/download-artifact@v7
36+
with:
37+
name: react-native-package
38+
path: /tmp/react-native-tmp
39+
- name: Print /tmp folder
40+
run: ls -lR /tmp/react-native-tmp
41+
- name: Prepare artifacts
42+
id: prepare-artifacts
43+
run: |
44+
REACT_NATIVE_PKG=$(find /tmp/react-native-tmp -type f -name "*.tgz")
45+
echo "React Native tgs is $REACT_NATIVE_PKG"
46+
47+
MAVEN_LOCAL=/tmp/react-native-tmp/maven-local
48+
echo "Maven local path is $MAVEN_LOCAL"
49+
50+
# For stable branches, we want to use the stable branch of the template
51+
# In all the other cases, we want to use "main"
52+
BRANCH=${{ github.ref_name }}
53+
if ! [[ $BRANCH == *-stable* ]]; then
54+
BRANCH=main
55+
fi
56+
node ./scripts/e2e/init-project-e2e.js --projectName RNTestProject --currentBranch $BRANCH --directory /tmp/RNTestProject --pathToLocalReactNative $REACT_NATIVE_PKG
57+
58+
echo "Feed maven local to gradle.properties"
59+
cd /tmp/RNTestProject
60+
echo "react.internal.mavenLocalRepo=$MAVEN_LOCAL" >> android/gradle.properties
61+
62+
# Build
63+
cd android
64+
CAPITALIZED_FLAVOR=$(echo "${{ matrix.flavor }}" | awk '{print toupper(substr($0, 1, 1)) substr($0, 2)}')
65+
./gradlew assemble$CAPITALIZED_FLAVOR --no-daemon -PreactNativeArchitectures=x86
66+
67+
- name: Run E2E Tests
68+
uses: ./.github/actions/maestro-android
69+
timeout-minutes: 60
70+
with:
71+
app-path: /tmp/RNTestProject/android/app/build/outputs/apk/${{ matrix.flavor }}/app-${{ matrix.flavor }}.apk
72+
app-id: com.rntestproject
73+
maestro-flow: ./scripts/e2e/.maestro/
74+
install-java: 'false'
75+
flavor: ${{ matrix.flavor }}
76+
working-directory: /tmp/RNTestProject
77+
78+
report:
79+
needs: test
80+
if: always()
81+
runs-on: ubuntu-latest
82+
outputs:
83+
status: ${{ steps.check.outputs.status }}
84+
steps:
85+
- id: check
86+
run: |
87+
if [[ "${{ needs.test.result }}" == "failure" ]]; then
88+
echo "status=failure" >> $GITHUB_OUTPUT
89+
else
90+
echo "status=success" >> $GITHUB_OUTPUT
91+
fi
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: E2E iOS RNTester
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
status:
7+
description: "The result of the E2E tests (success or failure)"
8+
value: ${{ jobs.report.outputs.status }}
9+
10+
jobs:
11+
test:
12+
runs-on: macos-15-large
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
flavor: [Debug, Release]
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v6
20+
- name: Setup Node.js
21+
uses: ./.github/actions/setup-node
22+
- name: Download App
23+
uses: actions/download-artifact@v7
24+
with:
25+
name: RNTesterApp-NewArch-${{ matrix.flavor }}
26+
path: /tmp/RNTesterBuild/RNTester.app
27+
- name: Check downloaded folder content
28+
run: ls -lR /tmp/RNTesterBuild
29+
- name: Setup xcode
30+
uses: ./.github/actions/setup-xcode
31+
- name: Run E2E Tests
32+
uses: ./.github/actions/maestro-ios
33+
with:
34+
app-path: "/tmp/RNTesterBuild/RNTester.app"
35+
app-id: com.meta.RNTester.localDevelopment
36+
maestro-flow: ./packages/rn-tester/.maestro/
37+
flavor: ${{ matrix.flavor }}
38+
39+
report:
40+
needs: test
41+
if: always()
42+
runs-on: ubuntu-latest
43+
outputs:
44+
status: ${{ steps.check.outputs.status }}
45+
steps:
46+
- id: check
47+
run: |
48+
if [[ "${{ needs.test.result }}" == "failure" ]]; then
49+
echo "status=failure" >> $GITHUB_OUTPUT
50+
else
51+
echo "status=success" >> $GITHUB_OUTPUT
52+
fi
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: E2E iOS Template App
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
status:
7+
description: "The result of the E2E tests (success or failure)"
8+
value: ${{ jobs.report.outputs.status }}
9+
10+
jobs:
11+
test:
12+
runs-on: macos-15-large
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
flavor: [Debug, Release]
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v6
20+
- name: Setup xcode
21+
uses: ./.github/actions/setup-xcode
22+
- name: Setup node.js
23+
uses: ./.github/actions/setup-node
24+
- name: Run yarn
25+
uses: ./.github/actions/yarn-install
26+
- name: Setup ruby
27+
uses: ruby/setup-ruby@v1
28+
with:
29+
ruby-version: 2.6.10
30+
- name: Download React Native Package
31+
uses: actions/download-artifact@v7
32+
with:
33+
name: react-native-package
34+
path: /tmp/react-native-tmp
35+
- name: Print /tmp folder
36+
run: ls -lR /tmp/react-native-tmp
37+
- name: Download ReactNativeDependencies
38+
uses: actions/download-artifact@v7
39+
with:
40+
name: ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz
41+
path: /tmp/third-party
42+
- name: Print third-party folder
43+
shell: bash
44+
run: ls -lR /tmp/third-party
45+
- name: Download React Native Prebuilds
46+
uses: actions/download-artifact@v7
47+
with:
48+
name: ReactCore${{ matrix.flavor }}.xcframework.tar.gz
49+
path: /tmp/ReactCore
50+
- name: Print ReactCore folder
51+
shell: bash
52+
run: ls -lR /tmp/ReactCore
53+
- name: Configure git
54+
shell: bash
55+
run: |
56+
git config --global user.email "react-native-bot@meta.com"
57+
git config --global user.name "React Native Bot"
58+
- name: Prepare artifacts
59+
run: |
60+
REACT_NATIVE_PKG=$(find /tmp/react-native-tmp -type f -name "*.tgz")
61+
echo "React Native tgs is $REACT_NATIVE_PKG"
62+
63+
# For stable branches, we want to use the stable branch of the template
64+
# In all the other cases, we want to use "main"
65+
BRANCH=${{ github.ref_name }}
66+
if ! [[ $BRANCH == *-stable* ]]; then
67+
BRANCH=main
68+
fi
69+
70+
node ./scripts/e2e/init-project-e2e.js --projectName RNTestProject --currentBranch $BRANCH --directory /tmp/RNTestProject --pathToLocalReactNative $REACT_NATIVE_PKG
71+
72+
cd /tmp/RNTestProject/ios
73+
bundle install
74+
NEW_ARCH_ENABLED=1
75+
76+
export RCT_USE_LOCAL_RN_DEP=/tmp/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz
77+
# Disable prebuilds for now, as they are causing issues with E2E tests for 0.82-stable branch
78+
export RCT_TESTONLY_RNCORE_TARBALL_PATH="/tmp/ReactCore/ReactCore${{ matrix.flavor }}.xcframework.tar.gz"
79+
RCT_NEW_ARCH_ENABLED=$NEW_ARCH_ENABLED bundle exec pod install
80+
81+
xcodebuild \
82+
-scheme "RNTestProject" \
83+
-workspace RNTestProject.xcworkspace \
84+
-configuration "${{ matrix.flavor }}" \
85+
-sdk "iphonesimulator" \
86+
-destination "generic/platform=iOS Simulator" \
87+
-derivedDataPath "/tmp/RNTestProject"
88+
- name: Run E2E Tests
89+
uses: ./.github/actions/maestro-ios
90+
with:
91+
app-path: "/tmp/RNTestProject/Build/Products/${{ matrix.flavor }}-iphonesimulator/RNTestProject.app"
92+
app-id: org.reactjs.native.example.RNTestProject
93+
maestro-flow: ./scripts/e2e/.maestro/
94+
flavor: ${{ matrix.flavor }}
95+
working-directory: /tmp/RNTestProject
96+
97+
report:
98+
needs: test
99+
if: always()
100+
runs-on: ubuntu-latest
101+
outputs:
102+
status: ${{ steps.check.outputs.status }}
103+
steps:
104+
- id: check
105+
run: |
106+
if [[ "${{ needs.test.result }}" == "failure" ]]; then
107+
echo "status=failure" >> $GITHUB_OUTPUT
108+
else
109+
echo "status=success" >> $GITHUB_OUTPUT
110+
fi

0 commit comments

Comments
 (0)