-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (93 loc) · 3.82 KB
/
Copy pathe2e-android.yml
File metadata and controls
106 lines (93 loc) · 3.82 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
# Patrol E2E on Android — manual only (does not block PRs).
# Requires a reachable API if the auth flow calls the network; see integration_test/app_e2e_test.dart.
name: E2E Android (Patrol)
on:
workflow_dispatch:
inputs:
api_level:
description: 'Android API level'
required: true
default: '34'
emulator_profile:
description: 'AVD profile name'
required: true
default: 'pixel_6'
concurrency:
group: e2e-android-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
patrol:
name: Patrol on Android emulator
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Install dependencies
run: flutter pub get
- name: Add Pub global bin to PATH
run: echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
# The CLI version MUST match the `patrol` dependency pinned in
# pubspec.yaml (^3.10.0 -> 3.20.0). Activating unpinned resolves the newest
# CLI (4.7.0), which aborts with "Patrol version 3.20.0 ... is not
# compatible with patrol_cli version 4.7.0" before any test runs.
# If you bump `patrol`, bump this together with it, using
# https://patrol.leancode.co/documentation/compatibility-table
- name: Install Patrol CLI
run: dart pub global activate patrol_cli 3.11.0
- name: Run Patrol tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ inputs.api_level }}
arch: x86_64
profile: ${{ inputs.emulator_profile }}
# `bash -o pipefail` is load-bearing. The emulator-runner executes this
# via /usr/bin/sh, so a bare `patrol test ... | tee` returns tee's exit
# status and a FAILING test set reports as a green job. Verified: a run
# with "Failed: 1" concluded success until this was added.
script: bash -o pipefail -c 'patrol test --target integration_test/app_e2e_test.dart 2>&1 | tee patrol-output.log'
# `patrol test` exits 0 on an EMPTY test set. Before the native androidTest
# source set existed, this job went green reporting "Total: 0" - a tick that
# verified nothing, which is worse than a red. Never let that recur.
- name: Reject an empty test run
if: always()
run: |
if [ ! -f patrol-output.log ]; then
echo "::error::patrol-output.log missing - the test step never produced output."
exit 1
fi
total="$(grep -oE 'Total: *[0-9]+' patrol-output.log | tail -1 | grep -oE '[0-9]+' || true)"
echo "Patrol reported test count: ${total:-<none>}"
if [ -z "$total" ]; then
echo "::error::No 'Total:' summary in patrol output; cannot confirm any test ran."
exit 1
fi
if [ "$total" -eq 0 ]; then
echo "::error::Patrol collected 0 tests. A green run here would be a false pass."
exit 1
fi
failed="$(grep -oE 'Failed: *[0-9]+' patrol-output.log | tail -1 | grep -oE '[0-9]+' || echo 0)"
if [ "$failed" -ne 0 ]; then
echo "::error::$failed of $total Patrol test(s) failed. See the patrol-output artifact."
exit 1
fi
echo "OK: $total test(s) collected and executed, 0 failed."
- name: Upload Patrol output
if: always()
uses: actions/upload-artifact@v4
with:
name: patrol-output
path: patrol-output.log
if-no-files-found: warn