mirror of
https://github.com/expo/explore.git
synced 2026-11-15 17:32:23 -10:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cc2008236 | ||
|
|
32518833f6 |
No files matched your search
@@ -294,8 +294,9 @@ export async function reservePort(port: number, environment: NodeJS.ProcessEnv):
|
||||
const abandoned = async (path: string) => {
|
||||
const info = await stat(path).catch(() => undefined);
|
||||
if (!info) return false;
|
||||
const owner = await readFile(join(path, "owner"), "utf8").catch(() => undefined);
|
||||
return owner === undefined ? Date.now() - info.mtimeMs > 10_000 : !processAlive(Number(owner));
|
||||
// writeFile creates the owner file before it writes the pid, so an empty one is a holder mid-write too.
|
||||
const owner = await readFile(join(path, "owner"), "utf8").catch(() => "");
|
||||
return owner === "" ? Date.now() - info.mtimeMs > 10_000 : !processAlive(Number(owner));
|
||||
};
|
||||
for (;;) {
|
||||
try { await mkdir(mutex); await writeFile(join(mutex, "owner"), String(process.pid)); break; }
|
||||
|
||||
+2
-1
@@ -268,7 +268,8 @@ export async function runCiReview(options: {
|
||||
const { projects, output, config, environment, state, assertCurrentHead, postComment } = options;
|
||||
const progress = options.progress ?? silentProgress;
|
||||
// The controllers are fetched before any EAS work, so a blocked download fails before a session is paid for. agent-device
|
||||
// also compares the screenshots. An injected runner (tests) runs no real controller.
|
||||
// also compares the screenshots. An injected runner (tests) stands in for the controllers' calls, but not for that
|
||||
// comparison: it still runs the real agent-device, which fetches itself on first use.
|
||||
if (!options.runner) await prefetchControllers(config, environment, progress);
|
||||
const pr = options.presentation;
|
||||
const now = options.now ?? Date.now;
|
||||
|
||||
@@ -272,6 +272,8 @@ test("choosing the report file opens it with the link's selection and keeps Modi
|
||||
await expect(page.locator("html")).toHaveAttribute("data-theme", "light");
|
||||
await page.getByRole("button", { name: "Screens", exact: true }).click();
|
||||
const screenshot = page.locator(".screens-page img[data-screenshot-src]").first();
|
||||
// The placeholder is the screenshot's size too, so wait for the screenshot itself.
|
||||
await expect(screenshot).toHaveAttribute("data-screenshot-state", "ready");
|
||||
await expect.poll(() => screenshot.evaluate(image => image.naturalWidth)).toBe(32);
|
||||
const screenshotUrl = await screenshot.getAttribute("src");
|
||||
assert.match(page.url(), /#\/screens/);
|
||||
@@ -328,6 +330,8 @@ test("a reload and a later per-screen link reopen the dropped report from the br
|
||||
await expect(page.getByText("Greeting changed from Hello to Welcome", { exact: true })).toBeVisible();
|
||||
await page.getByRole("button", { name: "Screens", exact: true }).click();
|
||||
const screenshot = page.locator(".screens-page img[data-screenshot-src]").first();
|
||||
// The placeholder is the screenshot's size too, so wait for the screenshot itself.
|
||||
await expect(screenshot).toHaveAttribute("data-screenshot-state", "ready");
|
||||
await expect.poll(() => screenshot.evaluate(image => image.naturalWidth)).toBe(32);
|
||||
// Comment links to one screen carry the same run identity, so they open without a new drop.
|
||||
await page.goto(`${origin}/r?${new URLSearchParams(identity)}&screen=home&inspect=diff`);
|
||||
|
||||
@@ -27,7 +27,10 @@ export async function createBrowserVite(test, options) {
|
||||
});
|
||||
const requested = options.server;
|
||||
const port = requested?.port === 0 ? await freePort(requested.host ?? "127.0.0.1") : requested?.port;
|
||||
server = await createServer({ ...options, cacheDir,
|
||||
// A cold cacheDir optimizes dependencies as the page asks for them; one found late (the JSX dev runtime, which
|
||||
// esbuild's JSX imports) makes Vite reload the page, dropping whatever the test has done in it.
|
||||
const optimizeDeps = { ...options.optimizeDeps, include: [...(options.optimizeDeps?.include ?? []), "react/jsx-dev-runtime"] };
|
||||
server = await createServer({ ...options, cacheDir, optimizeDeps,
|
||||
...(requested ? { server: { ...requested, port, ...(requested.port === 0 ? { strictPort: true } : {}) } } : {}) });
|
||||
return server;
|
||||
}
|
||||
@@ -8,11 +8,13 @@ import { createHash } from 'node:crypto';
|
||||
import { PNG } from 'pngjs';
|
||||
import { AGENT_DEVICE_VERSION } from '../../dist/capture/run.js';
|
||||
import { CAPTURE_OBSERVER_IDENTIFIER } from '../../dist/capture/observer.js';
|
||||
import { controllerCacheRoot, ensureController } from '../../dist/shared/controller-cache.js';
|
||||
import { writeCaptureObserverPackages } from './capture-observer-fixture.mjs';
|
||||
|
||||
/**
|
||||
* In-process public CI fixture: a git project with base/head commits plus mocked `eas`, `repack-app`,
|
||||
* `agent-device` and GitHub transports, so a review runs end to end without network or a simulator.
|
||||
* `agent-device` and GitHub transports, so a review runs end to end without a simulator, and without network once the
|
||||
* real agent-device that compares screenshots is cached.
|
||||
*/
|
||||
|
||||
export const PROJECT_ID = '00000000-0000-4000-8000-000000000001';
|
||||
@@ -27,6 +29,17 @@ export const usageReceipt = (overrides = {}) => ({ provider: 'anthropic', model:
|
||||
totals: { inputTokens: 100, outputTokens: 20, cacheReadInputTokens: 40, estimatedCostUsd: 0.012 },
|
||||
models: [{ model: 'fixture-model', inputTokens: 100, outputTokens: 20, cacheReadInputTokens: 40, estimatedCostUsd: 0.012, costBasis: 'list' }],
|
||||
...overrides });
|
||||
|
||||
/**
|
||||
* The review's screenshot comparison runs the real agent-device, which fetches itself on first use. The fixture fetches
|
||||
* it once, with retries, into the machine's controller cache, so a review never downloads it mid-run.
|
||||
*/
|
||||
const CONTROLLER_CACHE = controllerCacheRoot(process.env);
|
||||
for (let attempt = 1; ; attempt++) {
|
||||
try { await ensureController('agent-device', { environment: { ...process.env, EXPLORE_CONTROLLER_CACHE: CONTROLLER_CACHE } }); break; }
|
||||
catch (error) { if (attempt === 3) throw error; await new Promise(resolve => setTimeout(resolve, attempt * 2_000)); }
|
||||
}
|
||||
|
||||
export async function readUsage(output) {
|
||||
const path = join(output, 'agent-usage.jsonl');
|
||||
assert.equal((await stat(path)).mode & 0o777, 0o600, 'usage receipts are private artifacts');
|
||||
@@ -103,7 +116,7 @@ const Navigation=createStaticNavigation(Root); export default function App(){ret
|
||||
const pr = { repositoryId: '123', repository: 'acme/example', number: 7, title: 'Source capture integration', url: 'https://github.com/acme/example/pull/7',
|
||||
base: { ref: 'main', sha: baseSha }, head: { ref: 'feature', sha: headSha } };
|
||||
const pullRequestPath = join(root, 'pull-request.json'); await writeFile(pullRequestPath, JSON.stringify(pr));
|
||||
const environment = { PATH: process.env.PATH, HOME: root, RUNNER_TEMP: root, EXPO_TOKEN: 'test-expo-secret', GITHUB_TOKEN: 'test-github-secret',
|
||||
const environment = { PATH: process.env.PATH, HOME: root, RUNNER_TEMP: root, EXPLORE_CONTROLLER_CACHE: CONTROLLER_CACHE, EXPO_TOKEN: 'test-expo-secret', GITHUB_TOKEN: 'test-github-secret',
|
||||
GITHUB_RUN_ID: '1234', GITHUB_RUN_ATTEMPT: '1', GITHUB_REPOSITORY: pr.repository, TOOLS_COMMIT: 'c'.repeat(40), EXPLORE_VIEWER_ORIGIN: 'https://viewer.example' };
|
||||
const requests = []; const comments = []; const sessions = new Map(); let currentSession; const idleDevice = { path: '/', scheme: 'light' }; let sessionCounter = 0; let repackedSha; let openFailed = false;
|
||||
const identity = (session) => ({ session: 'expo-explore-runtime', appBundleId: config.app.bundleId,
|
||||
@@ -206,7 +219,7 @@ const Navigation=createStaticNavigation(Root); export default function App(){ret
|
||||
] });
|
||||
}
|
||||
if (command === 'settings') { if (request.args[1] === 'appearance') device.scheme = request.args[2]; return ok({ setting: request.args[1], value: request.args[2] }); }
|
||||
if (command === 'screenshot') { const color = createHash('sha256').update(`${device.path}:${device.scheme}:${device.path === '/home' ? device.build : 'unchanged-source'}`).digest(); const data = Buffer.alloc(16 * 24 * 4); for (let i = 0; i < data.length; i += 4) { data[i] = color[0]; data[i + 1] = color[1]; data[i + 2] = color[2]; data[i + 3] = 255; } writeFileSync(request.args[1], PNG.sync.write({ width: 16, height: 24, data })); return ok({ path: request.args[1] }); }
|
||||
if (command === 'screenshot') { const color = createHash('sha256').update(`${device.path}:${device.scheme}:${device.path === '/home' ? device.build : 'unchanged-source'}`).digest(); /* Hashed colours can land within the diff threshold, so /home's red channel keeps the base build apart from any other. */ if (device.path === '/home') color[0] = device.build?.endsWith(baseSha) ? 0 : 255; const data = Buffer.alloc(16 * 24 * 4); for (let i = 0; i < data.length; i += 4) { data[i] = color[0]; data[i + 1] = color[1]; data[i + 2] = color[2]; data[i + 3] = 255; } writeFileSync(request.args[1], PNG.sync.write({ width: 16, height: 24, data })); return ok({ path: request.args[1] }); }
|
||||
}
|
||||
throw new Error(`Unexpected mocked command: ${request.command} ${request.args.join(' ')}`);
|
||||
};
|
||||
|
||||
@@ -145,7 +145,8 @@ async function fixture(t, settings = {}) {
|
||||
if (request.args[1]?.includes('server start')) {
|
||||
const port = 4100 + serverStarts++;
|
||||
writeFileSync(request.environment.EXPLORE_ARGENT_SERVER_LOG, ` (or: argent link --host 127.0.0.1 --port ${port} --token abc123)\n[t] Tools server listening on http://127.0.0.1:${port}\n`);
|
||||
return { stdout: `${4242 + serverStarts}\n`, stderr: '' };
|
||||
// A pid no process can have: stopping the server signals it for real.
|
||||
return { stdout: `${999_999_000 + serverStarts}\n`, stderr: '' };
|
||||
}
|
||||
return { stdout: '', stderr: '' };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user