Skip to content
Merged
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
26 changes: 17 additions & 9 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions scripts/__tests__/device-lane-impact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +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 };
type Step = { id?: string; name?: string; if?: string; run?: string; parallel?: Step[] };

function jobSteps(workflow: string, job: string): Step[] {
const doc = parse(
fs.readFileSync(path.join(repoRoot, '.github/workflows', workflow), 'utf8'),
) as {
jobs: Record<string, { steps: Step[] }>;
};
return doc.jobs[job]!.steps;
return runnableSteps(doc.jobs[job]!.steps);
}

const LANES = {
Expand Down
4 changes: 2 additions & 2 deletions scripts/gate/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<S extends { parallel?: readonly S[] }>(steps: readonly S[]): S[] {
return steps.flatMap((step) => (step.parallel ? runnableSteps(step.parallel) : [step]));
}

Expand Down
14 changes: 7 additions & 7 deletions test/ci/trusted-fixture-artifact.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;

Expand Down
Loading