Repository navigation
191 lines (180 loc) · 9.66 KB
/
Copy pathandroid-realtime-e2e.yml
File metadata and controls
191 lines (180 loc) · 9.66 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Android Realtime E2E
# Deterministic realtime smoke on a GitHub emulator (scripts/qa/android_realtime_e2e.mjs): an Alpha APK
# (the realtime socket is the common Kotlin Socket.IO client) signs in with the QA account, receives a
# message posted through the API, survives airplane mode with catch-up of the messages posted meanwhile,
# and switches server and back; logcat must show the common client connecting
# (`realtime_kmp transport_connect_start` / `transport_connected`).
#
# APK: an Android Alpha Validation (android-alpha.yml) artifact. Dispatch with alpha_run_id (that run's
# android-alpha-* artifact), or label a pull request `realtime-e2e`: the newest successful
# android-alpha.yml run for the PR head is used (dispatch android-alpha.yml with ref=<head> first).
#
# scenario=draft-kill-timing (dispatch only) runs scripts/qa/android_draft_kill_timing.mjs instead on the same
# emulator, APK and QA sign-in: a composer draft must survive a force-stop shortly after the last keystroke,
# timed on the device's own monotonic clock (task #246). Its result table is results.md in the evidence.
on:
workflow_dispatch:
inputs:
alpha_run_id:
description: "android-alpha.yml run id whose android-alpha-* APK artifact to test"
required: true
type: string
scenario:
description: "realtime (default) or draft-kill-timing"
required: false
type: choice
options: [realtime, draft-kill-timing]
default: realtime
runs_per_bucket:
description: "draft-kill-timing: kill runs per delay bucket (0.05/0.1/0.3/0.7 s)"
required: false
type: string
default: "10"
require_commit:
description: "draft-kill-timing: a commit the APK's source must contain (checked through the GitHub compare API)"
required: false
type: string
default: ""
pull_request:
types: [labeled]
permissions:
contents: read
actions: read
concurrency:
group: android-realtime-e2e-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: false
jobs:
e2e:
if: github.event_name == 'workflow_dispatch' || github.event.label.name == 'realtime-e2e'
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.scenario == 'draft-kill-timing' && 150 || 60 }}
env:
EVIDENCE: ${{ inputs.scenario == 'draft-kill-timing' && 'draft-kill-timing-evidence' || 'realtime-e2e-evidence' }}
SCENARIO: ${{ inputs.scenario || 'realtime' }}
RUNS_PER_BUCKET: ${{ inputs.runs_per_bucket || '10' }}
steps:
- uses: actions/checkout@v7
- name: Find and download the Alpha APK
id: apk
env:
GH_TOKEN: ${{ github.token }}
RUN_ID_INPUT: ${{ inputs.alpha_run_id }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
HEAD_REF: ${{ github.event.pull_request.head.ref }}
REQUIRE_COMMIT: ${{ inputs.require_commit }}
run: |
set -euo pipefail
RUN_ID="${RUN_ID_INPUT:-}"
if [ -z "$RUN_ID" ]; then
RUN_ID="$(gh api "repos/${GITHUB_REPOSITORY}/actions/workflows/android-alpha.yml/runs?head_sha=${HEAD_SHA}&status=success&per_page=1" --jq '.workflow_runs[0].id // empty')"
if [ -z "$RUN_ID" ]; then
# An earlier head of this branch (e.g. only tests or CI changed since): use its newest Alpha, named
# in the summary so the tested commit is explicit.
RUN_ID="$(gh api "repos/${GITHUB_REPOSITORY}/actions/workflows/android-alpha.yml/runs?branch=${HEAD_REF}&status=success&per_page=1" --jq '.workflow_runs[0].id // empty')"
[ -n "$RUN_ID" ] && echo "::warning::no Alpha for ${HEAD_SHA}; testing run ${RUN_ID} of ${HEAD_REF}"
fi
[ -n "$RUN_ID" ] || { echo "::error::no successful android-alpha.yml run for ${HEAD_SHA}; dispatch it with ref=${HEAD_SHA} first"; exit 1; }
fi
NAME="$(gh api "repos/${GITHUB_REPOSITORY}/actions/runs/${RUN_ID}/artifacts" --jq '[.artifacts[] | select(.name | test("^android-alpha-[0-9]+-[0-9a-f]{40}$"))][0].name // empty')"
[ -n "$NAME" ] || { echo "::error::run ${RUN_ID} has no android-alpha-<n>-<sha> artifact"; exit 1; }
mkdir -p apk
gh run download "$RUN_ID" -R "$GITHUB_REPOSITORY" -n "$NAME" -D apk
APK="$(find apk -name '*.apk' | head -1)"
[ -s "$APK" ] || { echo "::error::no APK in ${NAME}"; exit 1; }
BT="$(ls -d "${ANDROID_HOME}"/build-tools/* | sort -V | tail -1)"
PKG="$("$BT/aapt" dump badging "$APK" | sed -n "s/^package: name='\([^']*\)'.*/\1/p")"
{
echo "run_id=$RUN_ID"; echo "artifact=$NAME"; echo "apk=$APK"; echo "package=$PKG"
echo "sha256=$(sha256sum "$APK" | cut -d' ' -f1)"
echo "source_sha=${NAME##*-}"
} | tee -a "$GITHUB_OUTPUT"
if [ -n "${REQUIRE_COMMIT:-}" ]; then
# identical / ahead: the APK's source commit contains REQUIRE_COMMIT.
STATUS="$(gh api "repos/${GITHUB_REPOSITORY}/compare/${REQUIRE_COMMIT}...${NAME##*-}" --jq .status 2>/dev/null || echo unavailable)"
echo "require_commit_status=$STATUS" | tee -a "$GITHUB_OUTPUT"
fi
# The QA account goes only to the steps that use it (the preflight probe and the emulator
# script), through their own env: from secrets.*, never through $GITHUB_ENV (that would hand
# it to every later step and process of the job). scripts/ci/check_workflow_secret_env.py.
- name: Preflight — QA account must not see the production server
env:
QA_TEST_EMAIL: ${{ secrets.QA_TEST_EMAIL }}
QA_TEST_PASSWORD: ${{ secrets.QA_TEST_PASSWORD }}
run: node scripts/qa/visible_servers_probe.mjs
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Run the scenario on the emulator
uses: reactivecircus/android-emulator-runner@v2
env:
QA_TEST_EMAIL: ${{ secrets.QA_TEST_EMAIL }}
QA_TEST_PASSWORD: ${{ secrets.QA_TEST_PASSWORD }}
APK_SHA256: ${{ steps.apk.outputs.sha256 }}
APK_SOURCE_SHA: ${{ steps.apk.outputs.source_sha }}
APK_ARTIFACT: ${{ steps.apk.outputs.artifact }}
REQUIRE_COMMIT: ${{ inputs.require_commit }}
REQUIRE_COMMIT_STATUS: ${{ steps.apk.outputs.require_commit_status }}
# Read-only (permissions: actions: read), this step only: the draft-kill scenario checks that an
# earlier run has completed before archiving the channel it left behind.
GH_RUN_STATUS_TOKEN: ${{ github.token }}
with:
api-level: 34
arch: x86_64
target: google_apis
profile: pixel_6
ram-size: 4096M
cores: 2
disk-size: 6000M
emulator-boot-timeout: 1200
emulator-options: -no-snapshot -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-metrics
disable-animations: true
# The action runs each script line in its own shell: keep this one line.
script: if [ "$SCENARIO" = draft-kill-timing ]; then node scripts/qa/android_draft_kill_timing.mjs --apk "${{ steps.apk.outputs.apk }}" --package "${{ steps.apk.outputs.package }}" --out "${{ env.EVIDENCE }}" --runs-per-bucket "$RUNS_PER_BUCKET"; else node scripts/qa/android_realtime_e2e.mjs --apk "${{ steps.apk.outputs.apk }}" --package "${{ steps.apk.outputs.package }}" --out "${{ env.EVIDENCE }}"; fi
- name: Summary
if: always()
run: |
{
echo "## Android ${SCENARIO} (emulator)"
echo "| | |"; echo "|---|---|"
echo "| APK | \`${{ steps.apk.outputs.artifact }}\` (run ${{ steps.apk.outputs.run_id }}) |"
echo "| SHA-256 | \`${{ steps.apk.outputs.sha256 }}\` |"
echo "| Emulator | API 34 google_apis x86_64, pixel_6 |"
if [ -f "${EVIDENCE}/results.md" ]; then
echo; cat "${EVIDENCE}/results.md"
elif [ -f "${EVIDENCE}/summary.json" ]; then
echo; echo '```json'; cat "${EVIDENCE}/summary.json"; echo '```'
fi
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload evidence
if: always() && env.SCENARIO != 'draft-kill-timing'
uses: actions/upload-artifact@v7
with:
name: android-realtime-e2e-evidence
# An allow-list, never the whole directory: whatever else a crashed run left there stays on the runner.
path: |
${{ env.EVIDENCE }}/summary.json
${{ env.EVIDENCE }}/steps.jsonl
${{ env.EVIDENCE }}/realtime-lines.txt
${{ env.EVIDENCE }}/logcat.txt
${{ env.EVIDENCE }}/*.png
${{ env.EVIDENCE }}/*.xml
if-no-files-found: warn
retention-days: 30
# draft-kill-timing: only the filtered timing lines, never a logcat. The raw capture lives outside the
# evidence directory (os.tmpdir) and the filtered file is renamed into place only when complete, so a
# run that dies at any point uploads nothing but these files.
- name: Upload draft-kill evidence
if: always() && env.SCENARIO == 'draft-kill-timing'
uses: actions/upload-artifact@v7
with:
name: android-draft-kill-timing-evidence
path: |
${{ env.EVIDENCE }}/summary.json
${{ env.EVIDENCE }}/results.md
${{ env.EVIDENCE }}/runs.jsonl
${{ env.EVIDENCE }}/timing-lines.txt
${{ env.EVIDENCE }}/*.png
if-no-files-found: warn
retention-days: 30