mirror of
https://github.com/expo/explore.git
synced 2026-11-15 17:32:23 -10:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
601aabfba4 | ||
|
|
8273d032f0 | ||
|
|
29ce5dea3c | ||
|
|
90d5d52dab | ||
|
|
7fa07d2cc0 | ||
|
|
6ad0d89c1f | ||
|
|
fbe12fea58 | ||
|
|
ac30f4d691 |
No files matched your search
@@ -16,6 +16,34 @@ Write "No visible change" if there is none.
|
||||
| --- | --- |
|
||||
| | |
|
||||
|
||||
## Code examples
|
||||
|
||||
<!--
|
||||
Required for any change to how Explore is used or what it writes: a CLI command or flag,
|
||||
config.yaml, a workflow template, a file format (a replay or flows file, report JSON), or a
|
||||
public type. Show it in use as a reader would write it: the command with its flags, the config
|
||||
or file it reads, and what it prints or writes, trimmed to the lines that matter. When existing
|
||||
usage changes, show it before and after.
|
||||
Write "No change to usage" if there is none.
|
||||
-->
|
||||
|
||||
```sh
|
||||
|
||||
```
|
||||
|
||||
## Try it
|
||||
|
||||
<!--
|
||||
Optional, but recommended: something a reviewer can open or run to see the change for themselves.
|
||||
- A Viewer change: the Viewer preview comment on this PR links a live build. Name the report,
|
||||
screen and steps to look at.
|
||||
- A capture or report change: a hosted report from a run of this branch (explore:binary,
|
||||
explore:session or capture with --upload), or an app pull request whose review ran this branch.
|
||||
- Otherwise: the commands that run it from a checkout of this branch, for example
|
||||
`npm ci && npm run build`, then `node dist/cli.js <command>`, with any app or file it needs.
|
||||
Write "Nothing to try" if there is nothing a reviewer could run.
|
||||
-->
|
||||
|
||||
## Testing
|
||||
|
||||
<!-- What you ran and what you checked by hand. -->
|
||||
+4
-4
@@ -153,10 +153,10 @@ Each new start logs the failed run's link and reason, for example `the hosted EA
|
||||
|
||||
1. `hostedRepackPeers` lists, in config order, the targets 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.
|
||||
- A capture gets a `RepackShare` when it has two or more peers and `GITHUB_RUN_ID`, `GITHUB_RUN_ATTEMPT` and `GITHUB_REPOSITORY` are set. Its scope is the run attempt, its leader is the first peer, and its rank is its place among the peers.
|
||||
- A single target, a local review, `capture.repack: local`, and a native build this job made itself behave as before. Nobody else's key can match a native build this job made.
|
||||
2. The build to repack is the newest finished build with the fingerprint that Explore did not repack itself (`existingBuild`, from 20 builds). If repacks carry their source's fingerprint, every job still picks the same build.
|
||||
- A single target, a local review, `capture.repack: local`, and a native build this job made itself behave as before. The repack of a native build this job made carries no key, so it is never shared.
|
||||
2. The build to repack is the newest finished build with the fingerprint that Explore did not repack itself (`existingBuild`, from 20 builds), else the newest repack. On a project that reviews often, the 20 are all repacks (euxy's 50 most recent `explore` builds were), so jobs that start minutes apart can pick different builds; the key below names the native code, not the build, so they still share.
|
||||
3. Once the copy is staged, the capture takes a key (`hostedRepackShareKey`) from:
|
||||
- the run attempt, the platform and the native build id;
|
||||
- the run attempt, the platform and the native fingerprint;
|
||||
- the EAS profile and environment name;
|
||||
- a snapshot of the environment's variables: `eas env:list --format long` for the project and the account, which names each variable with its value (masked when sensitive or secret) and when it was last updated;
|
||||
- the Explore release;
|
||||
@@ -168,7 +168,7 @@ Each new start logs the failed run's link and reason, for example `the hosted EA
|
||||
6. When the repack it follows fails, is cancelled or loses the key, the capture looks for another with the same key for 60 s, staggered the same way, before it repacks itself. That catches the leader's retry, which starts at once (#176).
|
||||
7. It also repacks itself, with the retries above, when nothing appears in its wait, or when EAS fails to answer three times in a row. Looking stops while the budget still has 5 minutes for a repack of its own. A followed repack that does not finish within the budget fails the target. No capture waits on a job that cannot answer, and none waits past its budget.
|
||||
|
||||
Only a build whose marker is this capture's own key is used, and every input to the key is what this capture would itself have uploaded and built with. So two jobs share a repack only when their uploads, native build, profile, environment variables and Explore release are the same, in the same run attempt. The run attempt is in the scope, and a review's or a first attempt's repacks are never used by another run or attempt. That covers the baseline workflow, whose artifacts later reviews reuse, and "Re-run failed jobs" after an `EXPO_PUBLIC_*` value was fixed, which rebundles with the new value.
|
||||
Only a build whose marker is this capture's own key is used, and every input to the key but one is what this capture would itself have uploaded and built with. So two jobs share a repack only when their uploads, native fingerprint, profile, environment variables and Explore release are the same, in the same run attempt. The one input that is not this capture's own is the source build: a follower runs the leader's repack of the build the leader found, which has the same fingerprint as its own but may be another build of it. `existingBuild` already treats builds of one fingerprint as interchangeable; what a repack keeps from its source beyond the native code the fingerprint covers (its Info.plist, and the toolchain it was built with) can differ between such builds. The run attempt is in the scope, and a review's or a first attempt's repacks are never used by another run or attempt. That covers the baseline workflow, whose artifacts later reviews reuse, and "Re-run failed jobs" after an `EXPO_PUBLIC_*` value was fixed, which rebundles with the new value.
|
||||
|
||||
What the key does not protect against: every input to it is public or predictable, and the pull request's head code runs in the capture job with `EXPO_TOKEN` (`app.config.*` under `eas config` and `eas fingerprint:generate`, and the app's build code on EAS). Head code could therefore make a build whose message carries the base side's marker, and base captures of the same run attempt in other matrix jobs would install it. That is within the trust the capture already gives EAS: the same credentials could publish a simulator build with a reused fingerprint, which every capture already reuses by fingerprint (the `build` stage above), and head code in one job can already tamper with that job's own base side on the runner. The run attempt in the scope keeps such a build out of every other run, including the baseline. Requiring the build's `initiatingActor` to be this job's own credentials would not exclude head code, which runs with the same token. Explore cannot tell offline which actor EAS records for a workflow's repack build, so it does not check it.
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ npx @expo/explore capture --base v1.3.0 --head v1.4.0 --scope all --upload
|
||||
- Your checkout, index and branches are never touched. Your uncommitted changes, untracked files included, are reviewed as `eas build` would upload them; `--committed`, or `cli.requireCommit: true` in `eas.json`, leaves them out.
|
||||
- Installs run without credential environment variables, which keeps tokens out of reach of a registry a commit's `.npmrc` names; that is not a sandbox. A registry that needs `${NPM_TOKEN}` in the project's `.npmrc` must be authenticated in your own `~/.npmrc`.
|
||||
- Captures are cached in `~/.cache/expo-explore`, so the same base is not captured twice (`--no-cache` skips it); a capture unused for 30 days goes, and the cache stays under 2 GB. Ctrl+C stops the run's simulator sessions and local devices; when a run is stopped harder than that, the next local run stops what it left running.
|
||||
- Like a CI review, it builds on EAS (reusing a matching build) and, unless it captures on a local simulator, runs EAS Simulator sessions: expect several minutes and EAS usage.
|
||||
- Like a CI review, it builds on EAS (reusing a matching build) and, unless it captures on a local simulator, runs EAS Simulator sessions: expect several minutes and EAS usage. A terminal that supports [OSC 7501](https://superlogical.com/rex/docs/build/program-status) shows whether the run is working, done or failed while you are in another tab; `explore:binary`, `report:upload` and `doctor --capture` report it too.
|
||||
- Saved runs take up to 2 GB in all, the oldest going first. `reports add <report.zip>` keeps a report you downloaded, such as a PR's `explore-review` artifact.
|
||||
|
||||
</details>
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@expo/explore",
|
||||
"version": "0.22.0",
|
||||
"version": "0.23.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@expo/explore",
|
||||
"version": "0.22.0",
|
||||
"version": "0.23.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@expo/repack-app": "0.10.1",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@expo/explore",
|
||||
"version": "0.22.0",
|
||||
"version": "0.23.0",
|
||||
"description": "Source-driven mobile app maps, deterministic CI capture, and visual reviews",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
|
||||
+17
-10
@@ -119,9 +119,9 @@ const EXPLORE_REPACK_MESSAGE = /^expo-explore (?:ios|android) capture: route obs
|
||||
|
||||
/**
|
||||
* The finished build to repack from `eas build:list --fingerprint-hash`: the newest one Explore did not repack itself,
|
||||
* else the newest. A repack keeps its source build's native code, and may carry its fingerprint; preferring the build
|
||||
* it came from has every job of a run pick the same one, which a shared repack's key needs (RepackShare), instead of a
|
||||
* repack another job finished a minute earlier.
|
||||
* else the newest. A repack keeps its source build's native code and carries its fingerprint, so on a project that
|
||||
* reviews often every listed build is a repack, and this is the newest of them; jobs that look minutes apart can get
|
||||
* different ones. A shared repack is keyed by the fingerprint, not by this build (hostedRepackShareKey).
|
||||
*/
|
||||
export function existingBuild(stdout: string): EasBuildDescriptor | undefined {
|
||||
const value = parseJson(stdout, "eas build:list");
|
||||
@@ -712,13 +712,18 @@ export async function stagedProjectDigest(root: string): Promise<string> {
|
||||
|
||||
/**
|
||||
* 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, EAS environment (by name and by a
|
||||
* snapshot of its variables) and Explore release, in the same run attempt.
|
||||
* when each would have uploaded the same bytes onto the same native code, for the same profile, EAS environment (by name
|
||||
* and by a snapshot of its variables) and Explore release, in the same run attempt.
|
||||
*
|
||||
* The native code is named by its fingerprint, not by the build a job found to repack: the build lookup returns the
|
||||
* newest build with that fingerprint, which is often an earlier repack, and it moves as repacks finish. In
|
||||
* brentvatne/euxy#179 (review run 40042718931) a target that started late found the repack the others had just made,
|
||||
* so its key matched none; it waited 3 minutes for a repack it could not find, then made another.
|
||||
*/
|
||||
export function hostedRepackShareKey(input: { scope: string; platform: "ios" | "android"; nativeBuildId: string; easProfile: string;
|
||||
export function hostedRepackShareKey(input: { scope: string; platform: "ios" | "android"; fingerprint: string; easProfile: string;
|
||||
environment: string; environmentVariables: string; project: string }): string {
|
||||
return createHash("sha256").update(JSON.stringify({ contract: "expo-explore.repack-share.v2", explore: EXPLORE_VERSION, scope: input.scope,
|
||||
platform: input.platform, nativeBuildId: input.nativeBuildId, easProfile: input.easProfile, environment: input.environment,
|
||||
return createHash("sha256").update(JSON.stringify({ contract: "expo-explore.repack-share.v3", explore: EXPLORE_VERSION, scope: input.scope,
|
||||
platform: input.platform, fingerprint: input.fingerprint, easProfile: input.easProfile, environment: input.environment,
|
||||
environmentVariables: input.environmentVariables, project: input.project })).digest("hex").slice(0, 32);
|
||||
}
|
||||
|
||||
@@ -870,6 +875,8 @@ async function prepareHostedRepack(options: {
|
||||
easCommand: string;
|
||||
project: string;
|
||||
nativeBuildId: string;
|
||||
/** The native fingerprint of that build, which keys a shared repack (hostedRepackShareKey). */
|
||||
fingerprint: string;
|
||||
easProfile: string;
|
||||
repackProfile: RepackProfile;
|
||||
easEnvironment: NodeJS.ProcessEnv;
|
||||
@@ -930,7 +937,7 @@ async function prepareHostedRepack(options: {
|
||||
if (variables === undefined) options.say(`EAS did not list the ${environment} environment's variables; repacking here without sharing the repack`);
|
||||
else {
|
||||
// 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, nativeBuildId: options.nativeBuildId,
|
||||
const marker = hostedRepackShareMarker(hostedRepackShareKey({ scope: options.share.scope, platform, fingerprint: options.fingerprint,
|
||||
easProfile: options.easProfile, environment, environmentVariables: variables, project: await stagedProjectDigest(staged) }));
|
||||
const shared = await options.timings.measure("repack-share-wait", () => sharedHostedRepack({ share: options.share!, marker, platform, say: options.say, clock,
|
||||
list: () => eas(["build:list", "--platform", platform, "--limit", String(SHARED_REPACK_LIST_LIMIT), "--json", "--non-interactive"], 2 * 60_000).stdout,
|
||||
@@ -1012,7 +1019,7 @@ export async function prepareExactSourceBuild(options: {
|
||||
if ((options.repack ?? "eas") === "eas") {
|
||||
if (!options.easProfile) throw new Error("The hosted repack needs the capture build profile name.");
|
||||
const hosted = await prepareHostedRepack({ platform, runner: options.runner, easCommand: options.easCommand, project: options.project,
|
||||
nativeBuildId: options.nativeBuildId, easProfile: options.easProfile, repackProfile: options.repackProfile,
|
||||
nativeBuildId: options.nativeBuildId, fingerprint: options.fingerprint, easProfile: options.easProfile, repackProfile: options.repackProfile,
|
||||
easEnvironment: options.easEnvironment, restrictedEnvironment: options.repackEnvironment, provider: providers[0]!,
|
||||
parameterKeys: captureObserverParameterKeys(options.routes), root, share: options.share, say: options.progress ?? (() => undefined),
|
||||
timings: options.timings ?? silentTimings, onBlocking: options.onBlocking,
|
||||
|
||||
+1
-1
@@ -608,7 +608,7 @@ async function executeCiMap(options: CiMapOptions, setStage: (stage: string) =>
|
||||
type BuiltApp = { fingerprint: string; nativeEasBuildId: string | null; easBuildId: string | null; app?: string; reused: boolean; version?: string; buildNumber?: string };
|
||||
// What a hosted repack waits with and reports through: one deadline from the moment the session starts beside it, for
|
||||
// the wait for another job's repack and every repack of its own. The repack is shared with this run's other matrix
|
||||
// jobs only when it repacks a build EAS already had: a native build this job made is its own, so nobody else's key matches it.
|
||||
// jobs only when it repacks a build EAS already had: a native build this job made is its own, so its repack carries no key and is never shared.
|
||||
const repackWaits = (shared: boolean) => ({ ...(shared ? { share: options.repackShare } : {}), progress: say, now: options.now, sleep: options.sleep, timings, onBlocking: options.onBlocking,
|
||||
signal: options.signal, deadline: (options.now ?? Date.now)() + HOSTED_REPACK_BUDGET_MS });
|
||||
// `repacking` tells the captures sharing this build that their sessions can start too (sharedBuild).
|
||||
|
||||
+11
@@ -5,6 +5,7 @@ import { resolve } from "node:path";
|
||||
import { ExploreStore } from "./map/store.js";
|
||||
import { QUERY_CONTRACT } from "./types.js";
|
||||
import { EXPLORE_VERSION } from "./shared/package-paths.js";
|
||||
import { enableProgramStatus, lastReportedStatus, reportFinished, reportStatus } from "./shared/program-status.js";
|
||||
import { isTargetId } from "./config/explore-config.js";
|
||||
import { command, resultContract, argumentError, validateCommandArguments, flag, has, setStore } from "./cli/args.js";
|
||||
import { help } from "./cli/help.js";
|
||||
@@ -69,6 +70,11 @@ const handlers: Record<string, () => Promise<void> | void> = {
|
||||
/** Commands people type at a terminal; everything else answers agents and scripts in JSON. */
|
||||
const HUMAN_COMMANDS = new Set(["setup", "doctor", "view", "help", "explore:binary", "explore:session", "report:upload", "reports"]);
|
||||
|
||||
/** Commands that run for minutes, so the terminal hears whether they are working, done or failed (see program-status). */
|
||||
const LONG_COMMANDS = new Set(["capture:review", "capture:baseline", "explore:binary", "explore:session", "report:upload"]);
|
||||
/** Stopped with Ctrl+C at the terminal: the person already knows, so the status is cleared rather than left as an error. */
|
||||
const CANCELLED = new Set(["LOCAL_REVIEW_INTERRUPTED", "CAPTURE_CANCELLED"]);
|
||||
|
||||
function version(): void {
|
||||
console.log(EXPLORE_VERSION);
|
||||
}
|
||||
@@ -77,10 +83,15 @@ try {
|
||||
const handler = handlers[command];
|
||||
if (!handler) argumentError(`Unknown command: ${command}`, undefined, "Run expo-explore help and choose a supported command.");
|
||||
validateCommandArguments();
|
||||
// Not with --json: under a pseudo-terminal the sequence would share a line with the JSON an agent parses.
|
||||
if ((LONG_COMMANDS.has(command) || (command === "doctor" && has("capture"))) && !has("json")) { enableProgramStatus(); reportStatus("working"); }
|
||||
const workspace = resolve(process.cwd(), flag("dir") ?? ".explore");
|
||||
setStore(new ExploreStore(workspace));
|
||||
await handler();
|
||||
if (lastReportedStatus() === "working") reportFinished();
|
||||
} catch (error) {
|
||||
if (error instanceof CiError && CANCELLED.has(error.code)) reportStatus("clear");
|
||||
else reportStatus("error", { message: error instanceof Error ? error.message : String(error) });
|
||||
if (command.startsWith("capture:") || command.startsWith("source:") || command.startsWith("ci:") || command.startsWith("config:")) {
|
||||
// The failure comment names the target from this: a capture, report or publication of one matrix target.
|
||||
const target = (() => { try { return flag("target"); } catch { return undefined; } })();
|
||||
|
||||
@@ -8,6 +8,7 @@ import { keepReports } from "./report-commands.js";
|
||||
import { warnIgnoredExpiry } from "../config/explore-config.js";
|
||||
import { argumentError, flag, flags, has, nonNegativeInteger, oneOf, output, positional, positiveInteger } from "./args.js";
|
||||
import { readReplayPlan } from "../binary/replay.js";
|
||||
import { reportFinished, reportStatus } from "../shared/program-status.js";
|
||||
|
||||
|
||||
/** `--alias NAME` plus a fixed token from EXPLORE_PREVIEW_TOKEN: the hosted link stays the same from one run to the next (validated by the deploy). */
|
||||
@@ -37,7 +38,7 @@ export async function exploreBinary(): Promise<void> {
|
||||
const upload = simulator === "local" ? has("upload") : !has("no-upload");
|
||||
const port = flag("port") === undefined ? undefined : nonNegativeInteger("port");
|
||||
const started = Date.now();
|
||||
const say = (message: string) => { process.stderr.write(`[explore ${Math.round((Date.now() - started) / 1000)}s] ${message}\n`); };
|
||||
const say = (message: string) => { reportStatus("working", { message }); process.stderr.write(`[explore ${Math.round((Date.now() - started) / 1000)}s] ${message}\n`); };
|
||||
const allowDestructive = flags("allow-destructive").flatMap(value => value.split(",")).map(value => value.trim()).filter(Boolean);
|
||||
if (upload) await assertHostingExport();
|
||||
const result = await runBinaryExploration({
|
||||
@@ -77,6 +78,7 @@ export async function exploreBinary(): Promise<void> {
|
||||
if (simulator === "eas" || hosted || has("no-open")) { console.log(`Next: ${summary.next.join(" | ")}`); return; }
|
||||
const viewer = await startViewerServer({ root: outputDirectory, ...(port === undefined ? {} : { port }) });
|
||||
console.log(`Viewer: ${viewer.url} (Ctrl+C to stop)`);
|
||||
reportFinished();
|
||||
openViewerInBrowser(viewer.url);
|
||||
await waitForViewerShutdown(viewer);
|
||||
}
|
||||
@@ -100,7 +102,7 @@ export async function exploreSession(): Promise<void> {
|
||||
const controller = flag("controller") === undefined ? undefined : oneOf("controller", ["agent-device", "argent"] as const);
|
||||
const port = flag("port") === undefined ? undefined : nonNegativeInteger("port");
|
||||
const started = Date.now();
|
||||
const say = (message: string) => { process.stderr.write(`[explore ${Math.round((Date.now() - started) / 1000)}s] ${message}\n`); };
|
||||
const say = (message: string) => { reportStatus("working", { message }); process.stderr.write(`[explore ${Math.round((Date.now() - started) / 1000)}s] ${message}\n`); };
|
||||
const allowDestructive = flags("allow-destructive").flatMap(value => value.split(",")).map(value => value.trim()).filter(Boolean);
|
||||
const envFile = await defaultSessionEnvFile(flag("env-file"));
|
||||
if (has("upload")) await assertHostingExport();
|
||||
@@ -140,6 +142,7 @@ export async function exploreSession(): Promise<void> {
|
||||
if (hosted || has("no-open")) { console.log(`Next: ${summary.next.join(" | ")}`); return; }
|
||||
const viewer = await startViewerServer({ root: outputDirectory, ...(port === undefined ? {} : { port }) });
|
||||
console.log(`Viewer: ${viewer.url} (Ctrl+C to stop)`);
|
||||
reportFinished();
|
||||
openViewerInBrowser(viewer.url);
|
||||
await waitForViewerShutdown(viewer);
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import { help } from "./help.js";
|
||||
import { CiError } from "../shared/ci-errors.js";
|
||||
import { cleanupAfterCapture, findOptionalBaseline, resolveCompareRefs, resolvePullRequest, writeCaptureOutputs, writeStepOutputs } from "../ci/workflow-steps.js";
|
||||
import { stderrProgress } from "../shared/progress.js";
|
||||
import { reportFinished, reportStatus } from "../shared/program-status.js";
|
||||
import { appendTimingsSummary, timingsPathFor } from "../shared/timings.js";
|
||||
import { maxParallelTargets } from "../ci/session-plan.js";
|
||||
|
||||
@@ -47,10 +48,12 @@ Fix the problems in steps 1–5 before a capture check.`);
|
||||
}
|
||||
if (!has("yes")) {
|
||||
if (!process.stdin.isTTY || has("json")) argumentError("A capture check starts an EAS build and simulator session; pass --yes to confirm.", "yes");
|
||||
reportStatus("blocked", { kind: "question", message: "Start a capture check on EAS?" });
|
||||
const terminal = createInterface({ input: process.stdin, output: process.stderr });
|
||||
const answer = await terminal.question(`This builds the app on EAS and runs an EAS Simulator session (EAS usage applies${report.mode === "agent" ? "; agent mode also uses your model API key or local claude/codex login" : ""}). Continue? (yes/no) `);
|
||||
terminal.close();
|
||||
if (!/^(y|yes)$/i.test(answer.trim())) return;
|
||||
if (!/^(y|yes)$/i.test(answer.trim())) { reportStatus("clear"); return; }
|
||||
reportStatus("working");
|
||||
}
|
||||
let result: Awaited<ReturnType<typeof runCaptureCheck>>;
|
||||
try {
|
||||
@@ -310,6 +313,8 @@ async function localReview(): Promise<void> {
|
||||
}
|
||||
// A target that failed outright has no report; the others still open, save and upload, and the command exits 1.
|
||||
if (result.failures.length) process.exitCode = 1;
|
||||
// The terminal keeps this record after the run, so it names what failed rather than what was open.
|
||||
const finished = () => reportFinished(result.failures.length ? `No report for ${result.failures.map(({ target }) => target.id).join(", ")}` : undefined);
|
||||
const summary = { ok: result.failures.length === 0, runId: result.runId, base: result.base, head: result.head,
|
||||
...(result.failures.length ? { failures: result.failures.map(({ target, error }) => ({ target: target.id, code: error.code, message: error.message })) } : {}),
|
||||
reports: result.reports.map(({ platform, target, directory, zip, changes, device }) => ({ platform, target: target.id, label: target.label, directory, zip,
|
||||
@@ -331,15 +336,18 @@ async function localReview(): Promise<void> {
|
||||
if (has("json")) output({ ...summary, ...(copied ? {} : { reports: summary.reports.map(({ directory: _directory, zip: _zip, ...report }) => report) }),
|
||||
url: hosted.previewUrl, expiresAt: hosted.expiresAt });
|
||||
else console.log(`Report: ${hosted.previewUrl}${hosted.expiresAt ? ` (until ${hosted.expiresAt.slice(0, 10)})` : ""}`);
|
||||
finished();
|
||||
return;
|
||||
}
|
||||
if (has("json") || has("no-open")) {
|
||||
if (has("json")) output(summary);
|
||||
else for (const report of result.reports) console.log(`${report.target.id}: ${report.zip}`);
|
||||
finished();
|
||||
return;
|
||||
}
|
||||
const server = await startLocalReportServer({ reports: zips, ...(has("port") ? { port: nonNegativeInteger("port") } : {}) });
|
||||
console.log(`Viewer: ${server.url} (Ctrl+C to stop)`);
|
||||
finished();
|
||||
if (saved) console.log(`Saved as ${saved.id}: expo-explore reports reopens it, and reports upload ${saved.id} hosts it.`);
|
||||
openViewerInBrowser(server.url);
|
||||
await new Promise<void>(done => { process.once("SIGINT", () => done()); process.once("SIGTERM", () => done()); });
|
||||
|
||||
@@ -57,7 +57,7 @@ export type CiErrorRenderOptions = { secrets?: readonly string[] };
|
||||
|
||||
/** The values of every variable that names a secret (a token, secret, password or API key), to redact from what Explore writes. */
|
||||
export function environmentSecrets(environment: NodeJS.ProcessEnv): string[] {
|
||||
return Object.entries(environment).filter(([key]) => /(?:TOKEN|SECRET|PASSWORD|API_KEY)/i.test(key)).flatMap(([, value]) => value ? [value] : []);
|
||||
return Object.entries(environment).filter(([key]) => /(?:TOKEN|SECRET|PASSWORD|API_KEY|PRIVATE_KEY)/i.test(key)).flatMap(([, value]) => value ? [value] : []);
|
||||
}
|
||||
|
||||
/** Redacts secret values, bearer and provider tokens, credentials in URLs, and signed-URL parameters from any text Explore writes. */
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
import { environmentSecrets, redactSecrets } from "./ci-errors.js";
|
||||
|
||||
/**
|
||||
* Tells the terminal what a long command is doing with OSC 7501
|
||||
* (https://superlogical.com/rex/docs/build/program-status), so a tab left in the background can show that a review is
|
||||
* working, waiting on an answer, done or failed. Only an interactive stderr gets the sequence; a terminal that does not
|
||||
* know it ignores it, as it does any unknown OSC (ECMA-48 §8.3.89). The spec's feature query is not sent: reading its
|
||||
* reply would put stdin in raw mode under the command's own prompts.
|
||||
*
|
||||
* The terminal drops a `working` or `blocked` record when the process exits and keeps `done` and `error`, so an exit
|
||||
* without a final report (a second Ctrl+C) leaves nothing behind.
|
||||
*/
|
||||
export type ProgramState = "working" | "blocked" | "done" | "error" | "clear";
|
||||
export type BlockedKind = "permission" | "question" | "auth";
|
||||
|
||||
const APP = "expo-explore";
|
||||
/** The spec allows 2048 bytes of decoded `msg`; 512 code points stay under it in any script. */
|
||||
const MESSAGE_LIMIT = 512;
|
||||
|
||||
let write: ((text: string) => void) | undefined;
|
||||
let last: ProgramState | undefined;
|
||||
|
||||
/**
|
||||
* A message is redacted as stderr's diagnostics are, since a kept record outlives the process. Redacting comes first,
|
||||
* so truncation cannot leave a partial secret the patterns no longer match.
|
||||
*/
|
||||
export function programStatusSequence(state: ProgramState, details: { message?: string; kind?: BlockedKind } = {}, environment: NodeJS.ProcessEnv = process.env): string {
|
||||
const pairs = [`state=${state}`, `app=${APP}`];
|
||||
if (state === "blocked" && details.kind) pairs.push(`kind=${details.kind}`);
|
||||
const redacted = details.message === undefined ? undefined : redactSecrets(details.message, environmentSecrets(environment));
|
||||
// The terminal discards a report whose message holds control characters, and shows one line.
|
||||
const message = redacted?.replace(/[\p{Cc}\u2028\u2029]+/gu, " ").trim();
|
||||
// By code points, so an emoji is not split; the first cut keeps Array.from off a long git stderr.
|
||||
const shown = message && Array.from(message.slice(0, MESSAGE_LIMIT * 2)).slice(0, MESSAGE_LIMIT).join("");
|
||||
if (shown) pairs.push(`msg=${Buffer.from(shown, "utf8").toString("base64")}`);
|
||||
return `\x1b]7501;${pairs.join(":")}\x1b\\`;
|
||||
}
|
||||
|
||||
/** CI is left out even under a pseudo-terminal (Buildkite, `docker run -t`), whose log would keep the raw sequences. */
|
||||
export function terminalReportsStatus(stream: { isTTY?: boolean } = process.stderr, environment: NodeJS.ProcessEnv = process.env): boolean {
|
||||
return stream.isTTY === true && environment.TERM !== "dumb" && !environment.CI;
|
||||
}
|
||||
|
||||
/** Turns reports on for this process when stderr is a terminal; until then `reportStatus` writes nothing. */
|
||||
export function enableProgramStatus(options: { write?: (text: string) => void } = {}): void {
|
||||
if (options.write) write = options.write;
|
||||
else if (terminalReportsStatus()) write = text => { process.stderr.write(text); };
|
||||
}
|
||||
|
||||
export function reportStatus(state: ProgramState, details: { message?: string; kind?: BlockedKind } = {}): void {
|
||||
last = state;
|
||||
write?.(programStatusSequence(state, details));
|
||||
}
|
||||
|
||||
/** `done`, or `error` when the command has already set a failing exit code (a review with a failed target). */
|
||||
export function reportFinished(message?: string): void {
|
||||
reportStatus(process.exitCode ? "error" : "done", message ? { message } : {});
|
||||
}
|
||||
|
||||
/** The last state reported, so the command's end reports `done` only when nothing more specific came before it. */
|
||||
export function lastReportedStatus(): ProgramState | undefined {
|
||||
return last;
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
import { reportStatus } from "./program-status.js";
|
||||
|
||||
/**
|
||||
* One line per capture step on stderr, so a CI log or a terminal shows what Explore is doing while
|
||||
* a build or a simulator session runs for minutes. Messages carry plan, route, and EAS identifiers
|
||||
* only; never setup text, which can hold app-test secrets.
|
||||
* a build or a simulator session runs for minutes; the same line becomes the terminal's status
|
||||
* message (see program-status). Messages carry plan, route, and EAS identifiers only; never setup
|
||||
* text, which can hold app-test secrets.
|
||||
*/
|
||||
export type Progress = (message: string) => void;
|
||||
|
||||
@@ -12,6 +15,7 @@ export function stderrProgress(options: { now?: () => number; write?: (text: str
|
||||
const write = options.write ?? (text => { process.stderr.write(text); });
|
||||
const started = now();
|
||||
return message => {
|
||||
reportStatus("working", { message });
|
||||
const seconds = Math.max(0, Math.floor((now() - started) / 1000));
|
||||
const elapsed = `${String(Math.floor(seconds / 60)).padStart(2, "0")}:${String(seconds % 60).padStart(2, "0")}`;
|
||||
write(`[explore ${elapsed}] ${message}\n`);
|
||||
|
||||
@@ -243,7 +243,7 @@ async function fixture(t, settings = {}) {
|
||||
if (listed === null) throw new Error('eas env:list exited with status 1: GraphQL request failed.');
|
||||
return { stdout: listed ?? 'Environment: preview\nNo variables found for this environment.\n', stderr: '' };
|
||||
}
|
||||
if (command === 'build:list') return json(settings.reuse ? [{ id: 'native-build', ...buildMetadata }] : []);
|
||||
if (command === 'build:list') return json(settings.reuse ? [{ id: settings.reusable ?? '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: '' }; }
|
||||
if (command === 'build:download') {
|
||||
@@ -2146,6 +2146,22 @@ test('two jobs of one run attempt that repack the same app share one hosted repa
|
||||
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 that starts after the shared repack finished, and finds that repack as its build to repack, joins it', async t => {
|
||||
const eas = easBuilds();
|
||||
const leader = await fixture(t, { reuse: true, eas });
|
||||
await runCiMap({ ...leader.options, ...share('iphone') });
|
||||
eas.builds[0].status = 'FINISHED';
|
||||
// The newest build with the fingerprint is now the leader's repack (brentvatne/euxy#179, review run 40042718931): a
|
||||
// key made from the build each job found would differ, and this target would wait, then repack a repack itself.
|
||||
const { f, lines, run } = await follow(t, eas, { reusable: 'repacked-app' });
|
||||
const result = await run;
|
||||
assert.equal(runs(f), 0, 'the late target does not repack');
|
||||
assert.equal(shareLists(f), 1, 'its first look finds the finished repack');
|
||||
assert.deepEqual(downloaded(f), ['repacked-app']);
|
||||
assert.equal(result.easBuildId, 'repacked-app');
|
||||
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 follows the leader's repack by its id while it runs, even once newer builds push it off the list", async t => {
|
||||
const message = await leaderMessage(t);
|
||||
const eas = easBuilds([{ id: 'leader-repack', status: 'IN_QUEUE', platform: 'IOS', message }]);
|
||||
|
||||
@@ -129,13 +129,17 @@ test('the staged digest changes with any file, mode or link, and the share key w
|
||||
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.1', platform: 'ios', nativeBuildId: 'a81d5d80', easProfile: 'explore', environment: 'preview', environmentVariables: 'a'.repeat(64), project: digests[0] };
|
||||
const input = { scope: 'acme/example#39506405687.1', platform: 'ios', fingerprint: 'ea9bf84e1a5b0900000ba7c1e6b1c7e272e1306f', easProfile: 'explore', environment: 'preview', environmentVariables: 'a'.repeat(64), project: digests[0] };
|
||||
const key = hostedRepackShareKey(input);
|
||||
assert.match(key, /^[0-9a-f]{32}$/);
|
||||
for (const [name, other] of Object.entries({ scope: 'acme/example#39506405687.2', platform: 'android', nativeBuildId: 'b0000000', easProfile: 'other', environment: 'production',
|
||||
for (const [name, other] of Object.entries({ scope: 'acme/example#39506405687.2', platform: 'android', fingerprint: 'fc2446ef4e6d0000000000000000000000000000', easProfile: 'other', environment: 'production',
|
||||
environmentVariables: 'b'.repeat(64), project: digests[1] })) {
|
||||
assert.notEqual(hostedRepackShareKey({ ...input, [name]: other }), key, name);
|
||||
}
|
||||
// Which build a job found to repack does not matter, only its native code: a target that starts after the others'
|
||||
// repack finished finds that repack as its newest build of the fingerprint (brentvatne/euxy#179), and must still
|
||||
// join it rather than make another.
|
||||
assert.equal(hostedRepackShareKey({ ...input, nativeBuildId: '7f6b592a' }), hostedRepackShareKey({ ...input, nativeBuildId: '2ebcfd8d' }));
|
||||
});
|
||||
|
||||
test("only a build whose message ends with this key, for this platform, is another job's repack", () => {
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { enableProgramStatus, lastReportedStatus, programStatusSequence, reportFinished, reportStatus, terminalReportsStatus } from "../../dist/shared/program-status.js";
|
||||
import { stderrProgress } from "../../dist/shared/progress.js";
|
||||
|
||||
const decode = sequence => {
|
||||
assert.match(sequence, /^\x1b\]7501;.*\x1b\\$/);
|
||||
return Object.fromEntries(sequence.slice(7, -2).split(":").map(pair => [pair.slice(0, pair.indexOf("=")), pair.slice(pair.indexOf("=") + 1)]));
|
||||
};
|
||||
const message = sequence => {
|
||||
const { msg } = decode(sequence);
|
||||
return msg === undefined ? undefined : Buffer.from(msg, "base64").toString("utf8");
|
||||
};
|
||||
|
||||
test("a report names the state and the app, and carries its message as base64", () => {
|
||||
assert.equal(programStatusSequence("done"), "\x1b]7501;state=done:app=expo-explore\x1b\\");
|
||||
const pairs = decode(programStatusSequence("working", { message: "capturing Home — ✓" }));
|
||||
assert.equal(pairs.state, "working");
|
||||
assert.equal(Buffer.from(pairs.msg, "base64").toString("utf8"), "capturing Home — ✓");
|
||||
});
|
||||
|
||||
test("only a blocked report carries its kind", () => {
|
||||
assert.equal(decode(programStatusSequence("blocked", { kind: "question" })).kind, "question");
|
||||
assert.equal(decode(programStatusSequence("working", { kind: "question" })).kind, undefined);
|
||||
});
|
||||
|
||||
test("a message becomes one line without control characters, within the spec's size", () => {
|
||||
const pairs = decode(programStatusSequence("error", { message: "build failed\n\x1b[31mexit 1\x1b[0m\t" }));
|
||||
assert.equal(Buffer.from(pairs.msg, "base64").toString("utf8"), "build failed [31mexit 1 [0m");
|
||||
assert.ok(Buffer.from(decode(programStatusSequence("working", { message: "あ".repeat(5000) })).msg, "base64").byteLength <= 2048);
|
||||
// Cut by code points: an emoji at the limit is kept whole or dropped, never halved.
|
||||
assert.equal(message(programStatusSequence("working", { message: `${"a".repeat(511)}😀😀` })), `${"a".repeat(511)}😀`);
|
||||
assert.ok(Buffer.from(decode(programStatusSequence("working", { message: "😀".repeat(5000) })).msg, "base64").byteLength <= 2048);
|
||||
assert.equal(decode(programStatusSequence("working", { message: " \n " })).msg, undefined);
|
||||
assert.ok(programStatusSequence("working", { message: "x".repeat(5000) }).length <= 4096);
|
||||
});
|
||||
|
||||
test("a message is redacted as stderr's diagnostics are", () => {
|
||||
const environment = { EXPO_TOKEN: "expo-secret-value", SIGNING_PRIVATE_KEY: "private-key-value" };
|
||||
const text = message(programStatusSequence("error", {
|
||||
message: "git failed: https://user:[email protected]/o/r expo-secret-value private-key-value",
|
||||
}, environment));
|
||||
assert.doesNotMatch(text, /ghp_|expo-secret-value|private-key-value/);
|
||||
assert.match(text, /\[REDACTED\]/);
|
||||
});
|
||||
|
||||
test("only an interactive stderr that is not a dumb terminal or CI gets reports", () => {
|
||||
assert.equal(terminalReportsStatus({ isTTY: true }, { TERM: "xterm-ghostty" }), true);
|
||||
assert.equal(terminalReportsStatus({ isTTY: true }, { TERM: "dumb" }), false);
|
||||
assert.equal(terminalReportsStatus({ isTTY: true }, { TERM: "xterm-256color", CI: "true" }), false);
|
||||
assert.equal(terminalReportsStatus({ isTTY: false }, {}), false);
|
||||
assert.equal(terminalReportsStatus({}, {}), false);
|
||||
});
|
||||
|
||||
test("progress lines become the working status once reports are on", () => {
|
||||
const written = [];
|
||||
stderrProgress({ write: () => {} })("before");
|
||||
enableProgramStatus({ write: text => written.push(text) });
|
||||
stderrProgress({ write: () => {} })("planning routes");
|
||||
reportStatus("done");
|
||||
assert.deepEqual(written.map(decode).map(({ state, msg }) => [state, msg && Buffer.from(msg, "base64").toString("utf8")]),
|
||||
[["working", "planning routes"], ["done", undefined]]);
|
||||
assert.equal(lastReportedStatus(), "done");
|
||||
});
|
||||
|
||||
test("a finished command reports done, or error once it has set a failing exit code", t => {
|
||||
const written = [];
|
||||
enableProgramStatus({ write: text => written.push(text) });
|
||||
const exitCode = process.exitCode;
|
||||
t.after(() => { process.exitCode = exitCode; });
|
||||
process.exitCode = undefined;
|
||||
reportFinished();
|
||||
process.exitCode = 1;
|
||||
reportFinished("No report for ios");
|
||||
assert.deepEqual(written.map(text => [decode(text).state, message(text)]), [["done", undefined], ["error", "No report for ios"]]);
|
||||
});
|
||||
@@ -9,6 +9,9 @@
|
||||
background: var(--canvas-minimap-background);
|
||||
box-shadow: var(--shadow-md);
|
||||
contain: layout paint;
|
||||
/* iOS WebKit lifts the minimap above freshly composited cards (a screenshot's reveal fade, as a
|
||||
fast pan mounts them) a frame late, so they flicker over it. Its own layer keeps it on top. */
|
||||
will-change: transform;
|
||||
pointer-events: none;
|
||||
view-transition-name: canvas-minimap;
|
||||
--canvas-minimap-background: color-mix(in srgb, var(--surface) 94%, transparent);
|
||||
|
||||
@@ -316,9 +316,13 @@
|
||||
.compare-stage.mode-flip .compare-frame-wrap,
|
||||
.sidebar-review-stage.mode-flip .compare-frame-wrap,
|
||||
.sidebar-review-stage.mode-split.landscape .compare-frame-wrap { display: flex; justify-content: center; }
|
||||
/* The width is spelled out, not left to aspect-ratio: WebKit sizes a flex item by its height + aspect-ratio box's
|
||||
available width rather than its ratio width, so Split's two sides stayed half the stage each and each frame sat at
|
||||
the left of its side, off centre under its name (seen on a folded iPhone Duo). */
|
||||
.compare-frame {
|
||||
position: relative;
|
||||
display: block;
|
||||
width: calc(var(--compare-frame-height) * var(--compare-aspect));
|
||||
height: var(--compare-frame-height);
|
||||
aspect-ratio: var(--compare-aspect);
|
||||
overflow: hidden;
|
||||
|
||||
Reference in new issue
Block a user