Repository navigation
147 lines (142 loc) · 5.21 KB
/
Copy pathe2e-android-templateapp.yml
File metadata and controls
147 lines (142 loc) · 5.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: E2E Android Template App
permissions:
contents: read
actions: read
on:
workflow_call:
inputs:
fail-on-error:
type: boolean
default: false
retry-attempt:
type: number
default: 0
outputs:
status:
description: 'The result of the E2E tests (success or failure)'
value: ${{ jobs.report.outputs.status }}
jobs:
test:
runs-on: 4-core-ubuntu
outputs:
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]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup node.js
uses: ./.github/actions/setup-node
- name: Run yarn
uses: ./.github/actions/yarn-install
# Debug APKs load JavaScript from Metro, so only that lane needs a
# generated project workspace.
- name: Download React Native Package
if: matrix.flavor == 'debug'
uses: ./.github/actions/download-artifact
with:
name: react-native-package
path: /tmp/react-native-tmp
- name: Prepare Metro workspace
if: matrix.flavor == 'debug'
run: |
REACT_NATIVE_PKG=$(find /tmp/react-native-tmp -type f -name "*.tgz")
# 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"
- name: Download template app APK
uses: ./.github/actions/download-artifact
with:
name: android-templateapp-${{ matrix.flavor }}
path: /tmp/android-templateapp
- name: Download previous per-flow test state
if: ${{ inputs.retry-attempt > 0 }}
continue-on-error: true
uses: ./.github/actions/download-artifact
with:
name: e2e_android_templateapp_state_${{ matrix.flavor }}_arm64-v8a_NewArch
path: /tmp/maestro-android-state
- name: Check for unfinished E2E flows
id: test-state
shell: bash
run: |
SHOULD_RUN=true
if [[ -f /tmp/maestro-android-state/results.json ]] && \
jq -e '(.flows | length > 0) and all(.flows[]; .status == "passed")' /tmp/maestro-android-state/results.json > /dev/null; then
SHOULD_RUN=false
fi
echo "should-run=$SHOULD_RUN" >> "$GITHUB_OUTPUT"
- name: Run E2E Tests
id: run-tests
if: steps.test-state.outputs.should-run == 'true'
continue-on-error: true
uses: ./.github/actions/maestro-android
timeout-minutes: 90
with:
app-path: /tmp/android-templateapp/app-${{ matrix.flavor }}.apk
app-id: com.rntestproject
maestro-flow: ./scripts/e2e/.maestro/
flavor: ${{ matrix.flavor }}
working-directory: ${{ matrix.flavor == 'debug' && '/tmp/RNTestProject' || '.' }}
emulator-api-level: '35'
emulator-target: google_apis
emulator-arch: x86_64
- name: Store per-flow test state
if: always()
uses: ./.github/actions/upload-artifact
with:
name: e2e_android_templateapp_state_${{ matrix.flavor }}_arm64-v8a_NewArch
overwrite: true
if-no-files-found: warn
path: /tmp/maestro-android-state/results.json
- 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)});
report:
needs: test
if: always()
runs-on: ubuntu-latest
outputs:
status: ${{ steps.check.outputs.status }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Report failed jobs
id: check
uses: actions/github-script@v8
env:
JOB_RESULTS: ${{ toJSON(needs) }}
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),
failOnError: process.env.FAIL_ON_ERROR === 'true',
attempt: Number(process.env.GITHUB_RUN_ATTEMPT)});