ci: skip superseded runs, move fuzz to nightly, trim the android PR trigger
All checks were successful
ci / test (pull_request) Successful in 6m33s
ci / sdk (pull_request) Successful in 1m27s
android-ci / android (pull_request) Successful in 12m47s

Three sources of wasted Pi time, measured over a two-week window
(353 workflow runs, 694 job runs): ~78% of CI wall-clock was spent on
work that did not need to happen.

1. Nothing was ever cancelled. Every `concurrency:` block in the repo
   had `cancel-in-progress: false`, and 279 of 353 runs sat in the
   queue behind a newer commit on the same branch. The comment
   justifying it ("shared the container name `onionwire-ci`") was
   stale — the name has been per-run-id for a while — but the real
   constraint is the shared cargo target volume, which two concurrent
   writers corrupt (`Permission denied (os error 13)` on
   /target/debug/deps). So the flag stays false and superseded runs
   instead stand down at a new gate: compare GITHUB_SHA against the
   remote branch tip and skip. Seconds, not minutes, and it cannot
   release the concurrency group into a volume race. Added to
   ci.yml (test, sdk) and android-ci.yml (android).

   Verified against the run history: Forgejo's pull_request GITHUB_SHA
   is the branch head, never a synthetic merge commit (245/245 recorded
   PR runs match a refs/pull/*/head tip), so the gate cannot skip a
   live run. It fails open — an unresolvable ref runs the job. 232 of
   477 historical PR runs would have been skipped.

2. `fuzz` ran on almost every push. A job cannot narrow a
   workflow-level path filter, so `fuzz/**` sat in ci.yml's list
   beside `src/**` and `crates/**`: 80 of 84 recorded runs touched
   nothing in fuzz/, each paying a nightly toolchain install and
   `cargo install cargo-fuzz` for 15 seconds of actual fuzzing. Moved
   to its own workflow, schedule-only (03:30 UTC, off the arti-watch
   slot) plus workflow_dispatch. The build/run single-container fix
   and the PATH export from #106/#107 come along unchanged.

3. android-ci built a full APK for commits that touched no android/
   file — 95 of 143 runs, at ~11 minutes each. The PR trigger now
   covers android/**, crates/onionwire-sdk/**, Cargo.toml, Cargo.lock
   and the build script. The push-to-main trigger keeps src/** and
   crates/**, so every merge still runs the in-APK checks that earn
   their keep (the target_max_memory marker gate, the .so listing, the
   sha256 round-trip) — a Rust-only PR now finds out at merge instead
   of before it, and nothing reaches a release untested.

Also drops `fetch-depth: 0` from android-ci: nothing in the build
reads git history (PUBLISH_TAG comes from the environment).

ci.yml's `push: [main]` trigger is unchanged. It re-tests trees a PR
already tested identically (73 job runs in the window), but branch
protection is empty, so it is not a merge gate — it is the "CI green
on main" signal docs/RELEASING.md's readiness gate reads, and a merge
commit has a different sha so statuses do not carry over. The
staleness gate already removes most of its cost.

docs/RELEASING.md describes all of the above; its android-ci path
list and its fuzz-job account were both wrong after this change.
This commit is contained in:
agent 2026-09-27 15:34:58 -04:00
commit 404ceea0f8
No known key found for this signature in database
4 changed files with 240 additions and 82 deletions

View file

@ -18,6 +18,22 @@ name: android-ci
# detection, and a gate that mis-detects hands out a green check for a suite
# that never ran. Here the runner's own paths filter decides — same mechanism
# ci.yml already uses.
#
# The two triggers differ on purpose, and the asymmetry is the whole point of
# the `src/**` entry below:
#
# pull_request — the client and the SDK binding surface. NOT `src/**`. A
# Rust-only PR does change the bytes in `libonionwire_sdk.so`, but proving
# that costs a ~11 minute full APK build, and 95 of 143 recorded runs
# touched no `android/` file at all. The in-APK checks that actually earn
# their keep (the `target_max_memory` marker gate, the `.so` listing, the
# sha256 round-trip) still run on every merge via the push trigger, so
# nothing reaches a release untested — a Rust PR just finds out at merge
# instead of before it. If a Rust change ever breaks the Android build
# specifically, add its path here rather than re-adding all of `src/**`.
#
# push: [main] — every Rust or Android change, every merge. This is the
# safety net, and it is why the trigger cannot simply mirror the PR one.
on:
push:
branches: [main]
@ -32,8 +48,7 @@ on:
pull_request:
paths:
- "android/**"
- "crates/**"
- "src/**"
- "crates/onionwire-sdk/**"
- "Cargo.toml"
- "Cargo.lock"
- "scripts/build-android-local.sh"
@ -80,10 +95,30 @@ jobs:
steps:
- name: Checkout
uses: https://code.forgejo.org/actions/checkout@v4
with:
fetch-depth: 0
- name: Skip superseded run
id: staleness
run: |
set -uo pipefail
# Same gate as ci.yml: a newer commit on this branch while this run
# sat in the shared android concurrency queue makes the ~11 minute
# APK build a proof of nothing. `origin` is anonymously readable
# here, and a failed lookup runs the job rather than skipping it.
ref="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME:-}}"
remote=""
if [ -n "$ref" ]; then
remote="$(git ls-remote origin "refs/heads/$ref" 2>/dev/null | cut -f1)"
fi
if [ -n "$remote" ] && [ "$remote" != "$GITHUB_SHA" ]; then
echo "::notice::superseded: refs/heads/$ref is at ${remote:0:12}, this run is ${GITHUB_SHA:0:12} — skipping"
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "tip=${remote:-unknown} sha=${GITHUB_SHA} ref=${ref:-none} — running"
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Record runner resources
if: steps.staleness.outputs.skip != 'true'
run: |
set -euo pipefail
cd "${GITHUB_WORKSPACE}"
@ -94,6 +129,7 @@ jobs:
ls -l /var/run/docker.sock || true
- name: Ensure docker CLI
if: steps.staleness.outputs.skip != 'true'
run: |
set -euo pipefail
if ! command -v docker >/dev/null 2>&1; then
@ -109,6 +145,7 @@ jobs:
- name: Build APK + AAR (debug-signed) in bookworm container
id: build
if: steps.staleness.outputs.skip != 'true'
run: |
set -euo pipefail
cd "${GITHUB_WORKSPACE}"
@ -286,6 +323,7 @@ jobs:
ls -l dist/
- name: Verify artifacts
if: steps.staleness.outputs.skip != 'true'
run: |
set -euo pipefail
cd "${GITHUB_WORKSPACE}"