@lizard-build/cli 4.0.94 → 4.0.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ import { Command } from "commander";
2
+ /** owner/name from a GitHub remote URL (https, ssh or git@), or null. */
3
+ export declare function repoFromRemote(url: string): string | null;
4
+ export declare function registerGha(program: Command): void;
@@ -0,0 +1,439 @@
1
+ import chalk from "chalk";
2
+ import { execFileSync } from "node:child_process";
3
+ import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
4
+ import path from "node:path";
5
+ import { api, APIError, getRequestToken } from "../lib/api.js";
6
+ import { fail, isJSONMode, printJSON, table, timeAgo } from "../lib/format.js";
7
+ // ── The repository ─────────────────────────────────────────────────────
8
+ const REPO_RE = /^[A-Za-z0-9-]{1,39}\/[A-Za-z0-9._-]{1,100}$/;
9
+ function git(args, cwd = process.cwd()) {
10
+ try {
11
+ return execFileSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
12
+ }
13
+ catch {
14
+ return null;
15
+ }
16
+ }
17
+ /** owner/name from a GitHub remote URL (https, ssh or git@), or null. */
18
+ export function repoFromRemote(url) {
19
+ const m = url.trim().match(/github\.com[:/]+([A-Za-z0-9-]{1,39})\/([A-Za-z0-9._-]{1,100}?)(?:\.git)?\/?$/);
20
+ return m ? `${m[1]}/${m[2]}` : null;
21
+ }
22
+ function resolveRepo(flag) {
23
+ const root = git(["rev-parse", "--show-toplevel"]);
24
+ if (flag) {
25
+ if (!REPO_RE.test(flag))
26
+ fail(`--repo must look like owner/name (got "${flag}")`, 1, "BAD_REPO");
27
+ // The local files are only this repository's when the checkout is that repository.
28
+ const here = root ? repoFromRemote(git(["remote", "get-url", "origin"], root) ?? "") : null;
29
+ return { repo: flag, root: here && here.toLowerCase() === flag.toLowerCase() ? root : null, fromFlag: true };
30
+ }
31
+ if (!root) {
32
+ fail("This isn't a git repository. Run `lizard gha` inside your repository, or pass --repo owner/name.", 1, "NOT_A_REPO");
33
+ }
34
+ const remotes = (git(["remote"], root) ?? "").split("\n").filter(Boolean);
35
+ const order = ["origin", ...remotes.filter((r) => r !== "origin")];
36
+ for (const r of order) {
37
+ const repo = repoFromRemote(git(["remote", "get-url", r], root) ?? "");
38
+ if (repo)
39
+ return { repo, root, fromFlag: false };
40
+ }
41
+ return fail("This repository has no GitHub remote. Push it to a GitHub organization first, or pass --repo owner/name.", 1, "NO_GITHUB_REMOTE");
42
+ }
43
+ /** A command to show, carrying --repo when the user gave one. */
44
+ function cmd(base, ctx) {
45
+ return ctx.fromFlag && base.startsWith("lizard gha") ? `${base} --repo ${ctx.repo}` : base;
46
+ }
47
+ function readWorkflows(root) {
48
+ const dir = path.join(root, ".github", "workflows");
49
+ if (!existsSync(dir))
50
+ return [];
51
+ return readdirSync(dir)
52
+ .filter((f) => /\.ya?ml$/.test(f))
53
+ .sort()
54
+ .slice(0, 50)
55
+ .map((f) => ({ path: `.github/workflows/${f}`, text: readFileSync(path.join(dir, f), "utf8") }));
56
+ }
57
+ /**
58
+ * Is this checkout behind GitHub with different workflow files there? Then the local files say
59
+ * nothing about what runs: GitHub runs what's on the branch. Fetches the branch's upstream first
60
+ * (10 s at most; offline just uses what was last fetched).
61
+ */
62
+ function outOfDate(root) {
63
+ const upstream = git(["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{upstream}"], root);
64
+ if (!upstream)
65
+ return null;
66
+ const [remote, ...rest] = upstream.split("/");
67
+ try {
68
+ execFileSync("git", ["fetch", "--quiet", remote, rest.join("/")], { cwd: root, stdio: "ignore", timeout: 10_000 });
69
+ }
70
+ catch { /* offline: compare with what we have */ }
71
+ const behind = Number(git(["rev-list", "--count", `HEAD..${upstream}`], root) ?? "0");
72
+ if (!behind)
73
+ return null;
74
+ try {
75
+ execFileSync("git", ["diff", "--quiet", "HEAD", upstream, "--", ".github/workflows"], { cwd: root, stdio: "ignore" });
76
+ return null; // same workflow files: the local ones are accurate
77
+ }
78
+ catch {
79
+ return { behind, upstream };
80
+ }
81
+ }
82
+ function workflowsUncommitted(root) {
83
+ const out = git(["status", "--porcelain", "--", ".github/workflows"], root);
84
+ return !!out && out.length > 0;
85
+ }
86
+ // ── Talking to the platform ────────────────────────────────────────────
87
+ async function getStatus(ctx) {
88
+ try {
89
+ const s = await api.get(`/api/gha/status?repo=${encodeURIComponent(ctx.repo)}`);
90
+ if (s.next.command)
91
+ s.next.command = cmd(s.next.command, ctx);
92
+ return s;
93
+ }
94
+ catch (e) {
95
+ if (e instanceof APIError && e.status === 401 && (getRequestToken() ?? "").startsWith("liz_")) {
96
+ fail("Setting up GitHub Actions needs your own login, not an API key. Run `lizard login` (or unset LIZARD_TOKEN) and try again.", 2, "API_KEY_NOT_ALLOWED");
97
+ }
98
+ if (e instanceof APIError && e.status === 403) {
99
+ fail("This API key is limited to a project or workspace, and GitHub Actions setup is account-wide. Run `lizard login` and try again.", 2, "SCOPED_KEY_NOT_ALLOWED");
100
+ }
101
+ throw e;
102
+ }
103
+ }
104
+ async function getPreview(files, opts) {
105
+ return api.post("/api/gha/preview", { files, size: opts.size, jobs: opts.jobs, cache: !!opts.cache, docker: !!opts.docker });
106
+ }
107
+ async function report(ctx) {
108
+ const s = await getStatus(ctx);
109
+ if (s.verdict !== "READY")
110
+ return s;
111
+ if (!ctx.root) {
112
+ // Another repository than this checkout: only the platform's side is known.
113
+ s.next = { actor: "agent", say: `${s.repo} is connected. Run this inside a checkout of ${s.repo} to move its workflows.`, command: "lizard gha migrate --dry-run" };
114
+ return s;
115
+ }
116
+ const stale = outOfDate(ctx.root);
117
+ if (stale) {
118
+ s.state = "CHECKOUT_OUT_OF_DATE";
119
+ s.verdict = "NOT_READY";
120
+ s.message = `${s.repo} is connected, but this checkout is ${stale.behind} commit${stale.behind === 1 ? "" : "s"} behind ${stale.upstream} and its workflow files differ, so they don't show what GitHub runs.`;
121
+ s.next = { actor: "agent", confirm: true, say: "Update this checkout first so its workflow files match GitHub (git pull), then check again.", command: `git pull && ${cmd("lizard gha", ctx)}` };
122
+ return s;
123
+ }
124
+ const files = readWorkflows(ctx.root);
125
+ if (!files.length) {
126
+ s.state = "NO_WORKFLOWS";
127
+ s.message = `${s.repo} is connected, but this checkout has no workflow files in .github/workflows.`;
128
+ s.next = { actor: "agent", say: "Add a GitHub Actions workflow with `runs-on: lizard-medium-ubuntu-2404` (or move an existing one here), then run `lizard gha` again.", command: cmd("lizard gha", ctx) };
129
+ return s;
130
+ }
131
+ const p = await getPreview(files, {});
132
+ const w = { toMove: [], onLizard: [], notMovable: [], unknownLabels: [], errors: [], uncommitted: workflowsUncommitted(ctx.root) };
133
+ for (const f of p.files) {
134
+ if (f.error)
135
+ w.errors.push({ file: f.path, error: f.error });
136
+ for (const m of f.moves)
137
+ w.toMove.push({ file: f.path, ...m });
138
+ for (const a of f.already)
139
+ w.onLizard.push({ file: f.path, ...a });
140
+ for (const k of f.kept)
141
+ w.notMovable.push({ file: f.path, ...k });
142
+ for (const u of f.unknownLabels)
143
+ w.unknownLabels.push({ file: f.path, ...u });
144
+ }
145
+ s.workflows = w;
146
+ if (w.unknownLabels.length) {
147
+ const u = w.unknownLabels[0];
148
+ s.state = "UNKNOWN_LABEL";
149
+ s.verdict = "NOT_READY";
150
+ s.message = `${u.file} asks for "${u.label}", which isn't a Lizard runner, so that job would wait forever.`;
151
+ s.next = { actor: "agent", say: `Change runs-on to one of: ${s.sizes.map((z) => z.label).join(", ")}. Or run \`lizard gha migrate\` to fix it for you.`, command: cmd("lizard gha migrate --dry-run", ctx) };
152
+ }
153
+ else if (w.toMove.length) {
154
+ s.state = "NEEDS_MIGRATION";
155
+ s.message = `${s.repo} is connected. ${w.toMove.length} job${w.toMove.length === 1 ? "" : "s"} still run${w.toMove.length === 1 ? "s" : ""} on GitHub's runners.`;
156
+ s.next = { actor: "agent", say: "Preview the change, then apply it. It only edits runs-on lines in .github/workflows; nothing on GitHub changes until you commit and push.", command: cmd("lizard gha migrate --dry-run", ctx) };
157
+ }
158
+ else if (w.onLizard.length && w.uncommitted) {
159
+ s.state = "NOT_PUSHED";
160
+ s.message = "The workflows here use Lizard runners, but the change isn't committed yet.";
161
+ s.next = { actor: "agent", say: `Commit and push the changes in .github/workflows (or open a pull request) the way you normally would: the next run uses Lizard runners. Afterwards, \`${cmd("lizard gha", ctx)}\` confirms the first job ran.` };
162
+ }
163
+ else if (w.onLizard.length && !s.recentJobs.length) {
164
+ s.state = "WAITING_FOR_FIRST_RUN";
165
+ s.message = "The workflows use Lizard runners. No job has run on Lizard yet.";
166
+ s.next = { actor: "agent", say: "Make sure the change is pushed to GitHub. Jobs show up here as soon as a workflow runs.", command: cmd("lizard gha jobs", ctx) };
167
+ }
168
+ else if (w.onLizard.length) {
169
+ const j = s.recentJobs[0];
170
+ s.state = "ACTIVE";
171
+ s.message = `${s.repo} runs on Lizard. Last job: ${j.job} (${j.conclusion ?? j.status}, ${timeAgo(j.createdAt)}).`;
172
+ s.next = { actor: "none", say: "All set: GitHub Actions jobs for this repository run on Lizard runners.", command: cmd("lizard gha jobs", ctx) };
173
+ }
174
+ else {
175
+ s.state = "NOTHING_TO_MOVE";
176
+ s.message = "None of this repository's jobs can move to Lizard runners (only Linux jobs on GitHub-hosted or sized runners can).";
177
+ s.next = { actor: "none", say: "Nothing to do. macOS, Windows and expression-based jobs stay where they are." };
178
+ }
179
+ return s;
180
+ }
181
+ // ── Printing ───────────────────────────────────────────────────────────
182
+ const VERDICT_TEXT = {
183
+ READY: chalk.green("✓ Ready"),
184
+ NOT_READY: chalk.yellow("● Not ready yet"),
185
+ BLOCKED: chalk.red("✗ Can't continue"),
186
+ };
187
+ const WHO = {
188
+ user: "What you need to do",
189
+ org_owner: "What an owner of the GitHub organization needs to do",
190
+ agent: "Next step",
191
+ none: "Status",
192
+ };
193
+ function money(n) {
194
+ return `$${n.toFixed(4).replace(/0+$/, "").replace(/\.$/, "")}/h`;
195
+ }
196
+ function printReport(r) {
197
+ const lines = [];
198
+ lines.push(chalk.bold(`GitHub Actions on Lizard · ${r.repo}`));
199
+ lines.push("");
200
+ lines.push(`${VERDICT_TEXT[r.verdict]}: ${r.message}`);
201
+ if (r.workflows) {
202
+ const w = r.workflows;
203
+ if (w.toMove.length) {
204
+ lines.push("");
205
+ lines.push(chalk.dim("Jobs that would move:"));
206
+ for (const m of w.toMove)
207
+ lines.push(` ${m.file} ${chalk.bold(m.job)} ${m.from ?? "?"} → ${chalk.cyan(m.to)}`);
208
+ }
209
+ if (w.onLizard.length && (r.state === "ACTIVE" || r.state === "WAITING_FOR_FIRST_RUN" || r.state === "NOT_PUSHED")) {
210
+ lines.push("");
211
+ lines.push(chalk.dim("On Lizard runners:"));
212
+ for (const a of w.onLizard)
213
+ lines.push(` ${a.file} ${chalk.bold(a.job)} ${chalk.cyan(a.label)}`);
214
+ }
215
+ if (w.notMovable.length) {
216
+ lines.push("");
217
+ lines.push(chalk.dim("Staying where they are:"));
218
+ for (const k of w.notMovable)
219
+ lines.push(chalk.dim(` ${k.file} ${k.job} (${k.runsOn ?? "no runs-on"}: ${k.reason})`));
220
+ }
221
+ for (const e of w.errors)
222
+ lines.push(chalk.yellow(` ${e.file}: ${e.error}`));
223
+ }
224
+ lines.push("");
225
+ lines.push(chalk.bold((r.next.confirm ? "Needs your OK" : WHO[r.next.actor]) + ":"));
226
+ lines.push(" " + r.next.say);
227
+ if (r.next.url)
228
+ lines.push(" " + chalk.cyan(r.next.url));
229
+ if (r.next.command && r.next.actor !== "none") {
230
+ lines.push("");
231
+ lines.push((r.next.confirm ? "If yes, run: " : r.next.url || r.next.actor === "user" || r.next.actor === "org_owner" ? "Then run: " : "Run: ") + chalk.cyan(r.next.command));
232
+ }
233
+ if (r.verdict === "READY" && r.sizes?.length && (r.state === "NEEDS_MIGRATION")) {
234
+ lines.push("");
235
+ lines.push(chalk.dim("Runner sizes (billed per second while a job runs): " + r.sizes.map((s) => `${s.name} ${s.vcpus} vCPU/${s.memoryGb} GB ${money(s.pricePerHour)}`).join(" · ")));
236
+ if (r.trial)
237
+ lines.push(chalk.dim("Your account hasn't paid yet, so only small runners are available until you add credit."));
238
+ }
239
+ console.log(lines.join("\n"));
240
+ }
241
+ /** For agents: one line saying how to act on `next`. */
242
+ function howToUse(n) {
243
+ if (n.confirm)
244
+ return "Ask the user first: show them next.say. Run next.command only if they agree.";
245
+ if (n.actor === "user" || n.actor === "org_owner") {
246
+ return "A person has to do this. Show the user next.say and next.url exactly as written, wait until they say it's done, then run next.command.";
247
+ }
248
+ if (n.actor === "agent" && n.command)
249
+ return "You can do this yourself: run next.command.";
250
+ if (n.actor === "agent")
251
+ return "You can do this yourself: next.say says what.";
252
+ return "Nothing left to do. Tell the user next.say.";
253
+ }
254
+ function jsonOut(r) {
255
+ printJSON({ ...r, howToUse: howToUse(r.next) });
256
+ }
257
+ function finish(r, requireReady) {
258
+ if (isJSONMode())
259
+ jsonOut(r);
260
+ else
261
+ printReport(r);
262
+ if (requireReady && r.verdict !== "READY")
263
+ process.exitCode = 1;
264
+ }
265
+ // ── Commands ───────────────────────────────────────────────────────────
266
+ function parseJobSizes(values) {
267
+ if (!values?.length)
268
+ return undefined;
269
+ const out = {};
270
+ for (const v of values) {
271
+ const m = v.match(/^([^=]+)=(small|medium|large)$/);
272
+ if (!m)
273
+ fail(`--job must look like build=large (got "${v}"). Sizes: small, medium, large.`, 1, "BAD_JOB_SIZE");
274
+ out[m[1]] = m[2];
275
+ }
276
+ return out;
277
+ }
278
+ export function registerGha(program) {
279
+ const gha = program
280
+ .command("gha")
281
+ .description("Run this repository's GitHub Actions jobs on Lizard runners: shows where setup stands and the one next step")
282
+ .option("--repo <owner/name>", "GitHub repository (default: this checkout's GitHub remote)")
283
+ .option("--require-ready", "Exit 1 unless the repository is ready (for CI)")
284
+ .addHelpText("after", `
285
+ How it works:
286
+ Run \`lizard gha\`, do the one thing it says, then run it again. It never waits:
287
+ steps that happen in a browser print a link and the command to run afterwards.
288
+
289
+ lizard gha where setup stands + the next step
290
+ lizard gha connect connect the GitHub organization to your Lizard account
291
+ lizard gha migrate switch runs-on in .github/workflows to Lizard runners
292
+ lizard gha jobs recent jobs on Lizard runners
293
+
294
+ Runners: lizard-small-ubuntu-2404 (2 vCPU), lizard-medium-ubuntu-2404 (4 vCPU),
295
+ lizard-large-ubuntu-2404 (8 vCPU), billed per second. GitHub organizations only.`)
296
+ .action(async (opts) => {
297
+ const ctx = resolveRepo(opts.repo);
298
+ finish(await report(ctx), !!opts.requireReady);
299
+ });
300
+ gha
301
+ .command("connect")
302
+ .description("Connect this repository's GitHub organization to your Lizard account (your account pays for its runners)")
303
+ .option("--repo <owner/name>", "GitHub repository (default: this checkout's GitHub remote)")
304
+ .action(async (opts, c) => {
305
+ const ctx = resolveRepo(opts.repo ?? c.parent?.opts().repo);
306
+ const before = await getStatus(ctx);
307
+ if (before.state === "NOT_CONNECTED" && before.installationId) {
308
+ try {
309
+ await api.post(`/api/gha/installations/${before.installationId}/connect`);
310
+ }
311
+ catch (e) {
312
+ if (!(e instanceof APIError))
313
+ throw e;
314
+ // The platform's reason, then where things stand.
315
+ if (!isJSONMode())
316
+ console.log(chalk.yellow(`Couldn't connect: ${e.message}`) + "\n");
317
+ }
318
+ finish(await report(ctx), false);
319
+ return;
320
+ }
321
+ // Already connected, or something else comes first: say what.
322
+ finish(await report(ctx), false);
323
+ });
324
+ gha
325
+ .command("migrate")
326
+ .description("Switch runs-on in this checkout's .github/workflows to Lizard runners (edits files only; commit and push to apply)")
327
+ .option("--repo <owner/name>", "GitHub repository (default: this checkout's GitHub remote)")
328
+ .option("--size <size>", "Runner size for every job that moves: small, medium or large (default: medium for GitHub's standard runners)")
329
+ .option("--job <job=size...>", "Size for one job, e.g. --job build=large (repeatable)")
330
+ .option("--cache", "Also use Lizard's cached checkout and cache actions (faster repeat runs)")
331
+ .option("--docker", "Also use Lizard's Docker build actions (layers stay cached between runs)")
332
+ .option("--dry-run", "Show what would change without writing anything")
333
+ .option("--force", "Edit the files even if the organization isn't set up yet")
334
+ .action(async (opts, c) => {
335
+ const ctx = resolveRepo(opts.repo ?? c.parent?.opts().repo);
336
+ if (opts.size && !["small", "medium", "large"].includes(opts.size))
337
+ fail("--size must be small, medium or large", 1, "BAD_SIZE");
338
+ if (!ctx.root)
339
+ fail(`Run this inside a checkout of ${ctx.repo}: it edits the workflow files on disk.`, 1, "NOT_IN_CHECKOUT");
340
+ const status = await getStatus(ctx);
341
+ if (status.verdict !== "READY" && !opts.force) {
342
+ // Jobs moved before the organization is ready would wait for a runner that never comes.
343
+ if (isJSONMode()) {
344
+ jsonOut({ ...status, message: `Not changing any files yet: ${status.message}` });
345
+ }
346
+ else {
347
+ console.log(chalk.yellow("Not changing any files yet") + chalk.dim(" — jobs moved now would wait for a runner that can't start.") + "\n");
348
+ printReport(status);
349
+ }
350
+ return;
351
+ }
352
+ const stale = opts.force ? null : outOfDate(ctx.root);
353
+ if (stale) {
354
+ fail(`This checkout is ${stale.behind} commit${stale.behind === 1 ? "" : "s"} behind ${stale.upstream} and its workflow files differ. Run \`git pull\` first, then \`lizard gha migrate\` again (or pass --force to edit these files anyway).`, 1, "CHECKOUT_OUT_OF_DATE");
355
+ }
356
+ const files = readWorkflows(ctx.root);
357
+ if (!files.length)
358
+ fail("No workflow files in .github/workflows.", 1, "NO_WORKFLOWS");
359
+ const p = await getPreview(files, { size: opts.size, jobs: parseJobSizes(opts.job), cache: opts.cache, docker: opts.docker });
360
+ const changed = p.files.filter((f) => f.changed && f.text);
361
+ if (!opts.dryRun)
362
+ for (const f of changed)
363
+ writeFileSync(path.join(ctx.root, f.path), f.text);
364
+ const moves = p.files.flatMap((f) => f.moves.map((m) => ({ file: f.path, ...m })));
365
+ const kept = p.files.flatMap((f) => f.kept.map((k) => ({ file: f.path, ...k })));
366
+ const errors = p.files.filter((f) => f.error).map((f) => ({ file: f.path, error: f.error }));
367
+ const next = !changed.length
368
+ ? { actor: "none", say: "Nothing needed changing.", command: cmd("lizard gha", ctx) }
369
+ : opts.dryRun
370
+ ? { actor: "agent", confirm: true, say: `This changes runs-on for ${moves.length} job${moves.length === 1 ? "" : "s"} (listed above) in your workflow files. Apply it?`, command: cmd(`lizard gha migrate${opts.size ? ` --size ${opts.size}` : ""}${(opts.job ?? []).map((j) => ` --job ${j}`).join("")}${opts.cache ? " --cache" : ""}${opts.docker ? " --docker" : ""}`, ctx) }
371
+ : { actor: "agent", say: `Updated ${changed.length === 1 ? "1 workflow file" : `${changed.length} workflow files`}. Commit and push ${changed.length === 1 ? "it" : "them"} (or open a pull request) the way you normally would: the next run uses Lizard runners. Afterwards, \`${cmd("lizard gha", ctx)}\` confirms the first job ran.` };
372
+ if (isJSONMode()) {
373
+ printJSON({
374
+ repo: ctx.repo, dryRun: !!opts.dryRun, filesChanged: changed.map((f) => f.path), moves, kept, errors,
375
+ trial: p.trial, next,
376
+ howToUse: howToUse(next),
377
+ });
378
+ return;
379
+ }
380
+ console.log(chalk.bold(opts.dryRun ? `Preview — nothing written (${ctx.repo})` : `Updated workflows (${ctx.repo})`));
381
+ console.log("");
382
+ if (moves.length) {
383
+ for (const m of moves)
384
+ console.log(` ${m.file} ${chalk.bold(m.job)} ${m.from ?? "?"} → ${chalk.cyan(m.to)}`);
385
+ }
386
+ else {
387
+ console.log(chalk.dim(" No jobs to move."));
388
+ }
389
+ if (kept.length) {
390
+ console.log("");
391
+ console.log(chalk.dim("Staying where they are:"));
392
+ for (const k of kept)
393
+ console.log(chalk.dim(` ${k.file} ${k.job} (${k.runsOn ?? "no runs-on"}: ${k.reason})`));
394
+ }
395
+ for (const e of errors)
396
+ console.log(chalk.yellow(` ${e.file}: ${e.error}`));
397
+ if (p.trial?.message)
398
+ console.log("\n" + chalk.yellow(p.trial.message));
399
+ console.log("");
400
+ console.log(chalk.bold(next.confirm ? "Needs your OK:" : "Next step:"));
401
+ console.log(" " + next.say);
402
+ if (next.command && next.actor !== "none")
403
+ console.log("\n" + (next.confirm ? "If yes, run: " : "Run: ") + chalk.cyan(next.command));
404
+ });
405
+ gha
406
+ .command("jobs")
407
+ .description("Recent GitHub Actions jobs that ran on Lizard runners for this repository")
408
+ .option("--repo <owner/name>", "GitHub repository (default: this checkout's GitHub remote)")
409
+ .option("--all", "Jobs of every repository you connected, not just this one")
410
+ .option("--limit <n>", "How many jobs (default 20)", "20")
411
+ .action(async (opts, c) => {
412
+ const repoFlag = opts.repo ?? c.parent?.opts().repo;
413
+ const ctx = opts.all && !repoFlag ? null : resolveRepo(repoFlag);
414
+ const limit = Math.min(200, Math.max(1, Number(opts.limit) || 20));
415
+ const { jobs } = await api.get(`/api/gha/jobs?limit=200`);
416
+ const mine = (ctx ? jobs.filter((j) => String(j.repo).toLowerCase() === ctx.repo.toLowerCase()) : jobs).slice(0, limit);
417
+ if (isJSONMode()) {
418
+ printJSON({
419
+ repo: ctx?.repo ?? null,
420
+ jobs: mine.map((j) => ({ id: j.id, repo: j.repo, workflow: j.workflow, job: j.job, status: j.status, conclusion: j.conclusion, branch: j.branch, url: j.url, runner: j.runner, createdAt: j.createdAt, finishedAt: j.finishedAt, error: j.vmError })),
421
+ ...(mine.length ? {} : { next: { actor: "agent", say: "No jobs on Lizard runners yet. Run `lizard gha` to see what's missing.", command: ctx ? cmd("lizard gha", ctx) : "lizard gha" } }),
422
+ });
423
+ return;
424
+ }
425
+ if (!mine.length) {
426
+ console.log(`No jobs on Lizard runners yet${ctx ? ` for ${ctx.repo}` : ""}. Run ${chalk.cyan(ctx ? cmd("lizard gha", ctx) : "lizard gha")} to see what's missing.`);
427
+ return;
428
+ }
429
+ table(["when", ...(ctx ? [] : ["repo"]), "workflow", "job", "result", "branch"], mine.map((j) => [
430
+ timeAgo(j.createdAt), ...(ctx ? [] : [j.repo]), j.workflow ?? "", j.job,
431
+ j.conclusion === "success" ? chalk.green("passed") : j.conclusion === "failure" ? chalk.red("failed") : j.conclusion ? j.conclusion : chalk.yellow(j.status),
432
+ j.branch ?? "",
433
+ ]));
434
+ const failedVm = mine.find((j) => j.vmError);
435
+ if (failedVm)
436
+ console.log("\n" + chalk.yellow(`A runner failed to start for ${failedVm.job}: ${failedVm.vmError}`));
437
+ });
438
+ }
439
+ //# sourceMappingURL=gha.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gha.js","sourceRoot":"","sources":["../../src/commands/gha.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAuC/E,0EAA0E;AAE1E,MAAM,OAAO,GAAG,6CAA6C,CAAC;AAE9D,SAAS,GAAG,CAAC,IAAc,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE;IAC9C,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1G,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,8EAA8E,CAAC,CAAC;IAC3G,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,C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AC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;YAC5J,CAAC,CAAC,MAAM,IAAI,EAAE;SACf,CAAC,CACH,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAI,QAAQ;YAAE,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,gCAAgC,QAAQ,CAAC,GAAG,KAAK,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACtH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -7,6 +7,19 @@ export declare function lifetimeLine(expiresAt: number | string | null | undefin
7
7
  /** What to do with a sandbox you just made, as aligned lines with its id filled in. */
