From 5b93ec23a2f2a61ca81f110f6e291b9ebe52074b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 17 Nov 2026 22:00:19 +0100 Subject: [PATCH 1/3] ci(android): overlap the smoke job CLI build with the fixture restore The job built the CLI as the first command of the emulator script, so a booted emulator waited for a build that needs no device. Build the CLI as a step instead, in one parallel group with the fixture restore: the two share no outputs, write disjoint paths, and the restore is the slower one, so the build leaves the critical path. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/android.yml | 29 ++++++++++++++++------- test/ci/trusted-fixture-artifact.test.mjs | 18 ++++++++------ 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 01e594915e..5e66336da4 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -56,14 +56,26 @@ jobs: with: package-helpers: 'true' - - name: Restore fixture APK - if: steps.impact.outputs.run != 'false' - id: fixture-app - uses: ./.github/actions/setup-fixture-app - with: - platform: android - install: 'false' - wait-for-artifact-seconds: '1800' + # The build and the fixture restore prepare the same emulator session and share no outputs: + # the build writes dist/, the repack writes .tmp/fixture-app through + # examples/test-app/node_modules. The build was previously the first command of the emulator + # script, so it held the booted emulator before the first case ran. The restore is the slower + # of the two, so the build costs the job nothing on the critical path. + - parallel: + - name: Build the shared CLI + if: steps.impact.outputs.run != 'false' + uses: ./.github/actions/run-gate + with: + gate: build + + - name: Restore fixture APK + if: steps.impact.outputs.run != 'false' + id: fixture-app + uses: ./.github/actions/setup-fixture-app + with: + platform: android + install: 'false' + wait-for-artifact-seconds: '1800' - name: Report fixture cache source if: steps.impact.outputs.run != 'false' @@ -90,7 +102,6 @@ jobs: set -eu ANDROID_SERIAL="$(adb devices | awk 'NR > 1 && $2 == "device" { print $1; exit }')" test -n "$ANDROID_SERIAL" - pnpm gate build pnpm clean:daemon AGENT_DEVICE_ANDROID_E2E=1 AGENT_DEVICE_ANDROID_E2E_TIER=smoke AGENT_DEVICE_ANDROID_SERIAL="$ANDROID_SERIAL" AGENT_DEVICE_FIXTURE_APP_PATH="${{ steps.fixture-app.outputs.apk-path }}" AGENT_DEVICE_FIXTURE_APP_ID="${{ steps.fixture-app.outputs.app-id }}" node --experimental-strip-types scripts/node-test-tmpdir.ts --test test/integration/smoke-android-emulator.test.ts node --experimental-strip-types src/bin.ts test test/integration/replays/android/emulator/01-settings.ad --retries 2 --report-junit test/artifacts/replays-android-smoke.junit.xml diff --git a/test/ci/trusted-fixture-artifact.test.mjs b/test/ci/trusted-fixture-artifact.test.mjs index 3d2830bd73..f961c05545 100644 --- a/test/ci/trusted-fixture-artifact.test.mjs +++ b/test/ci/trusted-fixture-artifact.test.mjs @@ -12,6 +12,13 @@ import { import { assertAndroidFixtureSnapshot } from '../scripts/assert-android-fixture-snapshot.mjs'; const repository = { default_branch: 'main', id: 42 }; + +/** A job's steps with each `parallel:` group opened into the steps it runs. */ +function jobSteps(job) { + return (job?.steps ?? []).flatMap((step) => + step.parallel ? jobSteps({ steps: step.parallel }) : [step], + ); +} const trustedRun = { event: 'pull_request', head_branch: 'feature', @@ -145,14 +152,11 @@ test('Android smoke consumes the restored APK through catalog fixture E2E', (t) assert.equal(replayEvidence.workflow, '.github/workflows/android.yml'); const evidenceJob = workflow.jobs[replayEvidence.job]; assert.ok(evidenceJob, `missing declared Android replay job: ${replayEvidence.job}`); - const smokeStep = evidenceJob.steps.find((step) => step.name === replayEvidence.step); + const smokeStep = jobSteps(evidenceJob).find((step) => step.name === replayEvidence.step); assert.ok(smokeStep, `missing declared Android replay step: ${replayEvidence.step}`); - const restoreStep = workflow.jobs['smoke-android'].steps.find( - (step) => step.name === 'Restore fixture APK', - ); - const sourceStep = workflow.jobs['smoke-android'].steps.find( - (step) => step.name === 'Report fixture cache source', - ); + const smokeJobSteps = jobSteps(workflow.jobs['smoke-android']); + const restoreStep = smokeJobSteps.find((step) => step.name === 'Restore fixture APK'); + const sourceStep = smokeJobSteps.find((step) => step.name === 'Report fixture cache source'); const assertion = fs.readFileSync('test/scripts/assert-android-fixture-snapshot.mjs', 'utf8'); const packageVersion = JSON.parse(fs.readFileSync('package.json', 'utf8')).version; From 163dc3e0eebe903d0bf8d3d461e9925d344b98b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 17 Nov 2026 22:18:30 +0100 Subject: [PATCH 2/3] test(ci): read parallel step groups in the Android lane guard device-lane-impact.test.ts walked a job's flat step list, so a step inside a parallel group read as no step and its gate went unchecked. Flatten the groups before the walk. Co-Authored-By: Claude Opus 5.5 --- scripts/__tests__/device-lane-impact.test.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/__tests__/device-lane-impact.test.ts b/scripts/__tests__/device-lane-impact.test.ts index f9d9d0144a..a847bfd99b 100644 --- a/scripts/__tests__/device-lane-impact.test.ts +++ b/scripts/__tests__/device-lane-impact.test.ts @@ -9,7 +9,13 @@ import { selectDeviceLane } from '../device-lane-impact.ts'; const repoRoot = path.resolve(import.meta.dirname, '../..'); -type Step = { id?: string; name?: string; if?: string; run?: string }; +type Step = { id?: string; name?: string; if?: string; run?: string; parallel?: Step[] }; + +// A parallel group carries steps instead of being one, so each member keeps the gate of the step +// the group replaced. +function flattenSteps(steps: Step[]): Step[] { + return steps.flatMap((step) => (step.parallel ? flattenSteps(step.parallel) : [step])); +} function jobSteps(workflow: string, job: string): Step[] { const doc = parse( @@ -17,7 +23,7 @@ function jobSteps(workflow: string, job: string): Step[] { ) as { jobs: Record; }; - return doc.jobs[job]!.steps; + return flattenSteps(doc.jobs[job]!.steps); } const LANES = { From c3568f5fe3808def8ac93f8d20adaf8683d66611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 17 Nov 2026 23:02:43 +0100 Subject: [PATCH 3/3] refactor(ci): share one parallel-group step reader Export runnableSteps from scripts/gate/workflows.ts, which already opened parallel groups for the gate manifest, and read workflow steps through it in the Android lane guards. Keep the step type generic so the gate module owns no test-only field. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/android.yml | 7 ++----- scripts/__tests__/device-lane-impact.test.ts | 9 ++------- scripts/gate/workflows.ts | 4 ++-- test/ci/trusted-fixture-artifact.test.mjs | 14 +++++--------- 4 files changed, 11 insertions(+), 23 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 5e66336da4..992f8f1089 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -56,11 +56,8 @@ jobs: with: package-helpers: 'true' - # The build and the fixture restore prepare the same emulator session and share no outputs: - # the build writes dist/, the repack writes .tmp/fixture-app through - # examples/test-app/node_modules. The build was previously the first command of the emulator - # script, so it held the booted emulator before the first case ran. The restore is the slower - # of the two, so the build costs the job nothing on the critical path. + # The build writes dist/. The repack writes .tmp/fixture-app through + # examples/test-app/node_modules. Neither reads the other's output, so they run together. - parallel: - name: Build the shared CLI if: steps.impact.outputs.run != 'false' diff --git a/scripts/__tests__/device-lane-impact.test.ts b/scripts/__tests__/device-lane-impact.test.ts index a847bfd99b..1113f9cb65 100644 --- a/scripts/__tests__/device-lane-impact.test.ts +++ b/scripts/__tests__/device-lane-impact.test.ts @@ -6,24 +6,19 @@ import { expect, test } from 'vitest'; import { parse } from 'yaml'; import type { CheckId } from '../check-affected/model.ts'; import { selectDeviceLane } from '../device-lane-impact.ts'; +import { runnableSteps } from '../gate/workflows.ts'; const repoRoot = path.resolve(import.meta.dirname, '../..'); type Step = { id?: string; name?: string; if?: string; run?: string; parallel?: Step[] }; -// A parallel group carries steps instead of being one, so each member keeps the gate of the step -// the group replaced. -function flattenSteps(steps: Step[]): Step[] { - return steps.flatMap((step) => (step.parallel ? flattenSteps(step.parallel) : [step])); -} - function jobSteps(workflow: string, job: string): Step[] { const doc = parse( fs.readFileSync(path.join(repoRoot, '.github/workflows', workflow), 'utf8'), ) as { jobs: Record; }; - return flattenSteps(doc.jobs[job]!.steps); + return runnableSteps(doc.jobs[job]!.steps); } const LANES = { diff --git a/scripts/gate/workflows.ts b/scripts/gate/workflows.ts index 5bafa455d2..fdceeb88cf 100644 --- a/scripts/gate/workflows.ts +++ b/scripts/gate/workflows.ts @@ -179,8 +179,8 @@ function readLocalWorkflowJobs(uses: string, root: string): Job[] | null { return jobs.length > 0 ? jobs : null; } -/** A job's steps with each `parallel:` group opened into the steps it runs. */ -function runnableSteps(steps: readonly RawStep[]): RawStep[] { +/** Steps a job runs, with each `parallel:` group opened into the steps it runs. */ +export function runnableSteps(steps: readonly S[]): S[] { return steps.flatMap((step) => (step.parallel ? runnableSteps(step.parallel) : [step])); } diff --git a/test/ci/trusted-fixture-artifact.test.mjs b/test/ci/trusted-fixture-artifact.test.mjs index f961c05545..c553039a19 100644 --- a/test/ci/trusted-fixture-artifact.test.mjs +++ b/test/ci/trusted-fixture-artifact.test.mjs @@ -10,15 +10,9 @@ import { findTrustedArtifact, } from '../../.github/actions/setup-fixture-app/trusted-artifact.mjs'; import { assertAndroidFixtureSnapshot } from '../scripts/assert-android-fixture-snapshot.mjs'; +import { runnableSteps } from '../../scripts/gate/workflows.ts'; const repository = { default_branch: 'main', id: 42 }; - -/** A job's steps with each `parallel:` group opened into the steps it runs. */ -function jobSteps(job) { - return (job?.steps ?? []).flatMap((step) => - step.parallel ? jobSteps({ steps: step.parallel }) : [step], - ); -} const trustedRun = { event: 'pull_request', head_branch: 'feature', @@ -152,9 +146,11 @@ test('Android smoke consumes the restored APK through catalog fixture E2E', (t) assert.equal(replayEvidence.workflow, '.github/workflows/android.yml'); const evidenceJob = workflow.jobs[replayEvidence.job]; assert.ok(evidenceJob, `missing declared Android replay job: ${replayEvidence.job}`); - const smokeStep = jobSteps(evidenceJob).find((step) => step.name === replayEvidence.step); + const smokeStep = runnableSteps(evidenceJob.steps).find( + (step) => step.name === replayEvidence.step, + ); assert.ok(smokeStep, `missing declared Android replay step: ${replayEvidence.step}`); - const smokeJobSteps = jobSteps(workflow.jobs['smoke-android']); + const smokeJobSteps = runnableSteps(workflow.jobs['smoke-android'].steps); const restoreStep = smokeJobSteps.find((step) => step.name === 'Restore fixture APK'); const sourceStep = smokeJobSteps.find((step) => step.name === 'Report fixture cache source'); const assertion = fs.readFileSync('test/scripts/assert-android-fixture-snapshot.mjs', 'utf8');