|
| 1 | +name: E2E Android Template App |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_call: |
| 8 | + inputs: |
| 9 | + fail-on-error: |
| 10 | + type: boolean |
| 11 | + default: false |
| 12 | + outputs: |
| 13 | + status: |
| 14 | + description: "The result of the E2E tests (success or failure)" |
| 15 | + value: ${{ jobs.report.outputs.status }} |
| 16 | + |
| 17 | +jobs: |
| 18 | + test: |
| 19 | + runs-on: 4-core-ubuntu |
| 20 | + outputs: |
| 21 | + status: ${{ steps.report-status.outputs.status }} |
| 22 | + strategy: |
| 23 | + fail-fast: false |
| 24 | + matrix: |
| 25 | + flavor: [debug, release] |
| 26 | + steps: |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v6 |
| 29 | + - name: Setup node.js |
| 30 | + uses: ./.github/actions/setup-node |
| 31 | + - name: Run yarn |
| 32 | + uses: ./.github/actions/yarn-install |
| 33 | + - name: Set up JDK 17 |
| 34 | + uses: actions/setup-java@v5 |
| 35 | + with: |
| 36 | + java-version: '17' |
| 37 | + distribution: 'zulu' |
| 38 | + - name: Download Maven Local |
| 39 | + uses: actions/download-artifact@v7 |
| 40 | + with: |
| 41 | + name: maven-local |
| 42 | + path: /tmp/react-native-tmp/maven-local |
| 43 | + - name: Download React Native Package |
| 44 | + uses: actions/download-artifact@v7 |
| 45 | + with: |
| 46 | + name: react-native-package |
| 47 | + path: /tmp/react-native-tmp |
| 48 | + - name: Print /tmp folder |
| 49 | + run: ls -lR /tmp/react-native-tmp |
| 50 | + - name: Prepare artifacts |
| 51 | + id: prepare-artifacts |
| 52 | + run: | |
| 53 | + REACT_NATIVE_PKG=$(find /tmp/react-native-tmp -type f -name "*.tgz") |
| 54 | + echo "React Native tgs is $REACT_NATIVE_PKG" |
| 55 | +
|
| 56 | + MAVEN_LOCAL=/tmp/react-native-tmp/maven-local |
| 57 | + echo "Maven local path is $MAVEN_LOCAL" |
| 58 | +
|
| 59 | + # For stable branches, we want to use the stable branch of the template |
| 60 | + # In all the other cases, we want to use "main" |
| 61 | + BRANCH=${{ github.ref_name }} |
| 62 | + if ! [[ $BRANCH == *-stable* ]]; then |
| 63 | + BRANCH=main |
| 64 | + fi |
| 65 | + node ./scripts/e2e/init-project-e2e.js --projectName RNTestProject --currentBranch $BRANCH --directory /tmp/RNTestProject --pathToLocalReactNative $REACT_NATIVE_PKG |
| 66 | +
|
| 67 | + echo "Feed maven local to gradle.properties" |
| 68 | + cd /tmp/RNTestProject |
| 69 | + echo "react.internal.mavenLocalRepo=$MAVEN_LOCAL" >> android/gradle.properties |
| 70 | +
|
| 71 | + # Build |
| 72 | + cd android |
| 73 | + CAPITALIZED_FLAVOR=$(echo "${{ matrix.flavor }}" | awk '{print toupper(substr($0, 1, 1)) substr($0, 2)}') |
| 74 | + ./gradlew assemble$CAPITALIZED_FLAVOR --no-daemon -PreactNativeArchitectures=x86 |
| 75 | +
|
| 76 | + - name: Run E2E Tests |
| 77 | + id: run-tests |
| 78 | + continue-on-error: true |
| 79 | + uses: ./.github/actions/maestro-android |
| 80 | + timeout-minutes: 60 |
| 81 | + with: |
| 82 | + app-path: /tmp/RNTestProject/android/app/build/outputs/apk/${{ matrix.flavor }}/app-${{ matrix.flavor }}.apk |
| 83 | + app-id: com.rntestproject |
| 84 | + maestro-flow: ./scripts/e2e/.maestro/ |
| 85 | + install-java: 'false' |
| 86 | + flavor: ${{ matrix.flavor }} |
| 87 | + working-directory: /tmp/RNTestProject |
| 88 | + - name: Report status |
| 89 | + id: report-status |
| 90 | + if: ${{ always() && steps.run-tests.outcome == 'failure' }} |
| 91 | + run: echo "status=failure" >> $GITHUB_OUTPUT |
| 92 | + |
| 93 | + report: |
| 94 | + needs: test |
| 95 | + if: always() |
| 96 | + runs-on: ubuntu-latest |
| 97 | + outputs: |
| 98 | + status: ${{ steps.check.outputs.status }} |
| 99 | + steps: |
| 100 | + - id: check |
| 101 | + run: | |
| 102 | + if [[ "${{ needs.test.outputs.status }}" == "failure" ]]; then |
| 103 | + echo "status=failure" >> $GITHUB_OUTPUT |
| 104 | + else |
| 105 | + echo "status=success" >> $GITHUB_OUTPUT |
| 106 | + fi |
| 107 | + - name: Fail if needed |
| 108 | + if: ${{ inputs.fail-on-error && steps.check.outputs.status == 'failure' }} |
| 109 | + run: exit 1 |
0 commit comments