diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 01e594915e..992f8f1089 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -56,14 +56,23 @@ 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 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' + 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 +99,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/scripts/__tests__/device-lane-impact.test.ts b/scripts/__tests__/device-lane-impact.test.ts index f9d9d0144a..1113f9cb65 100644 --- a/scripts/__tests__/device-lane-impact.test.ts +++ b/scripts/__tests__/device-lane-impact.test.ts @@ -6,10 +6,11 @@ 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 }; +type Step = { id?: string; name?: string; if?: string; run?: string; parallel?: Step[] }; function jobSteps(workflow: string, job: string): Step[] { const doc = parse( @@ -17,7 +18,7 @@ function jobSteps(workflow: string, job: string): Step[] { ) as { jobs: Record; }; - return 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 3d2830bd73..c553039a19 100644 --- a/test/ci/trusted-fixture-artifact.test.mjs +++ b/test/ci/trusted-fixture-artifact.test.mjs @@ -10,6 +10,7 @@ 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 }; const trustedRun = { @@ -145,14 +146,13 @@ 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); - 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 smokeStep = runnableSteps(evidenceJob.steps).find( + (step) => step.name === replayEvidence.step, ); + assert.ok(smokeStep, `missing declared Android replay step: ${replayEvidence.step}`); + 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'); const packageVersion = JSON.parse(fs.readFileSync('package.json', 'utf8')).version;