mirror of
https://github.com/expo/explore.git
synced 2026-11-15 13:18:16 -10:00
A failed hosted repack starts again, and a run's matrix jobs share one repack of each commit
In brentvatne/euxy#176 (review run 39506405687) EAS ended a repack's build while it saved the app, and the target failed with EAS_REPACK_FAILED; the four iOS matrix jobs had each made the same repack of build a81d5d80. A repack EAS failed around (an upload, spin-up or timeout) starts again up to twice, one whose run does not say why once, and one the app's JavaScript broke, a refused token or a cancelled run never, within 20 minutes of the first. The targets that repack one app on EAS now meet on EAS: each keys its staged upload (every file's bytes, the native build, profile, environment, Explore release and the GitHub run), and a build whose message carries that key is used instead of repacking again. The first target in config order repacks at once; the others wait up to 3 minutes for its repack to appear, follow it, and repack themselves when it fails or never comes. CI-FLOW.md §4.1 documents it.
This commit is contained in:
1 parent
29f1f0721f
commit
362d5f2c4d
9 files changed
+544
-32
No files matched your search
+27
-1
@@ -104,11 +104,37 @@ Head capture is never delayed. When the baseline arrives while head captures, ba
|
||||
| 1 | cache | If a reuse directory exists, its bundle and map are validated and copied. With no routes left, skip straight to export. |
|
||||
| 2 | `configuration` | `eas config --profile` confirms the app identity and scheme, `ios.simulator: true` and the bundle ID; `eas simulator:availability`. |
|
||||
| 3 | `build` | `eas fingerprint:generate`; a finished simulator build with the same fingerprint is reused, otherwise `eas build --wait` (up to 45 minutes). |
|
||||
| 4 | `instrumentation` | A hosted EAS `repack` workflow job (`eas workflow:run --wait --json` from a staged copy of the checkout) rebundles the current JavaScript with a read-only navigation observer (the same observer on both sides), and the repacked app is downloaded and installed into the session; `capture.repack: local` (the default with `capture.simulator: local`) runs `@expo/repack-app` on the runner, and its app is installed without an upload. Generated files stay outside the checkout. |
|
||||
| 4 | `instrumentation` | A hosted EAS `repack` workflow job (`eas workflow:run --wait --json` from a staged copy of the checkout) rebundles the current JavaScript with a read-only navigation observer (the same observer on both sides), and the repacked app is downloaded and installed into the session; `capture.repack: local` (the default with `capture.simulator: local`) runs `@expo/repack-app` on the runner, and its app is installed without an upload. Generated files stay outside the checkout. A failed hosted repack starts again, and a run's matrix jobs make one repack of each commit between them (§4.1). |
|
||||
| 5 | `session` | `eas simulator:start`; the session ID is written to `<side>-session`; the app is installed. |
|
||||
| 6 | route capture | Mode-specific (§5). `agent-device` drives the simulator and records a screenshot plus the accessibility tree. A capture is accepted only when the observer's reported destination matches the requested route. |
|
||||
| 7 | `export` / `cleanup` | Validate the map, write `<side>-export/` (`bundle.json`, `execution.json`, PNGs, `capture-diagnostics/`), stop the session. |
|
||||
|
||||
### 4.1 The hosted repack: retries, and one repack per commit for a run's jobs
|
||||
|
||||
`prepareHostedRepack` (`src/capture/eas-build.ts`) runs the repack job, and two things keep it from failing a target or repeating work.
|
||||
|
||||
**A failed repack starts again.** In brentvatne/euxy#176 (review run 39506405687) EAS ended a repack's build while its "Upload artifact" step was saving the app ("Turtle build is not in progress", reported as `Failed to upload application archive.`), and the target failed with `EAS_REPACK_FAILED`. `hostedRepackBuildId` now records why a run failed, from the build's error, the job's errors and the CLI's output, and `hostedRepackRetries` turns that into fresh repacks of the same staged copy:
|
||||
|
||||
| Failure | Examples | Fresh repacks |
|
||||
| --- | --- | --- |
|
||||
| `infrastructure`: EAS failed around the repack | upload or download of an artifact, "not in progress", a worker, spin-up or timeout, `SERVER_ERROR`, a staged copy that failed to upload | 2 |
|
||||
| `unknown`: the run does not say | `ERRORED` with no error, "Unknown custom build error" | 1 |
|
||||
| `app`: the app's JavaScript or build environment | the `Repack` / `Repack app` step, `Unable to resolve module`, `SyntaxError`, `TransformError` | 0 |
|
||||
| `configuration` / `canceled` | a token or workflow EAS refuses before a run starts; a run someone cancelled | 0 |
|
||||
|
||||
The build's saved error is whatever its failing step threw, so the step that failed is not always named; a failure no pattern recognizes counts as `unknown` and is tried once more. Each new start logs the failed run's link and reason (`the hosted EAS repack https://expo.dev/…/workflows/<id> failed (…); starting another repack (1/2)`). A new repack starts only within 20 minutes of the first, the allowance the EAS session started beside the repack has for it (`SESSION_PREPARATION_MINUTES`), and each still has the 30-minute `workflow:run --wait` timeout. `--wait` reports only a finished run, so a failed one leaves nothing running; a run that outlasts the timeout is not repeated. The session is started once, beside the first repack, and installs whichever repack succeeds.
|
||||
|
||||
**One repack per commit for a run's matrix jobs.** Captures that run in one process already share a build: appearance passes of one side in worker threads, and the targets of a local review, meet in a directory (`src/capture/shared-build.ts`), where the first to claim a key builds and repacks and the others wait for its `result.json` ("using the build another capture of this run is preparing for this commit"). A GitHub matrix job is a runner of its own, with no directory in common, so in #176 the four iOS jobs each logged `reusing EAS build a81d5d80 … repacking it with this commit's JavaScript` and made four identical repacks. The jobs of one run meet on EAS instead:
|
||||
|
||||
1. `hostedRepackPeers` lists the targets, in config order, that repack the same app on EAS (one platform, EAS profile and bundle id); `capture:review`, `capture:review --compare` and `capture:baseline` pass them on. With two or more, and `GITHUB_RUN_ID` and `GITHUB_REPOSITORY` set, the capture gets a `RepackShare`: the run as its scope and the first peer as its leader. A single target, a local review and `capture.repack: local` behave as before.
|
||||
2. Once the copy is staged, the capture takes a key (`hostedRepackShareKey`): the run, the platform, the native build id, the EAS profile and environment, the Explore release, and a digest of every staged file with its path, executable bit and content (`stagedProjectDigest`), which covers the commit's JavaScript and the generated observer. Its own repack's message ends with `[explore share <key>]`.
|
||||
3. It reads the platform's 30 most recent builds (`eas build:list --json`) for one whose message ends with that marker. A finished one is downloaded and installed instead of repacking. A queued or running one is waited for, then downloaded. The leader looks once and repacks if there is none; another target waits up to 3 minutes for the leader's to appear, reading every 15 s, and every 30 s once it follows one.
|
||||
4. It repacks itself, with the retries above, when nothing appears in 3 minutes, when the repack it follows fails, is cancelled or drops off the list, when that repack outlasts 30 minutes, or when EAS fails to list builds three times in a row. A leader that reaches a side later than the others (a base capture that started after a baseline wait, say) finds the repack one of them made, and uses it.
|
||||
|
||||
Only a build whose marker is this capture's own key is used, and every input to the key is what this capture would have uploaded itself, so two jobs share a repack only when their uploads would have been byte for byte the same. The pull request's head chooses its own code, as it does for its own repack, and nothing else: the leader only decides who waits, and a build from another commit, another native build, another release or another run carries another key. A run's repacks are never used by another run, so a review's are not used by the baseline workflow, whose artifacts later reviews reuse. Making a build with someone else's key takes the project's EAS credentials, the ones that could already publish a simulator build with a reused fingerprint, which every capture already trusts by fingerprint (the `build` stage above). The key does not cover the EAS environment's variable values, which the repack job reads on EAS; a reused native build relies on them staying put during the run in the same way.
|
||||
|
||||
Cost: the leader adds one `build:list`; another target adds up to 13 while it waits for the leader's repack to appear and about two a minute while that repack runs, about 20 for a 5-minute repack. In #176's run that is about 60 lists per side for the three iOS targets that would otherwise have repacked, in place of three repacks. A follower whose leader never repacks this side (its baseline was downloaded, say) loses the 3 minutes before it repacks itself. Native builds are not shared across jobs: a fingerprint EAS has no build for is built by every job that needs it.
|
||||
|
||||
## 5. Deterministic and agent modes
|
||||
|
||||
| | Deterministic | Agent |
|
||||
|
||||
+232
-18
@@ -1,8 +1,11 @@
|
||||
import { cp, lstat, realpath, mkdtemp, mkdir, writeFile, readFile, rename, rm } from "node:fs/promises";
|
||||
import { createHash } from "node:crypto";
|
||||
import { cp, lstat, realpath, mkdtemp, mkdir, writeFile, readFile, readdir, readlink, rename, rm } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { isAbsolute, basename, dirname, resolve, join } from "node:path";
|
||||
import { isAbsolute, basename, dirname, resolve, join, relative, sep } from "node:path";
|
||||
import { setTimeout as delay } from "node:timers/promises";
|
||||
import type { SourceRoute } from "../contracts/source-route.js";
|
||||
import { CiError } from "../shared/ci-errors.js";
|
||||
import { EXPLORE_VERSION } from "../shared/package-paths.js";
|
||||
import { prepareCaptureObserver, captureObserverParameterKeys } from "./observer.js";
|
||||
import { isRecord, parseJson, nonEmpty } from "./common.js";
|
||||
import { isWithin } from "./fs-safety.js";
|
||||
@@ -395,34 +398,64 @@ export function hostedRepackWorkflow(input: {
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Why a hosted repack failed, as far as its run tells: `app` when the app's own JavaScript or build environment broke it
|
||||
* (the "Repack" step), which a rerun repeats; `configuration` when the CLI was refused before a run started (a token or
|
||||
* workflow EAS rejects); `canceled` when someone stopped it; `infrastructure` when EAS failed around the repack (spin-up,
|
||||
* the upload of the app it made, a timeout); `unknown` when the run does not say.
|
||||
*/
|
||||
export type HostedRepackFailure = "app" | "configuration" | "canceled" | "infrastructure" | "unknown";
|
||||
|
||||
const APP_REPACK_FAILURE = /Build step "Repack(?: app)?" failed|Unable to resolve module|SyntaxError|TransformError|Error while bundling|Bundling failed|Cannot find module/i;
|
||||
const CONFIGURATION_REPACK_FAILURE = /Not logged in|unauthori[sz]ed|not authorized|forbidden|permission|EXPO_TOKEN|validation error|invalid workflow|YAML/i;
|
||||
// "Failed to upload application archive." is how the upload step reported "Turtle build is not in progress" in
|
||||
// brentvatne/euxy#176 (review run 39506405687): EAS ended a build that had repacked, and a fresh repack succeeds.
|
||||
const INFRASTRUCTURE_REPACK_FAILURE = /upload|download|not in progress|timed? ?out|timeout|worker|spin.?up|provision|network|ECONN|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|socket|fetch failed|server error|internal error|unavailable|\b5\d\d\b|SERVER_ERROR|EAS_BUILD_TIMEOUT_ERROR|Failed to start the workflow/i;
|
||||
|
||||
/** How many fresh repacks a failure earns: two after EAS's own failure, one after one nothing explains, none otherwise. */
|
||||
export function hostedRepackRetries(error: unknown): number {
|
||||
const failure = error instanceof CiError && error.code === "EAS_REPACK_FAILED" ? error.details?.failure : undefined;
|
||||
return failure === "infrastructure" ? 2 : failure === "unknown" ? 1 : 0;
|
||||
}
|
||||
|
||||
/** The repacked build id from `eas workflow:run --json`, or the job's failure as a readable error. */
|
||||
export function hostedRepackBuildId(stdout: string, stderr: string, platform: "ios" | "android"): string {
|
||||
const logs = /See logs: (https:\/\/expo\.dev\/\S+)/.exec(stderr)?.[1];
|
||||
const where = logs ? ` Logs: ${logs}` : "";
|
||||
let logs = /See logs: (https:\/\/expo\.dev\/\S+)/.exec(stderr)?.[1];
|
||||
let value: unknown;
|
||||
try {
|
||||
value = parseJson(stdout, "eas workflow:run");
|
||||
} catch (error) {
|
||||
const tail = stderr.trim().split("\n").slice(-3).join(" | ").slice(0, 600);
|
||||
const failure: HostedRepackFailure = CONFIGURATION_REPACK_FAILURE.test(tail) ? "configuration" : INFRASTRUCTURE_REPACK_FAILURE.test(tail) ? "infrastructure" : "unknown";
|
||||
throw new CiError({
|
||||
code: "EAS_REPACK_FAILED",
|
||||
stage: "instrumentation",
|
||||
message: `eas workflow:run did not report the hosted ${platform} repack: ${stderr.trim().split("\n").slice(-3).join(" | ").slice(0, 600) || (error instanceof Error ? error.message : String(error))}`,
|
||||
nextAction: `Check that EXPO_TOKEN can run workflows for this EAS project and retry.${where}`,
|
||||
message: `eas workflow:run did not report the hosted ${platform} repack: ${tail || (error instanceof Error ? error.message : String(error))}`,
|
||||
nextAction: `Check that EXPO_TOKEN can run workflows for this EAS project and retry.${logs ? ` Logs: ${logs}` : ""}`,
|
||||
details: { failure, ...(logs ? { logs } : {}) },
|
||||
cause: error,
|
||||
});
|
||||
}
|
||||
if (isRecord(value) && typeof value.url === "string" && /^https:\/\/expo\.dev\/\S+$/.test(value.url)) logs = value.url;
|
||||
const where = logs ? ` Logs: ${logs}` : "";
|
||||
const jobs = isRecord(value) && Array.isArray(value.jobs) ? value.jobs.filter(isRecord) : [];
|
||||
const job = jobs.find(entry => entry.key === "repack") ?? jobs[0];
|
||||
if (!job || job.status !== "SUCCESS") {
|
||||
const build = job && isRecord(job.turtleBuild) ? job.turtleBuild : undefined;
|
||||
const detail = build && isRecord(build.error) && typeof build.error.message === "string" ? build.error.message.trim() : undefined;
|
||||
const buildError = build && isRecord(build.error) ? build.error : undefined;
|
||||
const detail = typeof buildError?.message === "string" ? buildError.message.trim() : undefined;
|
||||
const planLimit = easPlanLimitError(new Error(`${detail ?? ""}\n${stderr}`), platform);
|
||||
if (planLimit) throw planLimit;
|
||||
const jobErrors = Array.isArray(job?.errors) ? job.errors.filter(isRecord).map(entry => `${String(entry.title ?? "")} ${String(entry.message ?? "")}`) : [];
|
||||
const evidence = [detail ?? "", typeof buildError?.errorCode === "string" ? buildError.errorCode : "", ...jobErrors].join("\n");
|
||||
const failure: HostedRepackFailure = job?.status === "CANCELED" ? "canceled" : APP_REPACK_FAILURE.test(evidence) ? "app"
|
||||
: INFRASTRUCTURE_REPACK_FAILURE.test(evidence) ? "infrastructure" : "unknown";
|
||||
throw new CiError({
|
||||
code: "EAS_REPACK_FAILED",
|
||||
stage: "instrumentation",
|
||||
message: `The hosted EAS repack of the ${platform} build ${job ? `finished with status ${String(job.status)}` : "did not run"}${detail ? `: ${detail.slice(0, 600)}` : "."}`,
|
||||
nextAction: `Open the EAS workflow run and fix the repack job; a broken app build environment usually surfaces in its "Repack" step.${where}`,
|
||||
details: { failure, ...(logs ? { logs } : {}) },
|
||||
});
|
||||
}
|
||||
const outputs = isRecord(job.outputs) ? job.outputs : {};
|
||||
@@ -433,10 +466,152 @@ export function hostedRepackBuildId(stdout: string, stderr: string, platform: "i
|
||||
return buildId;
|
||||
}
|
||||
|
||||
/** How long `eas workflow:run --wait` may take for one hosted repack, queue included. */
|
||||
const HOSTED_REPACK_TIMEOUT_MS = 30 * 60_000;
|
||||
/**
|
||||
* A fresh repack starts only this long after the first one did: the EAS session started beside the repack is given 20
|
||||
* minutes beyond the capture's own (SESSION_PREPARATION_MINUTES in run.ts), and a later app would eat into the capture.
|
||||
*/
|
||||
const HOSTED_REPACK_RETRY_BUDGET_MS = 20 * 60_000;
|
||||
|
||||
/**
|
||||
* Where the matrix jobs of one GitHub run meet to make one hosted repack of an app instead of one each: `scope` names the
|
||||
* run (repository and run id), `leader` the first target in config order that repacks this app, and `target` this one.
|
||||
* In brentvatne/euxy#176 (review run 39506405687) four iOS targets each repacked EAS build a81d5d80 with the same
|
||||
* commit's JavaScript at the same time, and one of the four failed.
|
||||
*/
|
||||
export type RepackShare = { scope: string; leader: string; target: string };
|
||||
|
||||
/** How long a target waits for its leader's repack to appear on EAS before it repacks itself. */
|
||||
const SHARED_REPACK_APPEAR_MS = 3 * 60_000;
|
||||
/** Polls while the leader's repack has not appeared, and while a repack this target waits for runs. */
|
||||
const SHARED_REPACK_APPEAR_POLL_MS = 15_000;
|
||||
const SHARED_REPACK_FOLLOW_POLL_MS = 30_000;
|
||||
/** The recent builds of the platform each poll reads; one this run made minutes ago is among them. */
|
||||
const SHARED_REPACK_LIST_LIMIT = 30;
|
||||
|
||||
/**
|
||||
* Every byte the hosted repack would upload, as one digest: the staged checkout's tracked files and the generated
|
||||
* observer, path by path, with their kind, executable bit and content (a symlink by its target).
|
||||
*/
|
||||
export async function stagedProjectDigest(root: string): Promise<string> {
|
||||
const hash = createHash("sha256");
|
||||
const entries = (await readdir(root, { recursive: true, withFileTypes: true }))
|
||||
.map(entry => ({ entry, path: relative(root, join(entry.parentPath, entry.name)).split(sep).join("/") }))
|
||||
.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
||||
for (const { entry, path } of entries) {
|
||||
const full = join(root, path);
|
||||
if (entry.isSymbolicLink()) hash.update(`link\0${path}\0${await readlink(full)}\0`);
|
||||
else if (entry.isDirectory()) hash.update(`directory\0${path}\0`);
|
||||
else if (entry.isFile()) {
|
||||
const executable = ((await lstat(full)).mode & 0o111) !== 0;
|
||||
hash.update(`file\0${path}\0${executable ? "x" : "-"}\0${createHash("sha256").update(await readFile(full)).digest("hex")}\0`);
|
||||
} else throw new Error(`The staged copy holds ${path}, which is neither a file, a directory nor a symlink`);
|
||||
}
|
||||
return hash.digest("hex");
|
||||
}
|
||||
|
||||
/**
|
||||
* The key a shared repack's build carries in its message: everything the repack is made from, so two jobs share one only
|
||||
* when each would have uploaded the same bytes for the same native build, profile, environment and Explore release, in
|
||||
* the same run. Nothing in it comes from another job.
|
||||
*/
|
||||
export function hostedRepackShareKey(input: { scope: string; platform: "ios" | "android"; nativeBuildId: string; easProfile: string;
|
||||
environment: string; project: string }): string {
|
||||
return createHash("sha256").update(JSON.stringify({ contract: "expo-explore.repack-share.v1", explore: EXPLORE_VERSION, scope: input.scope,
|
||||
platform: input.platform, nativeBuildId: input.nativeBuildId, easProfile: input.easProfile, environment: input.environment, project: input.project }))
|
||||
.digest("hex").slice(0, 32);
|
||||
}
|
||||
|
||||
/** The marker a shared repack's build message ends with. */
|
||||
export function hostedRepackShareMarker(key: string): string {
|
||||
return `[explore share ${key}]`;
|
||||
}
|
||||
|
||||
type ListedBuild = { id: string; status: string };
|
||||
|
||||
/** The builds `eas build:list --json` lists that carry `marker` for `platform`, or undefined when the list is unreadable. */
|
||||
export function sharedRepackBuilds(stdout: string, marker: string, platform: "ios" | "android"): ListedBuild[] | undefined {
|
||||
let value: unknown;
|
||||
try { value = JSON.parse(stdout); } catch { return undefined; }
|
||||
if (!Array.isArray(value)) return undefined;
|
||||
return value.filter(isRecord).flatMap(build => typeof build.id === "string" && /^[A-Za-z0-9-]{1,128}$/.test(build.id) && typeof build.status === "string"
|
||||
&& typeof build.message === "string" && build.message.endsWith(marker) && String(build.platform).toLowerCase() === platform
|
||||
? [{ id: build.id, status: build.status }] : []);
|
||||
}
|
||||
|
||||
const LIVE_BUILD_STATUSES = new Set(["NEW", "IN_QUEUE", "IN_PROGRESS"]);
|
||||
|
||||
/**
|
||||
* A repack another job of this run made, or is making, of exactly this app: its EAS build id once it finished, or
|
||||
* undefined when this job should repack itself. The leader looks once; another target waits up to
|
||||
* SHARED_REPACK_APPEAR_MS for one to appear. A repack it waits for that fails, disappears from the list or outlasts a
|
||||
* repack's own timeout sends it to repack itself, and so do three unreadable lists in a row: it never waits on a job
|
||||
* that cannot answer.
|
||||
*/
|
||||
async function sharedHostedRepack(options: { share: RepackShare; marker: string; platform: "ios" | "android"; list: () => string;
|
||||
say: (message: string) => void; now: () => number; sleep?: ((milliseconds: number) => void) | undefined; signal?: AbortSignal | undefined }): Promise<string | undefined> {
|
||||
const leader = options.share.leader === options.share.target;
|
||||
const start = options.now();
|
||||
const appearBy = start + (leader ? 0 : SHARED_REPACK_APPEAR_MS);
|
||||
let followed: string | undefined;
|
||||
let unreadable = 0;
|
||||
let announced = false;
|
||||
for (;;) {
|
||||
options.signal?.throwIfAborted();
|
||||
let listed: ListedBuild[] | undefined;
|
||||
try { listed = sharedRepackBuilds(options.list(), options.marker, options.platform); } catch { listed = undefined; }
|
||||
if (!listed) {
|
||||
unreadable += 1;
|
||||
if (unreadable >= 3) { options.say("EAS did not list its builds three times in a row; repacking here instead of waiting for another target's repack"); return undefined; }
|
||||
} else {
|
||||
unreadable = 0;
|
||||
const finished = listed.find(build => build.status === "FINISHED");
|
||||
if (finished) {
|
||||
options.say(`using EAS build ${finished.id}, the hosted repack of this commit another target of this run made, instead of repacking it again`);
|
||||
return finished.id;
|
||||
}
|
||||
if (followed) {
|
||||
const current = listed.find(build => build.id === followed);
|
||||
if (!current || !LIVE_BUILD_STATUSES.has(current.status)) {
|
||||
options.say(`the shared repack (EAS build ${followed}) ${current ? `ended ${current.status}` : "is no longer listed"}; repacking here`);
|
||||
return undefined;
|
||||
}
|
||||
} else {
|
||||
const live = listed.find(build => LIVE_BUILD_STATUSES.has(build.status));
|
||||
if (live) {
|
||||
followed = live.id;
|
||||
options.say(`waiting for EAS build ${live.id}, the hosted repack of this commit another target of this run started, instead of repacking it again`);
|
||||
}
|
||||
}
|
||||
}
|
||||
const now = options.now();
|
||||
if (!followed && now >= appearBy) {
|
||||
if (!leader) options.say(`no repack of this commit from ${options.share.leader} appeared within ${SHARED_REPACK_APPEAR_MS / 60_000} minutes; repacking here`);
|
||||
return undefined;
|
||||
}
|
||||
if (now - start >= HOSTED_REPACK_TIMEOUT_MS) {
|
||||
options.say(`the shared repack (EAS build ${followed}) did not finish within ${HOSTED_REPACK_TIMEOUT_MS / 60_000} minutes; repacking here`);
|
||||
return undefined;
|
||||
}
|
||||
if (!followed && !announced) {
|
||||
announced = true;
|
||||
options.say(`waiting up to ${SHARED_REPACK_APPEAR_MS / 60_000} minutes for the hosted repack ${options.share.leader} makes of this commit, instead of repacking it again`);
|
||||
}
|
||||
const pause = followed ? SHARED_REPACK_FOLLOW_POLL_MS : SHARED_REPACK_APPEAR_POLL_MS;
|
||||
if (options.sleep) options.sleep(pause);
|
||||
else await delay(pause, undefined, options.signal ? { signal: options.signal } : {});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Repack on EAS instead of the runner: the tracked files of the clean checkout are staged beside the
|
||||
* observer and a one-job workflow, uploaded with `eas workflow:run`, and the job's `build_id` comes back.
|
||||
* No build tools, no `eas upload`, and the profile's EAS environment applies as it does for any build.
|
||||
* With a `share`, a repack another job of this run makes of the same staged bytes is used instead (sharedHostedRepack),
|
||||
* and this job's own repack carries the key that lets the others use it. A repack that fails for a reason a rerun can
|
||||
* fix starts again (hostedRepackRetries): in brentvatne/euxy#176 EAS ended a build that had repacked before it could
|
||||
* save the app.
|
||||
*/
|
||||
async function prepareHostedRepack(options: {
|
||||
platform: "ios" | "android";
|
||||
@@ -451,6 +626,11 @@ async function prepareHostedRepack(options: {
|
||||
provider: SourceRoute["provider"];
|
||||
parameterKeys: readonly string[];
|
||||
root: string;
|
||||
share?: RepackShare | undefined;
|
||||
say: (message: string) => void;
|
||||
now: () => number;
|
||||
sleep?: ((milliseconds: number) => void) | undefined;
|
||||
signal?: AbortSignal | undefined;
|
||||
}): Promise<string> {
|
||||
const staged = join(options.root, "project");
|
||||
await mkdir(staged, { mode: 0o700 });
|
||||
@@ -481,19 +661,44 @@ async function prepareHostedRepack(options: {
|
||||
message: error instanceof Error ? error.message : "The route observer could not be prepared.",
|
||||
nextAction: "Check the installed Expo and navigation package compatibility for automatic capture instrumentation.", cause: error });
|
||||
}
|
||||
let message = `expo-explore ${options.platform} capture: route observer repack`;
|
||||
if (options.share) {
|
||||
// The digest is taken before the workflow file is written: the file's message carries the key made from it.
|
||||
const marker = hostedRepackShareMarker(hostedRepackShareKey({ scope: options.share.scope, platform: options.platform, nativeBuildId: options.nativeBuildId,
|
||||
easProfile: options.easProfile, environment: options.repackProfile.easEnvironment, project: await stagedProjectDigest(staged) }));
|
||||
const shared = await sharedHostedRepack({ share: options.share, marker, platform: options.platform, say: options.say, now: options.now, sleep: options.sleep, signal: options.signal,
|
||||
list: () => options.runner({ command: options.easCommand, args: ["build:list", "--platform", options.platform, "--limit", String(SHARED_REPACK_LIST_LIMIT), "--json", "--non-interactive"],
|
||||
cwd: options.project, environment: { ...options.easEnvironment, TMPDIR: options.root, TMP: options.root, TEMP: options.root }, timeoutMs: 2 * 60_000, allowFailure: true }).stdout });
|
||||
if (shared) return shared;
|
||||
message = `${message} ${marker}`;
|
||||
}
|
||||
const workflowPath = join(staged, HOSTED_REPACK_WORKFLOW);
|
||||
await mkdir(dirname(workflowPath), { recursive: true });
|
||||
await writeFile(workflowPath, hostedRepackWorkflow({ buildId: options.nativeBuildId, profile: options.easProfile,
|
||||
environment: options.repackProfile.easEnvironment, message: `expo-explore ${options.platform} capture: route observer repack` }), { flag: "wx", mode: 0o600 });
|
||||
const run = options.runner({
|
||||
command: options.easCommand,
|
||||
args: ["workflow:run", HOSTED_REPACK_WORKFLOW, "--wait", "--json", "--non-interactive"],
|
||||
cwd: staged,
|
||||
environment: { ...options.easEnvironment, EAS_NO_VCS: "1", TMPDIR: options.root, TMP: options.root, TEMP: options.root },
|
||||
timeoutMs: 30 * 60_000,
|
||||
allowFailure: true,
|
||||
});
|
||||
return hostedRepackBuildId(run.stdout, run.stderr, options.platform);
|
||||
environment: options.repackProfile.easEnvironment, message }), { flag: "wx", mode: 0o600 });
|
||||
const first = options.now();
|
||||
let retries = 0;
|
||||
for (;;) {
|
||||
const run = options.runner({
|
||||
command: options.easCommand,
|
||||
args: ["workflow:run", HOSTED_REPACK_WORKFLOW, "--wait", "--json", "--non-interactive"],
|
||||
cwd: staged,
|
||||
environment: { ...options.easEnvironment, EAS_NO_VCS: "1", TMPDIR: options.root, TMP: options.root, TEMP: options.root },
|
||||
timeoutMs: HOSTED_REPACK_TIMEOUT_MS,
|
||||
allowFailure: true,
|
||||
});
|
||||
try {
|
||||
return hostedRepackBuildId(run.stdout, run.stderr, options.platform);
|
||||
} catch (error) {
|
||||
// A failed run has ended (`--wait` reports only a finished run), so a fresh one leaves nothing running beside it.
|
||||
const allowed = hostedRepackRetries(error);
|
||||
if (retries >= allowed || options.now() - first >= HOSTED_REPACK_RETRY_BUDGET_MS) throw error;
|
||||
retries += 1;
|
||||
const logs = error instanceof CiError && typeof error.details?.logs === "string" ? error.details.logs : undefined;
|
||||
options.say(`the hosted EAS repack${logs ? ` ${logs}` : ""} failed (${error instanceof Error ? error.message : String(error)}); starting another repack (${retries}/${allowed})`);
|
||||
options.signal?.throwIfAborted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -520,6 +725,14 @@ export async function prepareExactSourceBuild(options: {
|
||||
easProfile?: string | undefined;
|
||||
/** Where to leave the instrumented app on this machine, for the capture to install; it must not exist yet. */
|
||||
keepApp: string;
|
||||
/** The other matrix jobs of this run that repack the same app, to make one hosted repack with (RepackShare). */
|
||||
share?: RepackShare | undefined;
|
||||
/** Says what the hosted repack is doing when it waits for another job's repack or starts another one. */
|
||||
progress?: ((message: string) => void) | undefined;
|
||||
/** The clock and pause the waits and retries use; tests replace them so that minutes are not real time. */
|
||||
now?: (() => number) | undefined;
|
||||
sleep?: ((milliseconds: number) => void) | undefined;
|
||||
signal?: AbortSignal | undefined;
|
||||
}): Promise<PreparedBuild | undefined> {
|
||||
const platform = options.platform ?? "ios";
|
||||
const root = await mkdtemp(join(tmpdir(), "expo-explore-repack-"));
|
||||
@@ -535,7 +748,8 @@ export async function prepareExactSourceBuild(options: {
|
||||
const hosted = await prepareHostedRepack({ platform, runner: options.runner, easCommand: options.easCommand, project: options.project,
|
||||
nativeBuildId: options.nativeBuildId, easProfile: options.easProfile, repackProfile: options.repackProfile,
|
||||
easEnvironment: options.easEnvironment, restrictedEnvironment: options.repackEnvironment, provider: providers[0]!,
|
||||
parameterKeys: captureObserverParameterKeys(options.routes), root });
|
||||
parameterKeys: captureObserverParameterKeys(options.routes), root, share: options.share, say: options.progress ?? (() => undefined),
|
||||
now: options.now ?? Date.now, sleep: options.sleep, signal: options.signal });
|
||||
{
|
||||
// The hosted job leaves its app on EAS; the capture installs a copy downloaded here.
|
||||
const downloaded = await downloadedAppPath(options.runner({ command: options.easCommand,
|
||||
|
||||
+8
-4
@@ -21,7 +21,7 @@ import { lstatIfExists, isWithin, temporaryCaptureDirectory, absoluteContractFil
|
||||
import { loadAppIcon, loadCachedAppIcon, storeAppIcon } from "./app-icon.js";
|
||||
import { defaultRunner, runAgentControllerCommand } from "./controller.js";
|
||||
import { silentProgress, type Progress } from "../shared/progress.js";
|
||||
import { assertCaptureEasProfile, assertSimulatorAvailable, fingerprintFrom, hasEasEnvironmentFetchFailure, nativeBuildFrom, existingBuild, repackProfileFrom, prepareExactSourceBuild, type RepackMode } from "./eas-build.js";
|
||||
import { assertCaptureEasProfile, assertSimulatorAvailable, fingerprintFrom, hasEasEnvironmentFetchFailure, nativeBuildFrom, existingBuild, repackProfileFrom, prepareExactSourceBuild, type RepackMode, type RepackShare } from "./eas-build.js";
|
||||
import { SIMULATOR_DOTENV_FILE_NAME, SIMULATOR_DOTENV_HEADER, endedOwnSimulatorSession, liveSimulatorSessionsNamed, simulatorSessionName, simulatorStartFailure, readSimulatorDotenvHandoff, assertSimulatorSessionIdentity, assertSimulatorStopped, collectRuntime, controllerVersion, simulatorOsVersion, type ActiveSimulatorRuntime, type SimulatorConnection } from "./simulator.js";
|
||||
import { argentControllerInvocation } from "./controller-invocation.js";
|
||||
import { startArgentBridgeRunner, type ArgentBridgeRunner } from "./argent-bridge-host.js";
|
||||
@@ -71,6 +71,8 @@ export type CiMapOptions = {
|
||||
repack?: RepackMode;
|
||||
/** A folder the review's captures share builds through: targets of one platform, profile and commit build and repack once. */
|
||||
buildShare?: string;
|
||||
/** The matrix jobs of this GitHub run that repack the same app: they make one hosted repack per commit between them. */
|
||||
repackShare?: RepackShare;
|
||||
/** Which appearances to capture; `auto` (default) follows the app's `userInterfaceStyle`. */
|
||||
appearance?: AppearanceSetting;
|
||||
/**
|
||||
@@ -580,6 +582,8 @@ async function executeCiMap(options: CiMapOptions, setStage: (stage: string) =>
|
||||
const appDirectory = !options.buildShare ? await realpath(await mkdtemp(join(tmpdir(), "expo-explore-app-"))) : undefined;
|
||||
let localApp: string | undefined;
|
||||
type BuiltApp = { fingerprint: string; nativeEasBuildId: string | null; easBuildId: string | null; app?: string; reused: boolean; version?: string; buildNumber?: string };
|
||||
// What a hosted repack shared with this run's other matrix jobs, or retried, waits with and reports through.
|
||||
const repackWaits = { share: options.repackShare, progress: say, now: options.now, sleep: options.sleep, signal: options.signal };
|
||||
// `repacking` tells the captures sharing this build that their sessions can start too (sharedBuild).
|
||||
const buildApp = async (keepApp: string, repacking?: () => Promise<void>): Promise<BuiltApp> => {
|
||||
options.signal?.throwIfAborted();
|
||||
@@ -593,7 +597,7 @@ async function executeCiMap(options: CiMapOptions, setStage: (stage: string) =>
|
||||
say(`reusing EAS build ${reusable.id} (fingerprint ${sourceFingerprint.slice(0, 12)}); repacking it with this commit's JavaScript and the route observer`);
|
||||
startSession(); await repacking?.();
|
||||
const repacked = await prepareExactSourceBuild({ platform: options.platform, runner, easCommand: options.easCommand, repackCommand: options.repackCommand,
|
||||
project, nativeBuildId: reusable.id, fingerprint: sourceFingerprint, repackProfile: profile, easEnvironment, repackEnvironment: restrictedEnvironment, routes: inventory, repack: options.repack, easProfile: options.easProfile, keepApp });
|
||||
project, nativeBuildId: reusable.id, fingerprint: sourceFingerprint, repackProfile: profile, easEnvironment, repackEnvironment: restrictedEnvironment, routes: inventory, repack: options.repack, easProfile: options.easProfile, keepApp, ...repackWaits });
|
||||
if (!repacked) throw new CiError({ code: "CAPTURE_OBSERVER_BUILD_UNSUPPORTED", stage: "instrumentation",
|
||||
message: "The build environment cannot be reproduced for automatic capture instrumentation.",
|
||||
nextAction: "Use a simulator build profile whose required bundle environment can be pulled for local repacking; an uninstrumented build cannot verify captures." });
|
||||
@@ -607,7 +611,7 @@ async function executeCiMap(options: CiMapOptions, setStage: (stage: string) =>
|
||||
say(`EAS build ${built.id} finished; repacking it with the route observer`);
|
||||
startSession(); await repacking?.();
|
||||
const repacked = await prepareExactSourceBuild({ platform: options.platform, runner, easCommand: options.easCommand, repackCommand: options.repackCommand,
|
||||
project, nativeBuildId: built.id, fingerprint: built.fingerprint, repackProfile: profile, easEnvironment, repackEnvironment: restrictedEnvironment, routes: inventory, repack: options.repack, easProfile: options.easProfile, keepApp });
|
||||
project, nativeBuildId: built.id, fingerprint: built.fingerprint, repackProfile: profile, easEnvironment, repackEnvironment: restrictedEnvironment, routes: inventory, repack: options.repack, easProfile: options.easProfile, keepApp, ...repackWaits });
|
||||
if (!repacked) throw new CiError({ code: "CAPTURE_OBSERVER_BUILD_UNSUPPORTED", stage: "instrumentation",
|
||||
message: "The fresh native build cannot be instrumented with the required route observer.",
|
||||
nextAction: "Use a simulator profile with a reproducible bundle environment so both revisions can be repacked with the same observer." });
|
||||
@@ -621,7 +625,7 @@ async function executeCiMap(options: CiMapOptions, setStage: (stage: string) =>
|
||||
? await sharedBuild({ directory: options.buildShare, appName, ...(options.signal ? { signal: options.signal } : {}), build: buildApp, owner: options.outputDirectory,
|
||||
key: { platform: options.platform, easProfile: options.easProfile, bundleId: options.bundleId, gitCommit: options.gitCommit, repack: options.repack ?? "eas", local,
|
||||
routes: inventory.map(route => route.id) },
|
||||
waiting: () => say("using the build another target of this review is preparing for this commit"),
|
||||
waiting: () => say("using the build another capture of this run is preparing for this commit"),
|
||||
// The session is named before its app exists, so a waiter's session boots while the other capture repacks.
|
||||
repacking: () => startSession() })
|
||||
: await buildApp(join(appDirectory!, appName));
|
||||
|
||||
+22
-1
@@ -8,6 +8,7 @@ import { setTimeout as delay } from "node:timers/promises";
|
||||
import { promisify } from "node:util";
|
||||
import { buildVerifiedPlan } from "./verified-plan.js";
|
||||
import { runCiMap, type CiMapOptions, type CommandRunner } from "../capture/run.js";
|
||||
import type { RepackShare } from "../capture/eas-build.js";
|
||||
import { resolveColorSchemes, routeIdOfScreen, type ColorScheme } from "../capture/appearance.js";
|
||||
import { baseEnvironment } from "../capture/common.js";
|
||||
import { DEFAULT_MAX_SESSIONS, planSideSessions, sessionShare } from "./session-plan.js";
|
||||
@@ -81,6 +82,18 @@ function captureOptions(config: ExploreConfig, environment: NodeJS.ProcessEnv, r
|
||||
...(config.capture.simulator ? { simulator: config.capture.simulator } : {}),
|
||||
environment, ...(runner ? { runner } : {}), easCommand: packageBin("eas-cli", "eas"), agentDeviceCommand: agentDeviceLauncher(environment), repackCommand: packageBin("@expo/repack-app", "repack-app") };
|
||||
}
|
||||
/**
|
||||
* The hosted repack this capture shares with the other matrix jobs of its GitHub run (RepackShare): only inside a GitHub
|
||||
* Actions run, whose jobs are the only ones that meet, and only when another target repacks the same app (`peers`, in
|
||||
* config order, from hostedRepackPeers). A run's repacks are never used by another run, such as the baseline workflow's.
|
||||
*/
|
||||
export function repackShareOption(config: ExploreConfig, environment: NodeJS.ProcessEnv, peers: readonly string[] | undefined): { repackShare?: RepackShare } {
|
||||
const target = config.target?.id;
|
||||
if (!peers || peers.length < 2 || !target || !peers.includes(target) || captureRepack(config) !== "eas") return {};
|
||||
const run = environment.GITHUB_RUN_ID ?? "", repository = environment.GITHUB_REPOSITORY ?? "";
|
||||
if (!/^[1-9][0-9]*$/.test(run) || !/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repository)) return {};
|
||||
return { repackShare: { scope: `${repository}#${run}`, leader: peers[0]!, target } };
|
||||
}
|
||||
/**
|
||||
* Head and base run in parallel worker threads when nothing ties them together: an agent session is
|
||||
* shared, an injected runner belongs to this thread, and a plausible baseline needs head's runtime profile.
|
||||
@@ -221,6 +234,8 @@ export type PublicCiOptions = {
|
||||
targets?: RunTarget[];
|
||||
/** The targets with a device pose (foldables), which take the sessions `capture.maxSessions` does not divide evenly. */
|
||||
posedTargets?: readonly string[];
|
||||
/** The targets whose jobs repack the same app as this one, in config order (hostedRepackPeers): they share one hosted repack per commit. */
|
||||
repackPeers?: readonly string[];
|
||||
baseProject: string; headProject: string; pullRequestPath: string; output: string;
|
||||
config: ExploreConfig; configPath?: string; environment?: NodeJS.ProcessEnv; transport?: typeof fetch;
|
||||
now?: () => number; sleep?: (milliseconds: number) => void; onComment?: (state: PublicCommentState, body: string) => void;
|
||||
@@ -390,6 +405,8 @@ export async function runCiReview(options: {
|
||||
posedTargets?: readonly string[];
|
||||
/** A folder shared with the other targets' reviews, so the targets of one platform build each commit once. */
|
||||
buildShare?: string;
|
||||
/** The targets whose matrix jobs repack the same app as this one, in config order: they share one hosted repack per commit. */
|
||||
repackPeers?: readonly string[];
|
||||
measure?: Parameters<typeof assessPublicEvidence>[0]["measure"];
|
||||
state: PublicCommentState; environment: NodeJS.ProcessEnv;
|
||||
assertCurrentHead: () => Promise<void>; postComment: () => Promise<void>; canPublish?: () => boolean;
|
||||
@@ -486,6 +503,7 @@ export async function runCiReview(options: {
|
||||
mapDirectory: join(output, `${side}-map`), outputDirectory: directory,
|
||||
name: config.app.name ?? pr.repository, buildId: pr.origin === "local" ? `local-${pr.runId}-${side}` : pr.origin === "compare" ? `compare-${options.runId}-${side}` : `pr-${pr.number}-${side}`, buildVersion: pr[side].sha.slice(0, 8), gitCommit: pr[side].sha,
|
||||
planPath: join(output, "execution-plan.json"), side, sessionStatePath: join(output, `${side}-session`), ...(options.buildShare ? { buildShare: options.buildShare } : {}),
|
||||
...repackShareOption(config, environment, options.repackPeers),
|
||||
...(reuseDirectory ? { reuseDirectory } : {}), ...(options.signal ? { signal: options.signal } : {}) };
|
||||
// A restored baseline already holds every appearance pass, so it never splits.
|
||||
const captured = await captureSideInSessions(mapOptions, reuseDirectory ? undefined : sidePasses[side], progress, options.signal, concurrent);
|
||||
@@ -632,6 +650,8 @@ export async function runBaselineCi(options: { platform?: ExplorePlatform; proje
|
||||
targets?: RunTarget[];
|
||||
/** The targets with a device pose (foldables), which take the sessions `capture.maxSessions` does not divide evenly. */
|
||||
posedTargets?: readonly string[];
|
||||
/** The targets whose baseline jobs repack the same app as this one, in config order: they share one hosted repack. */
|
||||
repackPeers?: readonly string[];
|
||||
now?: () => number; sleep?: (milliseconds: number) => void;
|
||||
agentSessionFactory?: PrepareCiExplorationOptions["createSession"]; progress?: Progress;
|
||||
/** Use the local `eas login` session instead of EXPO_TOKEN (expo-explore doctor --capture). */
|
||||
@@ -662,7 +682,8 @@ export async function runBaselineCi(options: { platform?: ExplorePlatform; proje
|
||||
...(exploration.agent ? { agent: exploration.agent } : {}), project: options.project,
|
||||
mapDirectory: join(output, "baseline-map"), outputDirectory: directory, name: options.config.app.name ?? options.config.app.bundleId,
|
||||
buildId: `baseline-${options.sha.slice(0, 12)}`, buildVersion: options.sha.slice(0, 8), gitCommit: options.sha,
|
||||
side: "head", planPath: join(output, "execution-plan.json"), sessionStatePath: join(output, "baseline-session") };
|
||||
side: "head", planPath: join(output, "execution-plan.json"), sessionStatePath: join(output, "baseline-session"),
|
||||
...repackShareOption(options.config, environment, options.repackPeers) };
|
||||
const share = targetSessionShare(options.config, options.targets, options.posedTargets);
|
||||
// Passes on worker threads cannot take an injected runner or an agent session.
|
||||
const passes = !options.runner && !exploration.agent
|
||||
|
||||
@@ -15,7 +15,7 @@ import { installCiFiles } from "../ci/workflow-install.js";
|
||||
import { readRouteEntry } from "../ci/route-entry.js";
|
||||
import { buildVerifiedPlan } from "../ci/verified-plan.js";
|
||||
import { formatCaptureCheck, formatDoctorReport, referencedSecretNames, runCaptureCheck, runDoctor } from "../ci/doctor.js";
|
||||
import { readExploreConfig, readExploreInstructions, resolveTargetConfig, configTargets, posedTargets, isTargetId, withRunOverrides, warnIgnoredExpiry, configPlatforms as listPlatforms, EXPLORE_PLATFORMS, DEFAULT_EXPLORE_CONFIG_PATH, type ExplorePlatform } from "../config/explore-config.js";
|
||||
import { readExploreConfig, readExploreInstructions, resolveTargetConfig, configTargets, posedTargets, hostedRepackPeers, isTargetId, withRunOverrides, warnIgnoredExpiry, configPlatforms as listPlatforms, EXPLORE_PLATFORMS, DEFAULT_EXPLORE_CONFIG_PATH, type ExplorePlatform } from "../config/explore-config.js";
|
||||
import { argumentError, output, required, has, flag, flags, nonNegativeInteger, oneOf, positiveInteger } from "./args.js";
|
||||
import { help } from "./help.js";
|
||||
import { CiError } from "../shared/ci-errors.js";
|
||||
@@ -236,12 +236,14 @@ export async function captureReview(): Promise<void> {
|
||||
const rawConfig = await readExploreConfig(headProject, configPath);
|
||||
// A release comparison's workflow may still pass --expires-in; ci:deploy says once that report.preview.expiresAfter is ignored.
|
||||
if (has("expires-in")) warnIgnoredExpiry("--expires-in");
|
||||
const config = withRunOverrides(resolveTargetConfig(rawConfig, selection), { scope: flag("scope"), expiresIn: flag("expires-in"), controller: flag("controller"), simulator: flag("simulator"), repack: flag("repack") });
|
||||
const overrides = { scope: flag("scope"), expiresIn: flag("expires-in"), controller: flag("controller"), simulator: flag("simulator"), repack: flag("repack") };
|
||||
const config = withRunOverrides(resolveTargetConfig(rawConfig, selection), overrides);
|
||||
if (has("pull-request") === has("compare")) argumentError("Pass --pull-request FILE for a pull request, or --compare FILE for any two commits.", has("compare") ? "compare" : "pull-request");
|
||||
// A matrix job names its target; its artifacts, report and comment section carry the target's id.
|
||||
const named = selection.target !== undefined || selection.platform !== undefined;
|
||||
const common = { ...(named ? { target: config.target!.id } : {}), ...(selection.platform ? { platform: selection.platform } : {}),
|
||||
platforms: listPlatforms(rawConfig), targets: configTargets(rawConfig), posedTargets: posedTargets(rawConfig), baseProject: required("base-project"), headProject,
|
||||
platforms: listPlatforms(rawConfig), targets: configTargets(rawConfig), posedTargets: posedTargets(rawConfig), repackPeers: hostedRepackPeers(rawConfig, config, overrides),
|
||||
baseProject: required("base-project"), headProject,
|
||||
output: required("output"), config, configPath, progress: stderrProgress() };
|
||||
const result = has("compare") ? await runCompareCi({ ...common, comparePath: required("compare") })
|
||||
: await runPublicCi({ ...common, pullRequestPath: required("pull-request") });
|
||||
@@ -253,8 +255,10 @@ export async function captureReview(): Promise<void> {
|
||||
export async function captureBaseline(): Promise<void> {
|
||||
const project = required("project");
|
||||
const rawConfig = await readExploreConfig(project, flag("config") ?? DEFAULT_EXPLORE_CONFIG_PATH);
|
||||
const config = withRunOverrides(resolveTargetConfig(rawConfig, targetSelection()), { controller: flag("controller"), simulator: flag("simulator"), repack: flag("repack") });
|
||||
output({ ok: true, ...await runBaselineCi({ platform: config.app.platform, project, sha: required("sha"), output: required("output"), config, targets: configTargets(rawConfig), posedTargets: posedTargets(rawConfig), progress: stderrProgress() }) });
|
||||
const overrides = { controller: flag("controller"), simulator: flag("simulator"), repack: flag("repack") };
|
||||
const config = withRunOverrides(resolveTargetConfig(rawConfig, targetSelection()), overrides);
|
||||
output({ ok: true, ...await runBaselineCi({ platform: config.app.platform, project, sha: required("sha"), output: required("output"), config, targets: configTargets(rawConfig), posedTargets: posedTargets(rawConfig),
|
||||
repackPeers: hostedRepackPeers(rawConfig, config, overrides), progress: stderrProgress() }) });
|
||||
}
|
||||
|
||||
/** `capture` (or `capture:review`) `[--base REF] [--head REF | --committed]`: a local review, opened in the Viewer or hosted with --upload. */
|
||||
|
||||
@@ -571,6 +571,19 @@ export function captureRepack(config: ExploreConfig): "eas" | "local" {
|
||||
return config.capture.repack ?? (config.capture.simulator === "local" ? "local" : "eas");
|
||||
}
|
||||
|
||||
/**
|
||||
* The targets, in config order, whose captures repack the same app as `selected` on EAS: one platform, EAS profile and
|
||||
* bundle id. Their matrix jobs make one hosted repack per commit between them, led by the first (RepackShare); a target
|
||||
* no other one shares an app with gets just itself.
|
||||
*/
|
||||
export function hostedRepackPeers(config: ExploreConfig, selected: ExploreConfig, overrides: Parameters<typeof withRunOverrides>[1] = {}): string[] {
|
||||
if (captureRepack(selected) !== "eas" || !selected.target) return [];
|
||||
const sameApp = (other: ExploreConfig) => other.app.platform === selected.app.platform && other.app.easProfile === selected.app.easProfile
|
||||
&& other.app.bundleId === selected.app.bundleId && captureRepack(other) === "eas";
|
||||
return configTargets(config).filter(target => target.id === selected.target!.id || sameApp(withRunOverrides(resolveTargetConfig(config, { target: target.id }), overrides)))
|
||||
.map(target => target.id);
|
||||
}
|
||||
|
||||
const GITHUB_LOGIN = /^[A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38}(?:\[bot\])?$/;
|
||||
export const TRUSTED_AUTHORS_MAX = 20;
|
||||
|
||||
|
||||
+136
-1
@@ -128,7 +128,7 @@ async function fixture(t, settings = {}) {
|
||||
let current = '/'; let snapshots = 0; let sessionName; let screenshotAttempts = 0; let splashLeft = 0; let recordingPath = ''; let alert = null; let appearance = 'light'; let alertReads = 0;
|
||||
let enteredName = false; let scrolledToContinue = false; let finishHidden = false; let wedgeCleared = false; let deviceLost = false; let relaunchedAfterForeign = false; let serverStarts = 0; let unreadableLeft = settings.unreadableAfterFold ?? 0;
|
||||
// startsErrored / startsUnnamed: how many session starts EAS fails, after naming the session (it ERRORS) or before.
|
||||
let starts = 0; let currentSession = 'session-1'; const erroredSessions = new Set(); let foldUnverifiedLeft = settings.foldUnverified ?? 0;
|
||||
let starts = 0; let currentSession = 'session-1'; let workflowRuns = 0; const erroredSessions = new Set(); let foldUnverifiedLeft = settings.foldUnverified ?? 0;
|
||||
// listFailures: the first so many `simulator:control --list` calls fail, as a host that drops the connection does.
|
||||
let listFailuresLeft = settings.listFailures ?? 0;
|
||||
// focusedField: the screen at `path` focuses its text field, and the keyboard is up from the `keyboardFrom`th read of it.
|
||||
@@ -219,6 +219,13 @@ async function fixture(t, settings = {}) {
|
||||
}
|
||||
if (command === 'fingerprint:generate') return json({ hash: 'source-fingerprint' });
|
||||
const buildMetadata = settings.buildMetadata ? { appVersion: '2.1.0', appBuildVersion: '42' } : {};
|
||||
// eas: the project's builds on EAS, shared by the fixtures of one test as the matrix jobs of one run share EAS.
|
||||
// A list without a fingerprint is a target looking for a repack another job of its run made (onList moves it on).
|
||||
if (command === 'build:list' && !request.args.includes('--fingerprint-hash')) {
|
||||
assert.ok(settings.eas, 'only a shared repack lists builds without a fingerprint');
|
||||
settings.eas.lists += 1; settings.eas.onList?.(settings.eas);
|
||||
return json(settings.eas.builds);
|
||||
}
|
||||
if (command === 'build:list') return json(settings.reuse ? [{ id: 'native-build', ...buildMetadata }] : []);
|
||||
if (command === 'build') return json([{ id: 'built-app', fingerprint: { hash: 'source-fingerprint' }, ...buildMetadata }]);
|
||||
if (command === 'env:pull') { writeFileSync(value(request, '--path'), '# Environment: preview\nEXPO_PUBLIC_ENDPOINT=sample\n'); return { stdout: '', stderr: '' }; }
|
||||
@@ -237,6 +244,14 @@ async function fixture(t, settings = {}) {
|
||||
assert.match(readFileSync(join(request.cwd, '.expo-explore-observer/metro.config.cjs'), 'utf8'), /PROJECT_RELATIVE = "\.\."/);
|
||||
assert.ok(existsSync(join(request.cwd, 'package.json')), 'tracked files are staged');
|
||||
assert.ok(!existsSync(join(request.cwd, 'node_modules')), 'untracked files are not staged');
|
||||
// repackFailures: how EAS ends the first runs, as { status, message } of the repack job and its build.
|
||||
workflowRuns += 1;
|
||||
clockMs += settings.repackMs ?? 0;
|
||||
const failure = settings.repackFailures?.[workflowRuns - 1];
|
||||
if (failure) return { stdout: json({ id: `run-${workflowRuns}`, url: `https://expo.dev/accounts/acme/projects/example/workflows/run-${workflowRuns}`,
|
||||
jobs: [{ key: 'repack', status: failure.status, turtleBuild: { status: 'ERRORED', ...(failure.message ? { error: { errorCode: 'UNKNOWN_CUSTOM_BUILD_ERROR', message: failure.message } } : {}) }, outputs: {} }] }).stdout,
|
||||
stderr: `See logs: https://expo.dev/accounts/acme/projects/example/workflows/run-${workflowRuns}\n` };
|
||||
if (settings.eas) settings.eas.builds.unshift({ id: 'repacked-app', status: 'FINISHED', platform: settings.android ? 'ANDROID' : 'IOS', message: JSON.parse(/^ {6}message: (.*)$/m.exec(workflow)[1]) });
|
||||
if (settings.workflowPlanLimit) return json({ jobs: [{ key: 'repack', status: 'FAILURE', turtleBuild: { status: 'ERRORED', error: { message: 'This account has used its local builds from the production_plus plan this month, which will reset in 13 days (on Sat Oct 24 2026). | Request ID: 1234 | Error: GraphQL request failed.' } }, outputs: {} }] });
|
||||
if (settings.workflowFailure) return { stdout: json({ jobs: [{ key: 'repack', status: 'FAILURE', turtleBuild: { status: 'ERRORED', error: { errorCode: 'UNKNOWN_CUSTOM_BUILD_ERROR', message: 'Build step "Repack" failed.' } }, outputs: {} }] }).stdout, stderr: 'See logs: https://expo.dev/accounts/acme/projects/example/workflows/run-1\n' };
|
||||
return json({ jobs: [{ key: 'repack', status: 'SUCCESS', outputs: { build_id: 'repacked-app', platform: settings.android ? 'android' : 'ios' } }] });
|
||||
@@ -1876,6 +1891,126 @@ test('a failed hosted repack job stops the capture as EAS_REPACK_FAILED with the
|
||||
assert.deepEqual(f.operations().filter(operation => operation.startsWith('simulator:')).filter(operation => operation !== 'simulator:availability'), ['simulator:start', 'simulator:stop']);
|
||||
});
|
||||
|
||||
test('a repack the app broke is not started again', async t => {
|
||||
for (const failure of [{ status: 'FAILURE', message: 'Build step "Repack app" failed.' }, { status: 'CANCELED' }]) {
|
||||
const f = await fixture(t, { repackFailures: [failure] });
|
||||
await assert.rejects(runCiMap(f.options), error => error.code === 'EAS_REPACK_FAILED');
|
||||
assert.equal(f.operations().filter(operation => operation === 'workflow:run').length, 1, failure.status);
|
||||
}
|
||||
});
|
||||
|
||||
test('a hosted repack EAS ended before it saved the app starts again, and the capture goes on (brentvatne/euxy#176)', async t => {
|
||||
const f = await fixture(t, { repackFailures: [{ status: 'FAILURE', message: 'Failed to upload application archive.' }] });
|
||||
const lines = [];
|
||||
const result = await runCiMap({ ...f.options, progress: line => lines.push(line) });
|
||||
assert.equal(result.runStatus, 'complete');
|
||||
assert.equal(result.easBuildId, 'repacked-app');
|
||||
assert.equal(f.operations().filter(operation => operation === 'workflow:run').length, 2);
|
||||
assert.ok(lines.some(line => /the hosted EAS repack https:\/\/expo\.dev\/accounts\/acme\/projects\/example\/workflows\/run-1 failed \(The hosted EAS repack of the ios build finished with status FAILURE: Failed to upload application archive\.\); starting another repack \(1\/2\)/.test(line)), lines.join('\n'));
|
||||
// One session, started beside the first repack, installs the second one's app.
|
||||
assert.equal(f.operations().filter(operation => operation === 'simulator:start').length, 1);
|
||||
assert.equal(f.operations().filter(operation => operation === 'simulator:stop').length, 1);
|
||||
});
|
||||
|
||||
test('a repack EAS keeps failing is started twice more, one nothing explains once more, and a late failure not again', async t => {
|
||||
const upload = { status: 'FAILURE', message: 'Failed to upload application archive.' };
|
||||
const cases = [{ failures: [upload, upload, upload], runs: 3 }, { failures: [{ status: 'ERRORED' }, { status: 'ERRORED' }], runs: 2 },
|
||||
// A repack that failed 21 minutes in has used the time the session was given for it.
|
||||
{ failures: [upload], runs: 1, repackMs: 21 * 60_000 }];
|
||||
for (const { failures, runs, repackMs } of cases) {
|
||||
const f = await fixture(t, { repackFailures: failures, ...(repackMs ? { repackMs } : {}) });
|
||||
await assert.rejects(runCiMap(f.options), error => error.code === 'EAS_REPACK_FAILED' && new RegExp(`workflows/run-${runs}`).test(error.nextAction));
|
||||
assert.equal(f.operations().filter(operation => operation === 'workflow:run').length, runs);
|
||||
assert.deepEqual(f.operations().filter(operation => /^simulator:(start|stop)$/.test(operation)), ['simulator:start', 'simulator:stop']);
|
||||
}
|
||||
});
|
||||
|
||||
// Two matrix jobs of one GitHub run: iphone leads, duo-open follows, as hostedRepackPeers orders them.
|
||||
const share = (target, scope = 'acme/example#39506405687') => ({ repackShare: { scope, leader: 'iphone', target } });
|
||||
const shareLists = f => f.requests.filter(request => request.args[0] === 'build:list' && !request.args.includes('--fingerprint-hash')).length;
|
||||
const downloaded = f => f.requests.filter(request => request.args[0] === 'build:download').map(request => value(request, '--build-id'));
|
||||
/** The message the leader's repack of this fixture's app gives its build, with the key the others look for. */
|
||||
async function leaderMessage(t, scope) {
|
||||
const eas = { builds: [], lists: 0 };
|
||||
const leader = await fixture(t, { reuse: true, eas });
|
||||
await runCiMap({ ...leader.options, ...share('iphone', scope) });
|
||||
return eas.builds[0].message;
|
||||
}
|
||||
|
||||
test('two jobs of one run that repack the same app share one hosted repack', async t => {
|
||||
const eas = { builds: [], lists: 0 };
|
||||
const leader = await fixture(t, { reuse: true, eas });
|
||||
await runCiMap({ ...leader.options, ...share('iphone') });
|
||||
// The leader looks once, finds nothing, and repacks with the key in its build's message.
|
||||
assert.equal(shareLists(leader), 1);
|
||||
assert.equal(leader.operations().filter(operation => operation === 'workflow:run').length, 1);
|
||||
assert.match(eas.builds[0].message, /^expo-explore ios capture: route observer repack \[explore share [0-9a-f]{32}\]$/);
|
||||
const follower = await fixture(t, { reuse: true, eas });
|
||||
const lines = [];
|
||||
const result = await runCiMap({ ...follower.options, ...share('duo-open'), progress: line => lines.push(line) });
|
||||
assert.equal(follower.operations().includes('workflow:run'), false, 'the follower does not repack');
|
||||
assert.deepEqual(downloaded(follower), ['repacked-app']);
|
||||
assert.equal(result.easBuildId, 'repacked-app');
|
||||
assert.equal(result.runStatus, 'complete');
|
||||
assert.ok(lines.some(line => /using EAS build repacked-app, the hosted repack of this commit another target of this run made/.test(line)), lines.join('\n'));
|
||||
});
|
||||
|
||||
test("a target waits for the leader's repack while it runs, then installs it", async t => {
|
||||
const message = await leaderMessage(t);
|
||||
// The leader's build is queued, then repacking, then done on the fourth list.
|
||||
const eas = { builds: [{ id: 'leader-repack', status: 'IN_QUEUE', platform: 'IOS', message }], lists: 0,
|
||||
onList: state => { state.builds[0].status = state.lists >= 4 ? 'FINISHED' : state.lists >= 2 ? 'IN_PROGRESS' : 'IN_QUEUE'; } };
|
||||
const follower = await fixture(t, { reuse: true, eas });
|
||||
const lines = [];
|
||||
const result = await runCiMap({ ...follower.options, ...share('duo-open'), progress: line => lines.push(line) });
|
||||
assert.equal(follower.operations().includes('workflow:run'), false);
|
||||
assert.deepEqual(downloaded(follower), ['leader-repack']);
|
||||
assert.equal(result.easBuildId, 'leader-repack');
|
||||
assert.equal(eas.lists, 4);
|
||||
assert.ok(lines.some(line => /waiting for EAS build leader-repack, the hosted repack of this commit another target of this run started/.test(line)), lines.join('\n'));
|
||||
});
|
||||
|
||||
test("a target whose leader's repack fails repacks itself, with the same key for the others", async t => {
|
||||
const message = await leaderMessage(t);
|
||||
const eas = { builds: [{ id: 'leader-repack', status: 'IN_PROGRESS', platform: 'IOS', message }], lists: 0,
|
||||
onList: state => { if (state.lists === 3) state.builds.find(build => build.id === 'leader-repack').status = 'ERRORED'; } };
|
||||
const follower = await fixture(t, { reuse: true, eas });
|
||||
const lines = [];
|
||||
const result = await runCiMap({ ...follower.options, ...share('duo-open'), progress: line => lines.push(line) });
|
||||
assert.equal(follower.operations().filter(operation => operation === 'workflow:run').length, 1);
|
||||
assert.equal(result.easBuildId, 'repacked-app');
|
||||
assert.equal(eas.lists, 3);
|
||||
assert.equal(eas.builds[0].message, message, "the follower's own repack carries the same key");
|
||||
assert.ok(lines.some(line => /the shared repack \(EAS build leader-repack\) ended ERRORED; repacking here/.test(line)), lines.join('\n'));
|
||||
});
|
||||
|
||||
test('a repack of other inputs is never used, and the wait for one ends after three minutes of modest polling', async t => {
|
||||
// Another run's repack of the same app, and builds of another platform or with the key not at the end.
|
||||
const otherRun = await leaderMessage(t, 'acme/example#1');
|
||||
const message = await leaderMessage(t);
|
||||
const changedEas = { builds: [], lists: 0 };
|
||||
const changedLeader = await fixture(t, { reuse: true, eas: changedEas });
|
||||
writeFileSync(join(changedLeader.options.project, 'app.json'), JSON.stringify({ expo: { name: 'Example', slug: 'example', version: '2' } }));
|
||||
await runCiMap({ ...changedLeader.options, ...share('iphone') });
|
||||
const otherJavaScript = changedEas.builds[0].message;
|
||||
assert.notEqual(otherJavaScript, message, 'another commit of the app has another key');
|
||||
assert.notEqual(otherRun, message, 'another run has another key');
|
||||
const eas = { builds: [
|
||||
{ id: 'other-run', status: 'FINISHED', platform: 'IOS', message: otherRun },
|
||||
{ id: 'other-javascript', status: 'FINISHED', platform: 'IOS', message: otherJavaScript },
|
||||
{ id: 'other-platform', status: 'FINISHED', platform: 'ANDROID', message },
|
||||
{ id: 'not-the-key', status: 'FINISHED', platform: 'IOS', message: `${message} (edited)` },
|
||||
], lists: 0 };
|
||||
const follower = await fixture(t, { reuse: true, eas });
|
||||
const lines = [];
|
||||
const result = await runCiMap({ ...follower.options, ...share('duo-open'), progress: line => lines.push(line) });
|
||||
assert.equal(result.easBuildId, 'repacked-app', 'the follower repacked its own app');
|
||||
assert.equal(follower.operations().filter(operation => operation === 'workflow:run').length, 1);
|
||||
// One list every 15 s for three minutes, and the first at once.
|
||||
assert.ok(eas.lists >= 12 && eas.lists <= 13, `${eas.lists} lists`);
|
||||
assert.ok(lines.some(line => /no repack of this commit from iphone appeared within 3 minutes; repacking here/.test(line)), lines.join('\n'));
|
||||
});
|
||||
|
||||
test('capture.repack: local repacks on the runner and installs the app from it, with no upload', async t => {
|
||||
for (const reuse of [false, true]) {
|
||||
const f = await fixture(t, { repack: 'local', reuse, buildMetadata: true });
|
||||
|
||||
@@ -5,7 +5,7 @@ import { join } from "node:path";
|
||||
import test from "node:test";
|
||||
import { tsImport } from "tsx/esm/api";
|
||||
|
||||
const { DEFAULT_EXPLORE_CONFIG_PATH, assertExecutionMode, parseExploreConfig, readExploreConfig, validateExploreConfig, configPlatforms, configTargets, resolvePlatformConfig, resolveTargetConfig, withRunOverrides, captureRepack } =
|
||||
const { DEFAULT_EXPLORE_CONFIG_PATH, assertExecutionMode, parseExploreConfig, readExploreConfig, validateExploreConfig, configPlatforms, configTargets, resolvePlatformConfig, resolveTargetConfig, withRunOverrides, captureRepack, hostedRepackPeers } =
|
||||
await tsImport("../../src/config/explore-config.ts", import.meta.url);
|
||||
|
||||
const SOURCE = `app:
|
||||
@@ -363,6 +363,25 @@ test("target ids and entries are validated", () => {
|
||||
assert.equal(validateExploreConfig({ ...base(), platforms, capture: { maxSessions: 1 } }).capture.maxSessions, 1);
|
||||
});
|
||||
|
||||
test("the targets that repack one app on EAS are its repack peers, led by the first in config order", () => {
|
||||
const config = validateExploreConfig({ ...base(), targets: {
|
||||
iphone: { platform: "ios" },
|
||||
"duo-closed": { platform: "ios", device: "iPhone Duo", pose: "closed" },
|
||||
"duo-open": { platform: "ios", device: "iPhone Duo", pose: "open" },
|
||||
local: { platform: "ios", simulator: "local" },
|
||||
android: { platform: "android", bundleId: "com.example.app", easProfile: "explore-apk" },
|
||||
} });
|
||||
const peers = (id, overrides) => hostedRepackPeers(config, withRunOverrides(resolveTargetConfig(config, { target: id }), overrides ?? {}), overrides);
|
||||
assert.deepEqual(peers("duo-open"), ["iphone", "duo-closed", "duo-open"]);
|
||||
assert.deepEqual(peers("android"), ["android"], "a target no other one shares an app with has only itself");
|
||||
assert.deepEqual(peers("local"), [], "a repack on this machine is shared with nobody");
|
||||
// A run that repacks on the runner (--repack local) shares nothing; one that repacks on EAS includes the local-simulator target.
|
||||
assert.deepEqual(peers("iphone", { repack: "local" }), []);
|
||||
assert.deepEqual(peers("iphone", { repack: "eas" }), ["iphone", "duo-closed", "duo-open", "local"]);
|
||||
const flat = validateExploreConfig(base());
|
||||
assert.deepEqual(hostedRepackPeers(flat, resolveTargetConfig(flat)), ["ios"]);
|
||||
});
|
||||
|
||||
test("a target can choose its own controller and simulator over capture's", () => {
|
||||
const config = validateExploreConfig({ ...base(), capture: { controller: "argent", simulator: "local" }, targets: {
|
||||
duo: { platform: "ios", device: "iPhone Duo" },
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { hostedRepackBuildId, hostedRepackWorkflow } from '../../dist/capture/eas-build.js';
|
||||
import { chmod, mkdir, mkdtemp, rm, symlink, writeFile } from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { hostedRepackBuildId, hostedRepackRetries, hostedRepackShareKey, hostedRepackShareMarker, hostedRepackWorkflow, sharedRepackBuilds, stagedProjectDigest } from '../../dist/capture/eas-build.js';
|
||||
import { repackShareOption } from '../../dist/ci/pipeline.js';
|
||||
import { CiError } from '../../dist/shared/ci-errors.js';
|
||||
|
||||
test('the generated repack workflow pins the source build, skips VCS and points Metro at the staged observer', () => {
|
||||
@@ -42,3 +46,75 @@ test('an exhausted build plan surfaces as EAS_PLAN_LIMIT_REACHED even from the h
|
||||
test('non-JSON output from eas workflow:run is reported with the CLI tail', () => {
|
||||
assert.throws(() => hostedRepackBuildId('', 'Error: Not logged in\n', 'ios'), error => error instanceof CiError && error.code === 'EAS_REPACK_FAILED' && /Not logged in/.test(error.message));
|
||||
});
|
||||
|
||||
const failed = (job, stderr = '') => { try { hostedRepackBuildId(run(job), stderr, 'ios'); } catch (error) { return error; } assert.fail('the repack did not fail'); };
|
||||
|
||||
test('a repack EAS failed around is repacked twice more, an unexplained one once, and one the app or a person ended never', () => {
|
||||
// brentvatne/euxy#176 (review run 39506405687): the upload step's report of "Turtle build is not in progress".
|
||||
const upload = failed({ key: 'repack', status: 'FAILURE', turtleBuild: { status: 'ERRORED', error: { errorCode: 'UNKNOWN_CUSTOM_BUILD_ERROR', message: 'Failed to upload application archive.' } } });
|
||||
assert.equal(upload.details.failure, 'infrastructure'); assert.equal(hostedRepackRetries(upload), 2);
|
||||
assert.equal(hostedRepackRetries(failed({ key: 'repack', status: 'FAILURE', turtleBuild: { error: { errorCode: 'EAS_BUILD_TIMEOUT_ERROR', message: 'Build timed out.' } } })), 2);
|
||||
assert.equal(hostedRepackRetries(failed({ key: 'repack', status: 'ERRORED' })), 1, 'a run that says nothing is tried once more');
|
||||
assert.equal(hostedRepackRetries(failed({ key: 'repack', status: 'FAILURE', turtleBuild: { error: { errorCode: 'UNKNOWN_CUSTOM_BUILD_ERROR', message: 'Unknown custom build error. See logs for more information.' } } })), 1);
|
||||
for (const message of ['Build step "Repack app" failed', 'Unable to resolve module ./missing from app/index.tsx', 'SyntaxError: app/home.tsx: Unexpected token (4:2)']) {
|
||||
const error = failed({ key: 'repack', status: 'FAILURE', turtleBuild: { error: { errorCode: 'UNKNOWN_CUSTOM_BUILD_ERROR', message } } });
|
||||
assert.equal(error.details.failure, 'app', message); assert.equal(hostedRepackRetries(error), 0, message);
|
||||
}
|
||||
assert.equal(hostedRepackRetries(failed({ key: 'repack', status: 'CANCELED' })), 0, 'a run someone cancelled is not started again');
|
||||
// Before a run starts: a refused token is not retried, a failed upload of the staged copy is.
|
||||
assert.throws(() => hostedRepackBuildId('', 'Error: Not logged in\n', 'ios'), error => hostedRepackRetries(error) === 0);
|
||||
assert.throws(() => hostedRepackBuildId('', 'Failed to upload project sources.\nError: socket hang up\n', 'ios'), error => hostedRepackRetries(error) === 2);
|
||||
assert.equal(hostedRepackRetries(new Error('spawnSync eas ETIMEDOUT')), 0, 'a repack that ran out its 30 minutes is not repeated');
|
||||
// The run's own link names it, as eas workflow:run --json reports it.
|
||||
const linked = failed({ key: 'repack', status: 'ERRORED' });
|
||||
assert.equal(linked.details.logs, undefined);
|
||||
assert.throws(() => hostedRepackBuildId(JSON.stringify({ id: 'run-2', url: 'https://expo.dev/accounts/acme/projects/example/workflows/run-2', jobs: [{ key: 'repack', status: 'ERRORED' }] }), '', 'ios'),
|
||||
error => error.details.logs === 'https://expo.dev/accounts/acme/projects/example/workflows/run-2');
|
||||
});
|
||||
|
||||
test('the staged digest changes with any file, mode or link, and the share key with every input', async t => {
|
||||
const root = await mkdtemp(join(tmpdir(), 'explore-staged-digest-'));
|
||||
t.after(() => rm(root, { recursive: true, force: true }));
|
||||
await mkdir(join(root, 'app'));
|
||||
await writeFile(join(root, 'app', 'index.js'), 'export default 1;\n');
|
||||
await writeFile(join(root, 'package.json'), '{}\n');
|
||||
await symlink('app/index.js', join(root, 'entry.js'));
|
||||
const digests = [await stagedProjectDigest(root)];
|
||||
assert.equal(await stagedProjectDigest(root), digests[0], 'the digest is stable');
|
||||
await writeFile(join(root, 'app', 'index.js'), 'export default 2;\n'); digests.push(await stagedProjectDigest(root));
|
||||
await chmod(join(root, 'package.json'), 0o755); digests.push(await stagedProjectDigest(root));
|
||||
await rm(join(root, 'entry.js')); await symlink('package.json', join(root, 'entry.js')); digests.push(await stagedProjectDigest(root));
|
||||
await mkdir(join(root, 'empty')); digests.push(await stagedProjectDigest(root));
|
||||
assert.equal(new Set(digests).size, digests.length);
|
||||
const input = { scope: 'acme/example#39506405687', platform: 'ios', nativeBuildId: 'a81d5d80', easProfile: 'explore', environment: 'preview', project: digests[0] };
|
||||
const key = hostedRepackShareKey(input);
|
||||
assert.match(key, /^[0-9a-f]{32}$/);
|
||||
for (const [name, other] of Object.entries({ scope: 'acme/example#1', platform: 'android', nativeBuildId: 'b0000000', easProfile: 'other', environment: 'production', project: digests[1] })) {
|
||||
assert.notEqual(hostedRepackShareKey({ ...input, [name]: other }), key, name);
|
||||
}
|
||||
});
|
||||
|
||||
test("only a build whose message ends with this key, for this platform, is another job's repack", () => {
|
||||
const marker = hostedRepackShareMarker('0'.repeat(32));
|
||||
const message = `expo-explore ios capture: route observer repack ${marker}`;
|
||||
const listed = JSON.stringify([
|
||||
{ id: 'shared', status: 'IN_PROGRESS', platform: 'IOS', message },
|
||||
{ id: 'android', status: 'FINISHED', platform: 'ANDROID', message },
|
||||
{ id: 'other-key', status: 'FINISHED', platform: 'IOS', message: `expo-explore ios capture: route observer repack ${hostedRepackShareMarker('1'.repeat(32))}` },
|
||||
{ id: 'suffixed', status: 'FINISHED', platform: 'IOS', message: `${message} and more` },
|
||||
{ id: '../escape', status: 'FINISHED', platform: 'IOS', message },
|
||||
{ id: 'no-message', status: 'FINISHED', platform: 'IOS' },
|
||||
]);
|
||||
assert.deepEqual(sharedRepackBuilds(listed, marker, 'ios'), [{ id: 'shared', status: 'IN_PROGRESS' }]);
|
||||
assert.equal(sharedRepackBuilds('Error: GraphQL request failed', marker, 'ios'), undefined);
|
||||
});
|
||||
|
||||
test("a target shares its repacks only with its own GitHub run's jobs, and only when another target repacks the same app", () => {
|
||||
const config = { target: { id: 'duo-open', platform: 'ios', label: 'Duo open' }, capture: {} };
|
||||
const environment = { GITHUB_RUN_ID: '39506405687', GITHUB_REPOSITORY: 'brentvatne/euxy' };
|
||||
assert.deepEqual(repackShareOption(config, environment, ['iphone', 'duo-open']), { repackShare: { scope: 'brentvatne/euxy#39506405687', leader: 'iphone', target: 'duo-open' } });
|
||||
assert.deepEqual(repackShareOption(config, environment, ['duo-open']), {}, 'a single target behaves as before');
|
||||
assert.deepEqual(repackShareOption(config, environment, undefined), {});
|
||||
assert.deepEqual(repackShareOption(config, {}, ['iphone', 'duo-open']), {}, 'outside GitHub Actions there is no run to share with');
|
||||
assert.deepEqual(repackShareOption({ ...config, capture: { repack: 'local' } }, environment, ['iphone', 'duo-open']), {});
|
||||
});
|
||||
Reference in new issue
Block a user