8
8
  export declare function sandboxNextSteps(id: string): string;
9
9
  export declare function registerSandbox(program: Command): void;
10
+ /** A file up to this size goes in one request. The server takes ~150 MB per request and the
11
+ * content travels as base64 (4/3 of the bytes), so a single request stops at ~110 MB. */
12
+ export declare const PUT_SINGLE_MAX: number;
13
+ /** A bigger file goes in pieces of this size, joined inside the sandbox. */
14
+ export declare const PUT_CHUNK: number;
15
+ /**
16
+ * Write a local file into a sandbox; resolves with its size. Over PUT_SINGLE_MAX the file is
17
+ * read and sent one piece at a time (memory stays at one piece): each piece is written next to
18
+ * the destination, appended to a temporary file and removed, and the temporary file is renamed
19
+ * onto the destination at the end, so a failed upload never leaves a half-written file there
20
+ * and the sandbox's disk needs the file plus one piece.
21
+ */
22
+ export declare function putSandboxFile(id: string, local: string, remote: string, chunk?: number, singleMax?: number): Promise<number>;
10
23
  /** Run a command inside a sandbox, streaming output. Resolves with the exit
11
24
  * code: the remote command's code from the `exit` event, or 1 when the
12
25
  * server reported an `error` event without one. Mirrors ssh.ts's parser. */
