MCPcopy Create free account
hub / github.com/cli/cli / main

Function main

evals/src/cleanup.ts:14–33  ·  view source on GitHub ↗
(argv = process.argv.slice(2))

Source from the content-addressed store, hash-verified

12
13/** Housekeeping outside vally eval: retrying a trial's cleanup, and finding trials that need it. */
14export async function main(argv = process.argv.slice(2)): Promise<void> {
15 if (argv[0] === "--unfinished" && argv[1]) {
16 const journals = await unfinishedJournals(resolve(argv[1]));
17 if (!journals.length) return;
18 console.error(`${journals.length} trial(s) have unfinished cleanup. Leftover resources can count toward account `
19 + "limits (event subscriptions do for 24 hours). If no other run is using them, clean up with:");
20 for (const path of journals) console.error(` evals/cleanup ${path}`);
21 return;
22 }
23 if (argv.length !== 1 || argv[0]!.startsWith("-")) throw new Error(usage);
24 const token = process.env.GH_EVAL_TOKEN;
25 if (!token?.trim()) throw new Error("GH_EVAL_TOKEN must be the same user token the trial ran with");
26 const path = await realpath(argv[0]!);
27 const request: typeof fetch = fetch;
28 const journal = await parseJournalFile(path);
29 const suite = Object.hasOwn(suites, journal.suite) ? suites[journal.suite] : undefined;
30 if (!suite) throw new Error(`The journal names an unknown suite: ${journal.suite}`);
31 await cleanupSuite(suite, journal, path, { token, fixtureToken: process.env.GH_EVAL_FIXTURE_TOKEN || token, request });
32 console.log("Resource cleanup complete.");
33}
34
35if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
36 main().catch(error => {

Callers 1

cleanup.tsFile · 0.70

Calls 4

unfinishedJournalsFunction · 0.85
parseJournalFileFunction · 0.85
cleanupSuiteFunction · 0.85
logMethod · 0.80

Tested by

no test coverage detected