The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore(ci): reformat source files to comply with project style
Steven Enamakel7f07988f7b4a
diff --git a/docs/ci-self-hosted.md b/docs/ci-self-hosted.mdindex 1c61444957..4c15ca1c23 100644--- a/docs/ci-self-hosted.md+++ b/docs/ci-self-hosted.md@@ -74,11 +74,11 @@ head commit. It is the check branch protection should require, whichever flowran the PR. It is re-evaluated whenever CI Fast, CI Fast (hosted) or CI Litestarts or finishes, from the decisive job of each:-| Flow | Decisive job |-| --- | --- |-| CI Fast | `Lanes / CI Fast (EX63)` |+| Flow | Decisive job |+| ---------------- | ------------------------------- |+| CI Fast | `Lanes / CI Fast (EX63)` || CI Fast (hosted) | `Lanes / CI Fast (hosted) Gate` |-| CI Lite | `PR CI Gate` |+| CI Lite | `PR CI Gate` |- **success** as soon as one of those jobs passes. The GitHub-hosted runsstill working on that commit are then cancelled. The EX63 run is neverdiff --git a/scripts/__tests__/ci-gate.test.mjs b/scripts/__tests__/ci-gate.test.mjsindex ffb97884bd..f1c296c704 100644--- a/scripts/__tests__/ci-gate.test.mjs+++ b/scripts/__tests__/ci-gate.test.mjs@@ -15,8 +15,14 @@ function entry(source, id, status, conclusion, job) {test("the EX63 lanes passing wins and cancels the hosted runs still going", () => {const verdict = decide([- entry(EX63, 1, "completed", "success", { status: "completed", conclusion: "success" }),- entry(HOSTED, 2, "completed", "success", { status: "completed", conclusion: "skipped" }),+ entry(EX63, 1, "completed", "success", {+ status: "completed",+ conclusion: "success",+ }),+ entry(HOSTED, 2, "completed", "success", {+ status: "completed",+ conclusion: "skipped",+ }),entry(LITE, 3, "in_progress", null, null),]);assert.equal(verdict.state, "success");@@ -27,8 +33,14 @@ test("the EX63 lanes passing wins and cancels the hosted runs still going", () =test("CI Lite passing first also passes the gate, and never cancels the EX63", () => {const verdict = decide([- entry(EX63, 1, "in_progress", null, { status: "in_progress", conclusion: null }),- entry(LITE, 3, "completed", "success", { status: "completed", conclusion: "success" }),+ entry(EX63, 1, "in_progress", null, {+ status: "in_progress",+ conclusion: null,+ }),+ entry(LITE, 3, "completed", "success", {+ status: "completed",+ conclusion: "success",+ }),]);assert.equal(verdict.state, "success");assert.equal(verdict.description, "CI Lite passed");@@ -37,8 +49,14 @@ test("CI Lite passing first also passes the gate, and never cancels the EX63", (test("a skipped decisive job is not a pass: an outsider's CI Fast run is pending on the rest", () => {const verdict = decide([- entry(EX63, 1, "completed", "success", { status: "completed", conclusion: "skipped" }),- entry(HOSTED, 2, "in_progress", null, { status: "queued", conclusion: null }),+ entry(EX63, 1, "completed", "success", {+ status: "completed",+ conclusion: "skipped",+ }),+ entry(HOSTED, 2, "in_progress", null, {+ status: "queued",+ conclusion: null,+ }),entry(LITE, 3, "queued", null, null),]);assert.equal(verdict.state, "pending");@@ -47,7 +65,10 @@ test("a skipped decisive job is not a pass: an outsider's CI Fast run is pendingtest("an EX63 failure waits for CI Lite instead of failing the gate early", () => {const verdict = decide([- entry(EX63, 1, "completed", "failure", { status: "completed", conclusion: "failure" }),+ entry(EX63, 1, "completed", "failure", {+ status: "completed",+ conclusion: "failure",+ }),entry(LITE, 3, "in_progress", null, null),]);assert.equal(verdict.state, "pending");@@ -55,9 +76,18 @@ test("an EX63 failure waits for CI Lite instead of failing the gate early", () =test("everything finished with no pass fails and points at the failed job", () => {const verdict = decide([- entry(EX63, 1, "completed", "failure", { status: "completed", conclusion: "failure" }),- entry(HOSTED, 2, "completed", "success", { status: "completed", conclusion: "skipped" }),- entry(LITE, 3, "completed", "failure", { status: "completed", conclusion: "failure" }),+ entry(EX63, 1, "completed", "failure", {+ status: "completed",+ conclusion: "failure",+ }),+ entry(HOSTED, 2, "completed", "success", {+ status: "completed",+ conclusion: "skipped",+ }),+ entry(LITE, 3, "completed", "failure", {+ status: "completed",+ conclusion: "failure",+ }),]);assert.equal(verdict.state, "failure");assert.equal(verdict.description, "CI Fast: failure; CI Lite: failure");@@ -67,7 +97,10 @@ test("everything finished with no pass fails and points at the failed job", () =test("finished flows whose decisive jobs never ran fail rather than pass", () => {const verdict = decide([entry(EX63, 1, "completed", "cancelled", null),- entry(LITE, 3, "completed", "cancelled", { status: "completed", conclusion: "skipped" }),+ entry(LITE, 3, "completed", "cancelled", {+ status: "completed",+ conclusion: "skipped",+ }),]);assert.equal(verdict.state, "failure");assert.equal(verdict.description, "No CI flow ran its checks");diff --git a/scripts/ci/ci-gate.mjs b/scripts/ci/ci-gate.mjsindex b57fb635ac..1df601fc45 100644--- a/scripts/ci/ci-gate.mjs+++ b/scripts/ci/ci-gate.mjs@@ -22,7 +22,12 @@ export const CONTEXT = "CI Gate";// Order is preference: when several passed, the first names the status.export const SOURCES = [- { workflow: "ci-fast.yml", name: "CI Fast", job: "Lanes / CI Fast (EX63)", hosted: false },+ {+ workflow: "ci-fast.yml",+ name: "CI Fast",+ job: "Lanes / CI Fast (EX63)",+ hosted: false,+ },{workflow: "ci-fast-hosted.yml",name: "CI Fast (hosted)",@@ -46,7 +51,9 @@ export function latestPrRun(runs) {return (runs.filter((run) => PR_EVENTS.has(run.event))- .sort((a, b) => String(b.created_at).localeCompare(String(a.created_at)))[0] ?? null+ .sort((a, b) =>+ String(b.created_at).localeCompare(String(a.created_at)),+ )[0] ?? null);}@@ -58,7 +65,9 @@ export function decide(entries) {const winner = entries.find((e) => e.job?.conclusion === "success");if (winner) {const cancel = entries- .filter((e) => e !== winner && e.source.hosted && e.run.status !== "completed")+ .filter(+ (e) => e !== winner && e.source.hosted && e.run.status !== "completed",+ ).map((e) => ({ id: e.run.id, name: e.source.name }));return {state: "success",@@ -72,12 +81,17 @@ export function decide(entries) {const names = running.map((e) => e.source.name).join(", ");return {state: "pending",- description: entries.length === 0 ? "Waiting for CI to start" : `Waiting on ${names}`,+ description:+ entries.length === 0+ ? "Waiting for CI to start"+ : `Waiting on ${names}`,targetUrl: running[0]?.run.html_url ?? null,cancel: [],};}- const ran = entries.filter((e) => e.job && e.job.conclusion && e.job.conclusion !== "skipped");+ const ran = entries.filter(+ (e) => e.job && e.job.conclusion && e.job.conclusion !== "skipped",+ );const failed = ran.find((e) => e.job.conclusion !== "success");return {state: "failure",@@ -85,7 +99,11 @@ export function decide(entries) {ran.length === 0? "No CI flow ran its checks": ran.map((e) => `${e.source.name}: ${e.job.conclusion}`).join("; "),- targetUrl: failed?.job.html_url ?? failed?.run.html_url ?? entries[0].run.html_url ?? null,+ targetUrl:+ failed?.job.html_url ??+ failed?.run.html_url ??+ entries[0].run.html_url ??+ null,cancel: [],};}@@ -112,15 +130,20 @@ async function collect(repo, sha) {const runs = await api(`/repos/${repo}/actions/workflows/${source.workflow}/runs?head_sha=${sha}&per_page=20`,);- if (runs.status !== 200) throw new Error(`list ${source.workflow} runs: HTTP ${runs.status}`);+ if (runs.status !== 200)+ throw new Error(`list ${source.workflow} runs: HTTP ${runs.status}`);const run = latestPrRun(runs.data.workflow_runs ?? []);if (!run) {log(`${source.name}: no PR run for ${sha.slice(0, 10)}`);continue;}- const jobs = await api(`/repos/${repo}/actions/runs/${run.id}/jobs?filter=latest&per_page=100`);- if (jobs.status !== 200) throw new Error(`list jobs of run ${run.id}: HTTP ${jobs.status}`);- const job = (jobs.data.jobs ?? []).find((j) => j.name === source.job) ?? null;+ const jobs = await api(+ `/repos/${repo}/actions/runs/${run.id}/jobs?filter=latest&per_page=100`,+ );+ if (jobs.status !== 200)+ throw new Error(`list jobs of run ${run.id}: HTTP ${jobs.status}`);+ const job =+ (jobs.data.jobs ?? []).find((j) => j.name === source.job) ?? null;log(`${source.name}: run=${run.id} status=${run.status} conclusion=${run.conclusion} ` +`job="${source.job}" ${job ? `${job.status}/${job.conclusion}` : "absent"}`,@@ -132,8 +155,10 @@ async function collect(repo, sha) {async function main() {const { REPO: repo, HEAD_SHA: sha, GH_TOKEN: token } = process.env;- if (!repo || !sha || !token) throw new Error("REPO, HEAD_SHA and GH_TOKEN are required");- if (!/^[0-9a-f]{40}$/.test(sha)) throw new Error(`HEAD_SHA is not a commit sha: ${sha}`);+ if (!repo || !sha || !token)+ throw new Error("REPO, HEAD_SHA and GH_TOKEN are required");+ if (!/^[0-9a-f]{40}$/.test(sha))+ throw new Error(`HEAD_SHA is not a commit sha: ${sha}`);const dry = process.env.CI_GATE_DRY_RUN === "1";const verdict = decide(await collect(repo, sha));@@ -149,11 +174,14 @@ async function main() {...(verdict.targetUrl ? { target_url: verdict.targetUrl } : {}),},});- if (status.status !== 201) throw new Error(`post status: HTTP ${status.status}`);+ if (status.status !== 201)+ throw new Error(`post status: HTTP ${status.status}`);for (const { id, name } of verdict.cancel) {// 409: it finished between the listing and now. Nothing to do.- const res = await api(`/repos/${repo}/actions/runs/${id}/cancel`, { method: "POST" });+ const res = await api(`/repos/${repo}/actions/runs/${id}/cancel`, {+ method: "POST",+ });log(`cancel ${name} run=${id}: HTTP ${res.status}`);}}