Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh
98 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Merge Actions runs: summaries, attempts and re-runs, graceful cancel, log downloads, badges (actions 0009)1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import type { JobLogText } from "@g1t/contracts";
5
A running job's log is live, as on GitHub. A step's output reaches its run's page within about two seconds: the runner sends what is printed every second, and the page asks every second while a step runs, every three while none does; an answer that fails (a 429, a 5xx, the network) is asked again after a wait that doubles to half a minute, or as long as Retry-After says, where before one such answer stopped the log for good and the step said "No output yet." until the page was reloaded, and a signed-out viewer's run page, refreshing beside its log, ran into the 30-a-minute limit within a minute; the live log now counts as a page, and only log downloads as costly. A hidden tab stops asking and catches up when shown, and the page says when it is reconnecting. The running step opens by itself, its timer counts, its log follows the newest line while its end is on screen and offers Jump to latest once the viewer scrolls up, a step that has printed nothing for a while says "Running · no output for 2m 10s", and the job's header names the step it is on. Colour that tools print (bold, dim, italic, underline, the 16 colours as theme tokens for light and dark, 256 colours and 24-bit colour, text and background) is drawn as printed, other escape codes are dropped and links keep their text, and search reads the plain text and keeps the colours around what it marks. Every line is stamped with the time it was printed, as GitHub's raw logs are, so log.txt and the run's zip have a time at the start of each line, and a clock button beside Search logs shows the times, remembered by the browser. Set up job now gives the runner's version and name, the operating system, the runner image, the machine's architecture, CPUs and memory, the token's permissions under G1T_TOKEN Permissions, the secret source and the actions it downloads; each run step opens with GitHub's folded Run group, the script in cyan, the shell's whole path and the step's env, each uses step with its with inputs (an action's defaults among them) and env; cache and artifact transfers say how far they have got every five seconds; and a last Complete job step sets the job's outputs and stops what the steps left running, found by RUNNER_TRACKING_ID as GitHub's runner finds it. Two batches of a job's log written at once can no longer reach for the same seq and lose one. The Actions guide and the rate limits page say so.6import { archiveFiles, blocks, classify, fileName, highlight, lastStamp, searchLog, splitStamp } from "./log-lines.ts";
Merge Actions runs: summaries, attempts and re-runs, graceful cancel, log downloads, badges (actions 0009)7
8const LOG = ["Job: test", "##[group]Run cargo test", "cargo test --locked", "##[endgroup]", "test greet ... FAILED", "##[error]Process completed with exit code 101."].join("\n");
9
10test("a log reads as lines and folded groups, numbered past the group markers", () => {
11 const parsed = blocks(LOG);
12 assert.equal(parsed.length, 4);
13 assert.deepEqual(parsed[1], { kind: "group", title: "Run cargo test", lines: [{ line: { kind: "text", text: "cargo test --locked" }, number: 2 }] });
14 assert.deepEqual(parsed[3], { kind: "line", line: { kind: "error", text: "Process completed with exit code 101." }, number: 4 });
15});
16
17test("search finds lines in any case, inside folded groups too", () => {
18 assert.deepEqual(
19 searchLog(LOG, "CARGO TEST").map((found) => found.number),
20 [2],
21 );
22 assert.deepEqual(
23 searchLog(LOG, "test").map((found) => found.number),
24 [1, 2, 3],
25 );
26 assert.deepEqual(searchLog(LOG, " "), []);
27 // The group's title is not a line of its own.
28 assert.deepEqual(searchLog(LOG, "Run cargo"), []);
29});
30
31test("matches are marked where they fall", () => {
32 assert.deepEqual(highlight("Test a test", "test"), [
33 { text: "Test", match: true },
34 { text: " a ", match: false },
35 { text: "test", match: true },
36 ]);
37 assert.deepEqual(highlight("plain", ""), [{ text: "plain", match: false }]);
38});
39
40test("a run's archive has each job whole and a file per step, named as the API names them", () => {
41 const job = (name: string, chunks: [number, string][], omitted = false): JobLogText => ({
42 jobId: "job_1",
43 name,
44 steps: [{ number: 1, name: "Run cargo test", status: "completed", conclusion: "success", startedAt: null, finishedAt: null }],
45 chunks: chunks.map(([step, text], index) => ({ seq: index + 1, step, text })),
46 done: true,
47 omitted,
48 });
49 const files = archiveFiles([job("test", [[0, "set up\n"], [1, "running\n"], [1, "ok\n"]]), job("deploy/x", [], true)]);
50 assert.deepEqual(
51 files.map((file) => file.path),
52 ["1_test.txt", "test/0_Set up job.txt", "test/1_Run cargo test.txt", "2_deploy_x.txt"],
53 );
54 assert.equal(files[0]!.text, "set up\nrunning\nok\n");
55 assert.equal(files[2]!.text, "running\nok\n");
56 assert.match(files[3]!.text, /left out/);
57 assert.equal(fileName("build / a:b"), "build _ a_b");
58 assert.equal(fileName(".."), "job");
59});
A running job's log is live, as on GitHub. A step's output reaches its run's page within about two seconds: the runner sends what is printed every second, and the page asks every second while a step runs, every three while none does; an answer that fails (a 429, a 5xx, the network) is asked again after a wait that doubles to half a minute, or as long as Retry-After says, where before one such answer stopped the log for good and the step said "No output yet." until the page was reloaded, and a signed-out viewer's run page, refreshing beside its log, ran into the 30-a-minute limit within a minute; the live log now counts as a page, and only log downloads as costly. A hidden tab stops asking and catches up when shown, and the page says when it is reconnecting. The running step opens by itself, its timer counts, its log follows the newest line while its end is on screen and offers Jump to latest once the viewer scrolls up, a step that has printed nothing for a while says "Running · no output for 2m 10s", and the job's header names the step it is on. Colour that tools print (bold, dim, italic, underline, the 16 colours as theme tokens for light and dark, 256 colours and 24-bit colour, text and background) is drawn as printed, other escape codes are dropped and links keep their text, and search reads the plain text and keeps the colours around what it marks. Every line is stamped with the time it was printed, as GitHub's raw logs are, so log.txt and the run's zip have a time at the start of each line, and a clock button beside Search logs shows the times, remembered by the browser. Set up job now gives the runner's version and name, the operating system, the runner image, the machine's architecture, CPUs and memory, the token's permissions under G1T_TOKEN Permissions, the secret source and the actions it downloads; each run step opens with GitHub's folded Run group, the script in cyan, the shell's whole path and the step's env, each uses step with its with inputs (an action's defaults among them) and env; cache and artifact transfers say how far they have got every five seconds; and a last Complete job step sets the job's outputs and stops what the steps left running, found by RUNNER_TRACKING_ID as GitHub's runner finds it. Two batches of a job's log written at once can no longer reach for the same seq and lose one. The Actions guide and the rate limits page say so.60
61test("each line's time comes off the front, as GitHub's logs stamp it, and colours stay beside the plain text", () => {
62 const stamped = [
63 "2026-10-12T09:41:07.1234567Z ##[group]Run cargo build",
64 "2026-10-12T09:41:07.2000000Z \u001b[36;1mcargo build\u001b[0m",
65 "2026-10-12T09:41:07.3000000Z ##[endgroup]",
66 "2026-10-12T09:41:09.0000000Z \u001b[1m\u001b[32m Compiling\u001b[0m g1t v0.2.0",
67 "2026-10-12T09:41:10.0000000Z ##[error]Process completed with exit code 1.",
68 "a line from before lines were stamped",
69 "",
70 ].join("\n");
71 const parsed = blocks(stamped);
72 assert.equal(parsed.length, 4, "a log's last newline adds no line");
73 assert.deepEqual(parsed[0], {
74 kind: "group",
75 title: "Run cargo build",
76 at: "2026-10-12T09:41:07.1234567Z",
77 lines: [{ line: { kind: "text", text: "cargo build", at: "2026-10-12T09:41:07.2000000Z", ansi: "\u001b[36;1mcargo build\u001b[0m" }, number: 1 }],
78 });
79 assert.deepEqual(parsed[1], {
80 kind: "line",
81 line: { kind: "text", text: " Compiling g1t v0.2.0", at: "2026-10-12T09:41:09.0000000Z", ansi: "\u001b[1m\u001b[32m Compiling\u001b[0m g1t v0.2.0" },
82 number: 2,
83 });
84 assert.deepEqual(parsed[2], { kind: "line", line: { kind: "error", text: "Process completed with exit code 1.", at: "2026-10-12T09:41:10.0000000Z" }, number: 3 });
85 assert.deepEqual(parsed[3], { kind: "line", line: { kind: "text", text: "a line from before lines were stamped" }, number: 4 });
86 // Search reads the plain text, never the time or the codes.
87 assert.deepEqual(
88 searchLog(stamped, "compiling g1t").map((found) => found.number),
89 [2],
90 );
91 assert.deepEqual(searchLog(stamped, "2026-10-12"), []);
92 assert.deepEqual(searchLog(stamped, "32m"), []);
93 assert.deepEqual(splitStamp("2026-10-12T09:41:07Z text"), { at: "2026-10-12T09:41:07Z", rest: "text" });
94 assert.deepEqual(splitStamp("2026-10-12 not a stamp"), { rest: "2026-10-12 not a stamp" });
95 assert.deepEqual(classify("##[warning]plain"), { kind: "warning", text: "plain" });
96 assert.equal(lastStamp(stamped), "2026-10-12T09:41:10.0000000Z");
97 assert.equal(lastStamp("no stamps\n"), undefined);
98});

This file's history is long; its oldest lines are credited to the oldest commit read.