Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/pm-console-android-offline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: pm-console-android offline

# CI tier policy: see .github/ci-policy.md. This is CI, not a release,
# so it runs on the nightly schedule and by hand, never on push.
#
# Checks the PM console Android app with no connection on a device in
# CI (#13500): it builds the app against the demo edge on the runner,
# starts an emulator, installs the APK, and drives it — open, aeroplane
# mode, open again from the icon, answer a question, swipe the app
# away, network back — then checks the demo edge saw that answer
# exactly once. What Android does differently from desktop Chrome is
# in pm-stack/console/README.md under "With no connection".
on:
schedule:
- cron: "17 7 * * *"
workflow_dispatch:

permissions:
contents: read

# One run at a time, in order; a newer run never cancels one that is
# driving the emulator.
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false

jobs:
offline-check:
name: "check the app with no connection on a device"
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
- name: Build the APK against the demo edge
# The emulator reaches this machine as 10.0.2.2. The site is
# plain http there, so the app opens as a Custom Tab rather
# than a verified Trusted Web Activity; the web content under
# test is the same.
env:
PM_CONSOLE_SITE: http://10.0.2.2:4897
run: bash pm-stack/console/android/build.sh
- name: Start the demo edge
env:
PM_CONSOLE_DEMO_ACT_LOG: ${{ github.workspace }}/pm-console-acts.jsonl
run: |
: >pm-console-acts.jsonl
nohup bun run pm-stack/console/scripts/edge-demo.ts 4897 >edge-demo.log 2>&1 &
echo $! >edge-demo.pid
disown
for attempt in $(seq 1 30); do
if curl -fsS --max-time 5 "http://127.0.0.1:4897/console/health" >/dev/null 2>&1; then
echo "demo edge answers at http://127.0.0.1:4897/console/health"
exit 0
fi
sleep 2
done
echo "the demo edge did not answer its health check" >&2
cat edge-demo.log >&2
exit 1
- name: Check the app with no connection
uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2
with:
api-level: 34
target: google_apis
arch: x86_64
profile: pixel_7
disable-animations: true
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim
script: bash pm-stack/console/android/offline-check.sh --apk pm-stack/console/android/app/build/outputs/apk/release/app-release.apk --edge-url http://127.0.0.1:4897 --act-log pm-console-acts.jsonl
- name: Keep the act log and the edge log
if: always()
uses: actions/upload-artifact@v7
with:
name: pm-console-android-offline-logs
path: |
pm-console-acts.jsonl
edge-demo.log
if-no-files-found: warn
23 changes: 22 additions & 1 deletion pm-stack/console/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,23 @@ the Android app alike (which is the same site in Chrome).
being done is told so, and asks again. And a name keeps to the side
that first took it, Cloudflare or a machine, whichever would be
chosen for it later.

On Android the app is the same site in Chrome, so the same worker and
the same outbox run there — the difference is only the page's life.
Swiping the app away closes the page, not the worker: the sync stays
registered, and Chrome wakes the worker when the network is back, so
an answer made offline is still sent with the app closed. There is no
deadline in the app: the sync stays registered until it runs, or the
browser says it is its last call for it, and then opening the app
sends what waits. The one thing the page owns is the few seconds an
answer waits before it is written down (the undo pause): if the app
is closed in that pause, the page tries to write it as it hides, and
if that write does not reach the outbox the answer is lost and the
question stays open. The `pm-console-android-offline` workflow
checks this every night and on demand: an emulator, the app against
the demo edge, aeroplane mode, an answer made offline, the app
swiped away, and the answer arriving exactly once when the network
is back.
- **"Sent" means recorded.** An answer the platform took and did not
record (a question that was settled in the meantime) is not counted
as sent: it is listed under "could not be done", with why. A question
Expand Down Expand Up @@ -417,4 +434,8 @@ offered. See its README.
Because it is the site, it opens with no connection and keeps what is
done there exactly as the site does (above, "With no connection"): text
dictated or shared into it with no signal lands in Ask, is kept when
sent, and goes when the phone is connected again.
sent, and goes when the phone is connected again. The Android half of
that is checked on a device in CI, not only in a desktop browser: the
`pm-console-android-offline` workflow starts an emulator, installs the
built APK, and drives it against the demo edge with the network off
and on again.
9 changes: 7 additions & 2 deletions pm-stack/console/android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,10 @@ The page says which it is. Later builds install over it.