@@ -729,12 +729,11 @@ function registerSandboxFiles(sb) {
729
729
  .argument("<id>", "Sandbox ID")
730
730
  .argument("<local>", "Local file path")
731
731
  .argument("<remote>", "Destination path inside the sandbox")
732
- .description("Upload a local file into a sandbox")
732
+ .description("Upload a local file into a sandbox (any size: big files go in pieces)")
733
733
  .action(async (id, local, remote) => {
734
- const content = fs.readFileSync(local).toString("base64");
735
- await api.post(`/api/sandboxes/${id}/files`, { path: remote, content, encoding: "base64" });
734
+ const size = await putSandboxFile(id, local, remote);
736
735
  if (isJSONMode())
737
- printJSON({ id, path: remote, status: "written" });
736
+ printJSON({ id, path: remote, size, status: "written" });
738
737
  else
739
738
  success(`Wrote ${chalk.bold(remote)} in sandbox ${id}`);
740
739
  });
@@ -765,6 +764,62 @@ function registerSandboxFiles(sb) {
765
764
  success(`Deleted ${chalk.bold(path)} in sandbox ${id}`);
766
765
  });
767
766
  }
767
+ /** A file up to this size goes in one request. The server takes ~150 MB per request and the
768
+ * content travels as base64 (4/3 of the bytes), so a single request stops at ~110 MB. */
769
+ export const PUT_SINGLE_MAX = 64 * 1024 * 1024;
770
+ /** A bigger file goes in pieces of this size, joined inside the sandbox. */
771
+ export const PUT_CHUNK = 32 * 1024 * 1024;
772
+ /**
773
+ * Write a local file into a sandbox; resolves with its size. Over PUT_SINGLE_MAX the file is
774
+ * read and sent one piece at a time (memory stays at one piece): each piece is written next to
775
+ * the destination, appended to a temporary file and removed, and the temporary file is renamed
776
+ * onto the destination at the end, so a failed upload never leaves a half-written file there
777
+ * and the sandbox's disk needs the file plus one piece.
778
+ */
779
+ export async function putSandboxFile(id, local, remote, chunk = PUT_CHUNK, singleMax = PUT_SINGLE_MAX) {
780
+ const size = fs.statSync(local).size;
781
+ const write = (path, buf) => api.post(`/api/sandboxes/${id}/files`, { path, content: buf.toString("base64"), encoding: "base64" });
782
+ if (size <= singleMax) {
783
+ await write(remote, fs.readFileSync(local));
784
+ return size;
785
+ }
786
+ const sh = async (script, ...args) => {
787
+ const r = await api.post(`/api/sandboxes/${id}/exec`, { cmd: ["/bin/sh", "-c", script, "sh", ...args] });
788
+ if (r?.exitCode !== 0)
789
+ throw new Error(`Upload failed inside the sandbox: ${r?.stderr?.trim() || `exit ${r?.exitCode}`}`);
790
+ };
791
+ const tag = `${process.pid}-${Date.now().toString(36)}`;
792
+ const tmp = `${remote}.lizard-upload-${tag}`;
793
+ const part = `${tmp}.part`;
794
+ const pieces = Math.ceil(size / chunk);
795
+ const spinner = !isJSONMode() && isTTY() ? ora(`Uploading ${local} (0/${pieces})`).start() : null;
796
+ const fd = fs.openSync(local, "r");
797
+ try {
798
+ await sh('mkdir -p -- "$(dirname -- "$1")" && : > "$1"', tmp);
799
+ const buf = Buffer.alloc(chunk);
800
+ for (let i = 0, off = 0; off < size; i++) {
801
+ const n = fs.readSync(fd, buf, 0, Math.min(chunk, size - off), off);
802
+ if (n <= 0)
803
+ throw new Error(`Could not read ${local} at byte ${off}`);
804
+ await write(part, buf.subarray(0, n));
805
+ await sh('cat -- "$1" >> "$2" && rm -f -- "$1"', part, tmp);
806
+ off += n;
807
+ if (spinner)
808
+ spinner.text = `Uploading ${local} (${i + 1}/${pieces})`;
809
+ }
810
+ await sh('[ "$(wc -c < "$1")" -eq "$2" ] && mv -f -- "$1" "$3"', tmp, String(size), remote);
811
+ spinner?.stop();
812
+ return size;
813
+ }
814
+ catch (e) {
815
+ spinner?.fail();
816
+ await sh('rm -f -- "$1" "$2"', part, tmp).catch(() => { });
817
+ throw e;
818
+ }
819
+ finally {
820
+ fs.closeSync(fd);
821
+ }
822
+ }
768
823
  /** Run a command inside a sandbox, streaming output. Resolves with the exit
769
824
  * code: the remote command's code from the `exit` event, or 1 when the
770
825
  * server reported an `error` event without one. Mirrors ssh.ts's parser. */