The native parts are checked by compiling the build and reading its
merged manifest; the site's side of each (the Ask box taking handed-over
words, linking a phone, the summary) is tested in `test/`. They have not
been exercised by an automated run on a device.
words, linking a phone, the summary) is tested in `test/`. The app
with no connection is checked on a device in CI: the
`pm-console-android-offline` workflow (nightly, and on demand) starts
an emulator, installs the built APK, and drives it against the demo
edge — open, aeroplane mode, open again from the icon, answer a
question, swipe the app away, network back — and checks the demo edge
saw that answer exactly once. See `offline-check.sh` for the steps.
12 changes: 10 additions & 2 deletions pm-stack/console/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ plugins {
id 'com.android.application'
}

def site = 'https://pm.security.cab'
def site = findProperty('pmConsoleSite') ?: 'https://pm.security.cab'
def siteHost = new URI(site).host
def keystore = System.getenv('PM_ANDROID_KEYSTORE')
// A release names its own version (build.sh works both out from the
// commit, so a later build always installs over an earlier one). A
Expand All @@ -28,7 +29,14 @@ android {
targetSdk 34
versionCode releaseCode ? releaseCode.toInteger() : 3
versionName releaseName ?: '0.3.0'
manifestPlaceholders = [hostName: 'pm.security.cab', defaultUrl: "${site}/console/"]
// The site the app opens. The offline check builds it against
// the demo edge on the runner instead
// (-PpmConsoleSite=http://10.0.2.2:4897, via PM_CONSOLE_SITE in
// build.sh); anything else keeps the real site, and the release
// build is unchanged. A demo site is plain http, so the app
// opens there as a Custom Tab rather than a verified Trusted
// Web Activity; the web content under test is the same.
manifestPlaceholders = [hostName: siteHost, defaultUrl: "${site}/console/"]
// The app's half of the link to the site. The site's half is
// /.well-known/assetlinks.json, served by pm-console.
resValue 'string', 'console_url', "${site}/console/"
Expand Down
10 changes: 8 additions & 2 deletions pm-stack/console/android/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
# Inputs (environment):
# KEYSTORE_B64 base64 of the PKCS#12 signing keystore (key alias pmconsole)
# PM_ANDROID_KEYSTORE_PASSWORD its password
# GRADLE_VERSION Gradle to fetch (default 8.9; AGP 8.5 needs 8.7 or later)
# PM_CONSOLE_SITE site the app opens (default https://pm.security.cab);
# the offline check sets it to the demo edge
# on the runner, http://10.0.2.2:4897
# Needs: a JDK 17 or 21, an Android SDK at ANDROID_HOME, curl, unzip.
#
# With both keystore variables set the result is app/build/outputs/apk/release/pm-console.apk,
Expand Down Expand Up @@ -58,7 +60,11 @@ if [ -n "${KEYSTORE_B64:-}" ] && [ -n "${PM_ANDROID_KEYSTORE_PASSWORD:-}" ]; the
export PM_ANDROID_KEYSTORE="$keystore"
fi

"$GRADLE" --no-daemon --console=plain assembleRelease
GRADLE_ARGS=(--no-daemon --console=plain assembleRelease)
if [ -n "${PM_CONSOLE_SITE:-}" ]; then
GRADLE_ARGS+=("-PpmConsoleSite=$PM_CONSOLE_SITE")
fi
"$GRADLE" "${GRADLE_ARGS[@]}"
printf '%s\n%s\n' "${PM_ANDROID_VERSION_NAME:-0.3.0}" "${PM_ANDROID_VERSION_CODE:-3}" >"$OUT/version"
echo "build.sh: version ${PM_ANDROID_VERSION_NAME:-0.3.0} (code ${PM_ANDROID_VERSION_CODE:-3})"

Expand Down
Loading