chaffbroom 0.3.1 → 0.3.2
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.
- package/README.md +11 -5
- package/dist/chaffbroom.js +179 -78
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,11 +18,17 @@ Writes, into the repository you run it in:
|
|
|
18
18
|
- `.winnow.yml`: the Winnow config, with only the preview providers the repository shows
|
|
19
19
|
(`vercel.json`, `fly.toml`, `railway.json`, `supabase/config.toml`, `wrangler.toml`, Neon in
|
|
20
20
|
`package.json`), or the ones you name with `--provider`.
|
|
21
|
-
- `.github/workflows/winnow.yml
|
|
22
|
-
|
|
23
|
-
- `.github/workflows/tollbook-pr.yml
|
|
24
|
-
runs
|
|
25
|
-
|
|
21
|
+
- `.github/workflows/winnow.yml` ("Chaffbroom Winnow"): nightly and on PR close. It starts in
|
|
22
|
+
plan mode: it lists, it deletes nothing, until you set `WINNOW_MODE: apply`.
|
|
23
|
+
- `.github/workflows/tollbook-pr.yml` ("Chaffbroom Tollbook PR"): the sticky PR cost comment,
|
|
24
|
+
after each workflow that runs when a pull request is opened or pushed to. A workflow that runs
|
|
25
|
+
on pull requests only when they close is left out (name it with `--pr-workflow` to cost it).
|
|
26
|
+
- `.github/workflows/tollbook-weekly.yml` ("Chaffbroom Tollbook weekly"): the Monday summary.
|
|
27
|
+
|
|
28
|
+
Each workflow pins the Action to the full commit of the release this package came with, with the
|
|
29
|
+
version in a comment: `uses: chaffbroom/tollbook@<commit> # v0.x.y`. To take every 0.x release
|
|
30
|
+
as it comes out instead, change it to `@v0`. Nothing runs until the files are on your default
|
|
31
|
+
branch: GitHub starts scheduled, `workflow_run` and manually run workflows only from there.
|
|
26
32
|
|
|
27
33
|
It shows every file first and writes only with `--yes` (`--dry-run` never writes). A file that
|
|
28
34
|
exists and differs is kept unless you add `--force`. It never asks for a token and never
|
package/dist/chaffbroom.js
CHANGED
|
@@ -7389,8 +7389,8 @@ var BRAND = {
|
|
|
7389
7389
|
sourceActionRef: "chaffbroom/chaffbroom/tollbook@v0",
|
|
7390
7390
|
/** Default config file name, at the repository root. */
|
|
7391
7391
|
configFile: ".tollbook.yml",
|
|
7392
|
-
version: "0.3.
|
|
7393
|
-
userAgent: "chaffbroom-tollbook/0.3.
|
|
7392
|
+
version: "0.3.2",
|
|
7393
|
+
userAgent: "chaffbroom-tollbook/0.3.2 (+https://github.com/chaffbroom/chaffbroom/tree/main/tollbook#readme)",
|
|
7394
7394
|
/**
|
|
7395
7395
|
* Hidden HTML comment that starts the sticky PR comment. The comment is ours only when it
|
|
7396
7396
|
* starts with this AND was written by the identity we post as. Changing it orphans old comments.
|
|
@@ -7441,6 +7441,17 @@ function loadConfig(path) {
|
|
|
7441
7441
|
return parseConfig(readFileSync(path, "utf8"));
|
|
7442
7442
|
}
|
|
7443
7443
|
|
|
7444
|
+
// ../tollbook/src/git.ts
|
|
7445
|
+
import { execFileSync } from "node:child_process";
|
|
7446
|
+
function githubRepo(dir) {
|
|
7447
|
+
try {
|
|
7448
|
+
const url = execFileSync("git", ["-C", dir, "config", "--get", "remote.origin.url"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
7449
|
+
return /github\.com[:/]([\w.-]+\/[\w.-]+?)(?:\.git)?\/?$/.exec(url)?.[1];
|
|
7450
|
+
} catch {
|
|
7451
|
+
return void 0;
|
|
7452
|
+
}
|
|
7453
|
+
}
|
|
7454
|
+
|
|
7444
7455
|
// ../tollbook/src/endpoints.ts
|
|
7445
7456
|
var GITHUB_API = "https://api.github.com";
|
|
7446
7457
|
|
|
@@ -7548,6 +7559,20 @@ var GitHub = class {
|
|
|
7548
7559
|
return run3.event.startsWith("pull_request") && run3.head_branch === pr.head.ref && (!headRepo || !run3.head_repository || run3.head_repository.full_name === headRepo) && !run3.pull_requests?.length;
|
|
7549
7560
|
});
|
|
7550
7561
|
}
|
|
7562
|
+
/**
|
|
7563
|
+
* Pull requests of any state updated on or after `sinceDate` (YYYY-MM-DD), newest first. A PR
|
|
7564
|
+
* that ran a workflow in the window was updated in it too, so this finds every one of them.
|
|
7565
|
+
*/
|
|
7566
|
+
async listPullsUpdatedSince(sinceDate, max) {
|
|
7567
|
+
const out = [];
|
|
7568
|
+
for (let page = 1; out.length < max; page++) {
|
|
7569
|
+
const items = await this.get(this.url("/pulls", { state: "all", sort: "updated", direction: "desc", per_page: 100, page })) ?? [];
|
|
7570
|
+
const recent = items.filter((p) => !p.updated_at || p.updated_at.slice(0, 10) >= sinceDate);
|
|
7571
|
+
out.push(...recent);
|
|
7572
|
+
if (items.length < 100 || recent.length < items.length) break;
|
|
7573
|
+
}
|
|
7574
|
+
return out.slice(0, max);
|
|
7575
|
+
}
|
|
7551
7576
|
listRunsCreatedSince(sinceDate, max) {
|
|
7552
7577
|
return this.paginate("/actions/runs", { created: `>=${sinceDate}` }, (r) => r.workflow_runs, max);
|
|
7553
7578
|
}
|
|
@@ -7883,7 +7908,17 @@ function cacheInfo(ref, caches) {
|
|
|
7883
7908
|
const last = caches.map((c) => c.last_accessed_at).filter(Boolean).sort().at(-1) ?? null;
|
|
7884
7909
|
return { ref, entries: caches.length, bytes: caches.reduce((a, c) => a + (c.size_in_bytes ?? 0), 0), lastAccessedAt: last, hitRateAvailable: false };
|
|
7885
7910
|
}
|
|
7886
|
-
function
|
|
7911
|
+
function prsForUnlinkedRuns(runs, pulls) {
|
|
7912
|
+
const out = /* @__PURE__ */ new Map();
|
|
7913
|
+
for (const run3 of runs) {
|
|
7914
|
+
if (run3.pull_requests?.length || !run3.event.startsWith("pull_request") || run3.event === "pull_request_target" || !run3.head_branch) continue;
|
|
7915
|
+
const repo = run3.head_repository?.full_name;
|
|
7916
|
+
const match = pulls.filter((p) => p.head.ref === run3.head_branch && (!repo || !p.head.repo || p.head.repo.full_name === repo)).filter((p) => !p.created_at || p.created_at <= run3.created_at).sort((a, b) => (b.created_at ?? "").localeCompare(a.created_at ?? ""))[0];
|
|
7917
|
+
if (match) out.set(run3.id, match.number);
|
|
7918
|
+
}
|
|
7919
|
+
return out;
|
|
7920
|
+
}
|
|
7921
|
+
function weekly(inputs, pricing, since, until, ignoreWorkflows = [], prByRun = /* @__PURE__ */ new Map()) {
|
|
7887
7922
|
const kept = inputs.filter((i) => !ignoreWorkflows.includes(workflowName(i.run)));
|
|
7888
7923
|
const totals = summarize(kept, pricing);
|
|
7889
7924
|
const wfs = /* @__PURE__ */ new Map();
|
|
@@ -7901,7 +7936,8 @@ function weekly(inputs, pricing, since, until, ignoreWorkflows = []) {
|
|
|
7901
7936
|
if (j.bucket === "cancelled") w.cancelledMicros += j.micros;
|
|
7902
7937
|
}
|
|
7903
7938
|
wfs.set(name, w);
|
|
7904
|
-
|
|
7939
|
+
const linked = input.run.pull_requests?.length ? input.run.pull_requests : prByRun.has(input.run.id) ? [{ number: prByRun.get(input.run.id) }] : [];
|
|
7940
|
+
for (const pr of linked) {
|
|
7905
7941
|
const p = prs.get(pr.number) ?? { number: pr.number, micros: 0, runs: 0 };
|
|
7906
7942
|
p.micros += runMicros;
|
|
7907
7943
|
p.runs++;
|
|
@@ -7969,7 +8005,18 @@ async function weeklyReport(gh, config, table, opts) {
|
|
|
7969
8005
|
const runs = await gh.listRunsCreatedSince(sinceDate, config.maxRuns);
|
|
7970
8006
|
const inputs = await collectJobs(gh, runs);
|
|
7971
8007
|
const pricing = { table, runnerMap: config.runnerMap, isPublic: opts.isPublic };
|
|
7972
|
-
|
|
8008
|
+
let prByRun = /* @__PURE__ */ new Map();
|
|
8009
|
+
let warning;
|
|
8010
|
+
if (runs.some((r) => !r.pull_requests?.length && r.event.startsWith("pull_request") && r.event !== "pull_request_target")) {
|
|
8011
|
+
try {
|
|
8012
|
+
prByRun = prsForUnlinkedRuns(runs, await gh.listPullsUpdatedSince(sinceDate, 1e3));
|
|
8013
|
+
} catch (e) {
|
|
8014
|
+
warning = `PRs of merged or deleted branches not listed (could not read pull requests: ${oneLine(e.message).slice(0, 200)})`;
|
|
8015
|
+
}
|
|
8016
|
+
}
|
|
8017
|
+
const w = weekly(inputs, pricing, sinceDate, opts.now.toISOString().slice(0, 10), config.ignoreWorkflows, prByRun);
|
|
8018
|
+
if (warning) w.totals.warnings.push(warning);
|
|
8019
|
+
return w;
|
|
7973
8020
|
}
|
|
7974
8021
|
function billingByRepo(items) {
|
|
7975
8022
|
const m = /* @__PURE__ */ new Map();
|
|
@@ -8044,7 +8091,7 @@ function prComment(s, o) {
|
|
|
8044
8091
|
`### ${BRAND.displayName}: ${usd(s.totalMicros)} for this PR`,
|
|
8045
8092
|
...netLine(s),
|
|
8046
8093
|
"",
|
|
8047
|
-
`${s.runs
|
|
8094
|
+
`${plural(s.runs, "workflow run")} \xB7 ${s.minutes} billable minutes \xB7 ${s.rerunRuns} rerun${s.rerunRuns === 1 ? "" : "s"} \xB7 ${s.cancelledRuns} cancelled`,
|
|
8048
8095
|
"",
|
|
8049
8096
|
`**Waste:** ${usd(waste)} (reruns ${usd(s.byBucket.rerun.micros)} / ${s.byBucket.rerun.minutes} min, cancelled ${usd(s.byBucket.cancelled.micros)} / ${s.byBucket.cancelled.minutes} min)` + (s.byBucket.failed.micros ? ` \xB7 failed runs ${usd(s.byBucket.failed.micros)}` : "")
|
|
8050
8097
|
];
|
|
@@ -8079,7 +8126,7 @@ function weeklyMarkdown(w, table, top = 5) {
|
|
|
8079
8126
|
const lines = [
|
|
8080
8127
|
`### ${BRAND.displayName}: weekly summary ${w.since} to ${w.until}`,
|
|
8081
8128
|
"",
|
|
8082
|
-
`**${usd(t.totalMicros)}** across ${t.runs}
|
|
8129
|
+
`**${usd(t.totalMicros)}** across ${plural(t.runs, "run")}, ${t.minutes} billable minutes.`,
|
|
8083
8130
|
...netLine(t),
|
|
8084
8131
|
"",
|
|
8085
8132
|
`**Rerun waste: ${usd(t.byBucket.rerun.micros)}** (${t.byBucket.rerun.minutes} min) \xB7 cancelled: ${usd(t.byBucket.cancelled.micros)} (${t.byBucket.cancelled.minutes} min) \xB7 failed: ${usd(t.byBucket.failed.micros)}`,
|
|
@@ -8105,9 +8152,12 @@ function weeklyMarkdown(w, table, top = 5) {
|
|
|
8105
8152
|
lines.push("", `<sub>${mdText(priceFootnote(table), 1e3)}</sub>`);
|
|
8106
8153
|
return lines.join("\n");
|
|
8107
8154
|
}
|
|
8155
|
+
function plural(n, word) {
|
|
8156
|
+
return `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
8157
|
+
}
|
|
8108
8158
|
function textSummary(s) {
|
|
8109
8159
|
const lines = [
|
|
8110
|
-
`total ${usd(s.totalMicros)} \xB7 ${s.minutes} min \xB7 ${s.runs}
|
|
8160
|
+
`total ${usd(s.totalMicros)} \xB7 ${s.minutes} min \xB7 ${plural(s.runs, "run")} \xB7 rerun waste ${usd(s.byBucket.rerun.micros)} \xB7 cancelled ${usd(s.byBucket.cancelled.micros)}` + (s.byBucket.failed.micros ? ` \xB7 failed runs ${usd(s.byBucket.failed.micros)}` : "") + (s.net ? ` \xB7 \u2248 net ${usd(s.net.micros)} (${(s.net.factor * 100).toFixed(0)}% of list, ${s.net.month})` : "")
|
|
8111
8161
|
];
|
|
8112
8162
|
for (const j of s.jobs.filter((x) => x.minutes > 0)) {
|
|
8113
8163
|
lines.push(` ${usd(j.micros).padStart(8)} ${String(j.minutes).padStart(5)} min ${oneLine(j.workflow)} / ${oneLine(j.job)} [${oneLine(j.runner)}]`);
|
|
@@ -8126,7 +8176,7 @@ Usage:
|
|
|
8126
8176
|
${BRAND.product} prices Show the price table source and date
|
|
8127
8177
|
|
|
8128
8178
|
Options:
|
|
8129
|
-
--repo owner/name Default $GITHUB_REPOSITORY
|
|
8179
|
+
--repo owner/name Default $GITHUB_REPOSITORY, else the github.com origin of this clone
|
|
8130
8180
|
--pr N Default: PR from $GITHUB_EVENT_PATH
|
|
8131
8181
|
--comment Create or update the sticky PR comment
|
|
8132
8182
|
--comment-author L Login the comment is posted as (default: GET /user, else github-actions[bot]);
|
|
@@ -8137,10 +8187,10 @@ Options:
|
|
|
8137
8187
|
--issue Open an issue with the weekly summary
|
|
8138
8188
|
-c, --config <path> Default ${BRAND.configFile} (optional)
|
|
8139
8189
|
--prices <path> Alternative price table JSON
|
|
8140
|
-
-f, --format <fmt> text | markdown | json (default text)
|
|
8190
|
+
-f, --format <fmt> text | markdown | json (default text); with json, errors are JSON too
|
|
8141
8191
|
-h, --help | -v, --version
|
|
8142
8192
|
|
|
8143
|
-
Needs GITHUB_TOKEN (actions: read; pull-requests: write for --comment; issues: write for --issue).
|
|
8193
|
+
Needs GITHUB_TOKEN (actions: read; pull-requests: write for --comment, read for weekly; issues: write for --issue).
|
|
8144
8194
|
Docs: ${BRAND.docsUrl}`;
|
|
8145
8195
|
function prFromEvent(env) {
|
|
8146
8196
|
if (!env.GITHUB_EVENT_PATH) return void 0;
|
|
@@ -8152,9 +8202,18 @@ function prFromEvent(env) {
|
|
|
8152
8202
|
return void 0;
|
|
8153
8203
|
}
|
|
8154
8204
|
}
|
|
8205
|
+
function wantsJson(argv) {
|
|
8206
|
+
return argv.some((a, i) => a === "--format=json" || a === "-fjson" || (a === "--format" || a === "-f") && argv[i + 1] === "json");
|
|
8207
|
+
}
|
|
8155
8208
|
async function run(argv, io = {}) {
|
|
8156
8209
|
const out = io.stdout ?? ((s) => process.stdout.write(s + "\n"));
|
|
8157
8210
|
const err = io.stderr ?? ((s) => process.stderr.write(s + "\n"));
|
|
8211
|
+
const json = wantsJson(argv);
|
|
8212
|
+
const fail = (code, message, kind = code === 2 ? "usage" : "error") => {
|
|
8213
|
+
if (json) out(JSON.stringify({ error: { kind, message: oneLine(message.split("\n\n")[0] ?? message) }, code }));
|
|
8214
|
+
err(message);
|
|
8215
|
+
return { code };
|
|
8216
|
+
};
|
|
8158
8217
|
const env = io.env ?? process.env;
|
|
8159
8218
|
const fetchFn = io.fetch ?? globalThis.fetch;
|
|
8160
8219
|
const now = io.now ?? /* @__PURE__ */ new Date();
|
|
@@ -8184,20 +8243,16 @@ async function run(argv, io = {}) {
|
|
|
8184
8243
|
}
|
|
8185
8244
|
});
|
|
8186
8245
|
} catch (e) {
|
|
8187
|
-
|
|
8246
|
+
return fail(2, `${e.message}
|
|
8188
8247
|
|
|
8189
8248
|
${HELP}`);
|
|
8190
|
-
return { code: 2 };
|
|
8191
8249
|
}
|
|
8192
8250
|
const { values: v, positionals } = parsed;
|
|
8193
8251
|
if (v.help) return out(HELP), { code: 0 };
|
|
8194
8252
|
if (v.version) return out(BRAND.version), { code: 0 };
|
|
8195
8253
|
const command = positionals[0] ?? "pr";
|
|
8196
8254
|
const format = v.format ?? "text";
|
|
8197
|
-
if (!["text", "markdown", "json"].includes(format))
|
|
8198
|
-
err("--format must be text, markdown or json");
|
|
8199
|
-
return { code: 2 };
|
|
8200
|
-
}
|
|
8255
|
+
if (!["text", "markdown", "json"].includes(format)) return fail(2, "--format must be text, markdown or json");
|
|
8201
8256
|
try {
|
|
8202
8257
|
const cwd = io.cwd ?? process.cwd();
|
|
8203
8258
|
const config = loadConfig(resolve(cwd, v.config ?? BRAND.configFile));
|
|
@@ -8208,9 +8263,27 @@ retrieved ${table.retrieved}, effective ${table.effective}
|
|
|
8208
8263
|
` + Object.entries(table.skus).map(([k, p]) => ` ${k.padEnd(22)} $${p.rate.toFixed(3)}/min ${p.name}`).join("\n"));
|
|
8209
8264
|
return { code: 0 };
|
|
8210
8265
|
}
|
|
8211
|
-
|
|
8266
|
+
if (command === "billing") {
|
|
8267
|
+
if (!v.org) throw new ConfigError("billing needs --org");
|
|
8268
|
+
const gh2 = new GitHub(v.org, "", env.GITHUB_TOKEN, fetchFn);
|
|
8269
|
+
const items = await gh2.billingUsage(v.org, {
|
|
8270
|
+
year: v.year ? Number(v.year) : now.getUTCFullYear(),
|
|
8271
|
+
month: v.month ? Number(v.month) : now.getUTCMonth() + 1
|
|
8272
|
+
});
|
|
8273
|
+
const lines = billingByRepo(items);
|
|
8274
|
+
if (format === "json") out(JSON.stringify(lines, null, 2));
|
|
8275
|
+
else {
|
|
8276
|
+
out(`GitHub billing usage report, Actions minutes, ${v.org}:`);
|
|
8277
|
+
for (const l of lines) out(` ${oneLine(l.repository).padEnd(40)} ${String(Math.round(l.quantity)).padStart(7)} min gross $${l.grossAmount.toFixed(2)} net $${l.netAmount.toFixed(2)}`);
|
|
8278
|
+
}
|
|
8279
|
+
return { code: 0, costUsd: lines.reduce((a, l) => a + l.grossAmount, 0) };
|
|
8280
|
+
}
|
|
8281
|
+
if (command !== "pr" && command !== "weekly") return fail(2, `unknown command "${command}"
|
|
8282
|
+
|
|
8283
|
+
${HELP}`);
|
|
8284
|
+
const repoStr = v.repo ?? env.GITHUB_REPOSITORY ?? githubRepo(cwd);
|
|
8212
8285
|
const [owner, name] = (repoStr ?? "").split("/");
|
|
8213
|
-
if (!owner || !name) throw new ConfigError("repository unknown: pass --repo owner/name or
|
|
8286
|
+
if (!owner || !name) throw new ConfigError("repository unknown: pass --repo owner/name, set GITHUB_REPOSITORY, or run it in a clone whose origin is on github.com");
|
|
8214
8287
|
const gh = new GitHub(owner, name, env.GITHUB_TOKEN, fetchFn);
|
|
8215
8288
|
if (command === "pr") {
|
|
8216
8289
|
const prNumber = v.pr !== void 0 ? Number(v.pr) : prFromEvent(env);
|
|
@@ -8269,32 +8342,17 @@ retrieved ${table.retrieved}, effective ${table.effective}
|
|
|
8269
8342
|
else if (format === "markdown") out(md);
|
|
8270
8343
|
else {
|
|
8271
8344
|
out(`${w.since}..${w.until}: ${textSummary(w.totals).split("\n")[0]}`);
|
|
8272
|
-
w.workflows.slice(0, top).forEach((x, i) => out(` ${i + 1}. ${usd(x.micros).padStart(8)} ${oneLine(x.workflow)} (${x.runs}
|
|
8345
|
+
w.workflows.slice(0, top).forEach((x, i) => out(` ${i + 1}. ${usd(x.micros).padStart(8)} ${oneLine(x.workflow)} (${plural(x.runs, "run")}, rerun waste ${usd(x.rerunMicros)})`));
|
|
8346
|
+
w.prs.slice(0, top).forEach((p) => out(` PR #${p.number}: ${usd(p.micros)} over ${plural(p.runs, "run")}`));
|
|
8273
8347
|
}
|
|
8274
8348
|
return outcome;
|
|
8275
8349
|
}
|
|
8276
|
-
|
|
8277
|
-
if (!v.org) throw new ConfigError("billing needs --org");
|
|
8278
|
-
const items = await gh.billingUsage(v.org, {
|
|
8279
|
-
year: v.year ? Number(v.year) : now.getUTCFullYear(),
|
|
8280
|
-
month: v.month ? Number(v.month) : now.getUTCMonth() + 1
|
|
8281
|
-
});
|
|
8282
|
-
const lines = billingByRepo(items);
|
|
8283
|
-
if (format === "json") out(JSON.stringify(lines, null, 2));
|
|
8284
|
-
else {
|
|
8285
|
-
out(`GitHub billing usage report, Actions minutes, ${v.org}:`);
|
|
8286
|
-
for (const l of lines) out(` ${oneLine(l.repository).padEnd(40)} ${String(Math.round(l.quantity)).padStart(7)} min gross $${l.grossAmount.toFixed(2)} net $${l.netAmount.toFixed(2)}`);
|
|
8287
|
-
}
|
|
8288
|
-
return { code: 0, costUsd: lines.reduce((a, l) => a + l.grossAmount, 0) };
|
|
8289
|
-
}
|
|
8290
|
-
err(`unknown command "${command}"
|
|
8350
|
+
return fail(2, `unknown command "${command}"
|
|
8291
8351
|
|
|
8292
8352
|
${HELP}`);
|
|
8293
|
-
return { code: 2 };
|
|
8294
8353
|
} catch (e) {
|
|
8295
8354
|
const msg = oneLine(e.message);
|
|
8296
|
-
|
|
8297
|
-
return { code: e instanceof ConfigError ? 2 : 1 };
|
|
8355
|
+
return e instanceof ConfigError ? fail(2, `config error: ${msg}`, "config") : fail(1, `error: ${msg}`);
|
|
8298
8356
|
}
|
|
8299
8357
|
}
|
|
8300
8358
|
|
|
@@ -8320,8 +8378,8 @@ var BRAND2 = {
|
|
|
8320
8378
|
sourceActionRef: "chaffbroom/chaffbroom/winnow@v0",
|
|
8321
8379
|
/** Default config file name, at the repository root. */
|
|
8322
8380
|
configFile: ".winnow.yml",
|
|
8323
|
-
version: "0.3.
|
|
8324
|
-
userAgent: "chaffbroom-winnow/0.3.
|
|
8381
|
+
version: "0.3.2",
|
|
8382
|
+
userAgent: "chaffbroom-winnow/0.3.2 (+https://github.com/chaffbroom/chaffbroom/tree/main/winnow#readme)"
|
|
8325
8383
|
};
|
|
8326
8384
|
|
|
8327
8385
|
// ../winnow/src/config.ts
|
|
@@ -8440,6 +8498,17 @@ function requireEnv(env, name, provider) {
|
|
|
8440
8498
|
return v;
|
|
8441
8499
|
}
|
|
8442
8500
|
|
|
8501
|
+
// ../winnow/src/git.ts
|
|
8502
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
8503
|
+
function githubRepo2(dir) {
|
|
8504
|
+
try {
|
|
8505
|
+
const url = execFileSync2("git", ["-C", dir, "config", "--get", "remote.origin.url"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
8506
|
+
return /github\.com[:/]([\w.-]+\/[\w.-]+?)(?:\.git)?\/?$/.exec(url)?.[1];
|
|
8507
|
+
} catch {
|
|
8508
|
+
return void 0;
|
|
8509
|
+
}
|
|
8510
|
+
}
|
|
8511
|
+
|
|
8443
8512
|
// ../winnow/src/markdown.ts
|
|
8444
8513
|
var MAX_INLINE2 = 500;
|
|
8445
8514
|
var NEWLINES2 = /\r\n|[\r\n\u2028\u2029\u0085]/g;
|
|
@@ -9258,7 +9327,7 @@ Usage:
|
|
|
9258
9327
|
|
|
9259
9328
|
Options:
|
|
9260
9329
|
-c, --config <path> Config file (default ${BRAND2.configFile})
|
|
9261
|
-
-f, --format <fmt> text | markdown | json (default text)
|
|
9330
|
+
-f, --format <fmt> text | markdown | json (default text); with json, errors are JSON too
|
|
9262
9331
|
--pr <number> Only resources mapped to this PR (for the on-close workflow)
|
|
9263
9332
|
-p, --provider <id> Limit to provider(s); repeatable. One of: ${PROVIDER_IDS.join(", ")}
|
|
9264
9333
|
--show-kept Also list resources that are kept
|
|
@@ -9272,10 +9341,19 @@ Tokens are read from the environment: GITHUB_TOKEN, NEON_API_KEY, SUPABASE_ACCES
|
|
|
9272
9341
|
VERCEL_TOKEN, FLY_API_TOKEN, RAILWAY_TOKEN, CLOUDFLARE_API_TOKEN (each overridable with token_env).
|
|
9273
9342
|
A provider whose token is missing is skipped and reported; the others still run (exit 1).
|
|
9274
9343
|
Docs: ${BRAND2.docsUrl}`;
|
|
9344
|
+
function wantsJson2(argv) {
|
|
9345
|
+
return argv.some((a, i) => a === "--format=json" || a === "-fjson" || (a === "--format" || a === "-f") && argv[i + 1] === "json");
|
|
9346
|
+
}
|
|
9275
9347
|
async function run2(argv, io = {}) {
|
|
9276
9348
|
const out = io.stdout ?? ((s) => process.stdout.write(s + "\n"));
|
|
9277
9349
|
const err = io.stderr ?? ((s) => process.stderr.write(s + "\n"));
|
|
9278
9350
|
const outcome = { code: 0, orphans: 0, toDelete: 0, deleted: 0, failed: 0, markdown: "", providerErrors: 0 };
|
|
9351
|
+
const json = wantsJson2(argv);
|
|
9352
|
+
const fail = (code, message, kind = code === 2 ? "usage" : "error") => {
|
|
9353
|
+
if (json) out(JSON.stringify({ error: { kind, message: oneLine2(message.split("\n\n")[0] ?? message) }, code }));
|
|
9354
|
+
err(message);
|
|
9355
|
+
return { ...outcome, code };
|
|
9356
|
+
};
|
|
9279
9357
|
let args;
|
|
9280
9358
|
try {
|
|
9281
9359
|
args = parseArgs2({
|
|
@@ -9296,45 +9374,44 @@ async function run2(argv, io = {}) {
|
|
|
9296
9374
|
}
|
|
9297
9375
|
});
|
|
9298
9376
|
} catch (e) {
|
|
9299
|
-
|
|
9377
|
+
return fail(2, `${e.message}
|
|
9300
9378
|
|
|
9301
9379
|
${HELP2}`);
|
|
9302
|
-
return { ...outcome, code: 2 };
|
|
9303
9380
|
}
|
|
9304
9381
|
const { values, positionals } = args;
|
|
9305
9382
|
if (values.help) return out(HELP2), outcome;
|
|
9306
9383
|
if (values.version) return out(BRAND2.version), outcome;
|
|
9307
9384
|
const command = positionals[0] ?? "plan";
|
|
9308
9385
|
if (command !== "plan" && command !== "apply") {
|
|
9309
|
-
|
|
9386
|
+
return fail(2, `unknown command "${command}"
|
|
9310
9387
|
|
|
9311
9388
|
${HELP2}`);
|
|
9312
|
-
return { ...outcome, code: 2 };
|
|
9313
9389
|
}
|
|
9314
9390
|
const format = values.format ?? "text";
|
|
9315
9391
|
if (!["text", "markdown", "json"].includes(format)) {
|
|
9316
|
-
|
|
9317
|
-
return { ...outcome, code: 2 };
|
|
9392
|
+
return fail(2, `--format must be text, markdown or json`);
|
|
9318
9393
|
}
|
|
9319
9394
|
if (command === "apply" && !values.yes) {
|
|
9320
|
-
|
|
9321
|
-
return { ...outcome, code: 2 };
|
|
9395
|
+
return fail(2, 'apply deletes resources; re-run with --yes to confirm (run "plan" first to review).');
|
|
9322
9396
|
}
|
|
9323
9397
|
const providers = values.provider ?? [];
|
|
9324
9398
|
for (const p of providers) {
|
|
9325
9399
|
if (!PROVIDER_IDS.includes(p)) {
|
|
9326
|
-
|
|
9327
|
-
return { ...outcome, code: 2 };
|
|
9400
|
+
return fail(2, `unknown provider "${p}"`);
|
|
9328
9401
|
}
|
|
9329
9402
|
}
|
|
9330
9403
|
const pr = values.pr !== void 0 ? Number(values.pr) : void 0;
|
|
9331
9404
|
if (pr !== void 0 && !Number.isInteger(pr)) {
|
|
9332
|
-
|
|
9333
|
-
return { ...outcome, code: 2 };
|
|
9405
|
+
return fail(2, "--pr must be a number");
|
|
9334
9406
|
}
|
|
9335
9407
|
try {
|
|
9336
9408
|
const env = io.env ?? process.env;
|
|
9337
|
-
const
|
|
9409
|
+
const cwd = io.cwd ?? process.cwd();
|
|
9410
|
+
const config = await loadConfig2(resolve2(cwd, values.config ?? BRAND2.configFile), env);
|
|
9411
|
+
if (!config.repo) {
|
|
9412
|
+
const [owner, name] = (githubRepo2(cwd) ?? "").split("/");
|
|
9413
|
+
if (owner && name) config.repo = { owner, name };
|
|
9414
|
+
}
|
|
9338
9415
|
const reapOpen = values["reap-open"] ? true : void 0;
|
|
9339
9416
|
const p = await plan({ config, env, fetch: io.fetch, now: io.now, pr, providers, reapOpen });
|
|
9340
9417
|
outcome.providerErrors = p.errors.length;
|
|
@@ -9354,8 +9431,7 @@ ${HELP2}`);
|
|
|
9354
9431
|
return outcome;
|
|
9355
9432
|
} catch (e) {
|
|
9356
9433
|
const msg = oneLine2(e.message);
|
|
9357
|
-
|
|
9358
|
-
return { ...outcome, code: e instanceof ConfigError2 ? 2 : 1 };
|
|
9434
|
+
return e instanceof ConfigError2 ? fail(2, `config error: ${msg}`, "config") : fail(1, `error: ${msg}`);
|
|
9359
9435
|
}
|
|
9360
9436
|
}
|
|
9361
9437
|
|
|
@@ -9366,26 +9442,35 @@ var BRAND3 = {
|
|
|
9366
9442
|
/** The command (the npm bin) and the npm package name. */
|
|
9367
9443
|
bin: "chaffbroom",
|
|
9368
9444
|
npmName: "chaffbroom",
|
|
9369
|
-
version: "0.3.
|
|
9445
|
+
version: "0.3.2",
|
|
9370
9446
|
repoUrl: "https://github.com/chaffbroom/chaffbroom",
|
|
9371
9447
|
winnow: {
|
|
9372
9448
|
displayName: "Chaffbroom Winnow",
|
|
9449
|
+
actionRepo: "chaffbroom/winnow",
|
|
9450
|
+
/** The moving major tag: follows every release. Opt-in; init pins pinnedRef. */
|
|
9373
9451
|
actionRef: "chaffbroom/winnow@v0",
|
|
9374
9452
|
sourceActionRef: "chaffbroom/chaffbroom/winnow@v0",
|
|
9453
|
+
/** What init writes: the commit of the Action repo's v<pinnedVersion> tag. */
|
|
9454
|
+
pinnedRef: "chaffbroom/winnow@76ac2825f14cc3083bd99a73e1a92abdaf2eff84",
|
|
9455
|
+
pinnedVersion: "0.3.2",
|
|
9375
9456
|
configFile: ".winnow.yml",
|
|
9376
9457
|
docsUrl: "https://github.com/chaffbroom/chaffbroom/tree/main/winnow#readme"
|
|
9377
9458
|
},
|
|
9378
9459
|
tollbook: {
|
|
9379
9460
|
displayName: "Chaffbroom Tollbook",
|
|
9461
|
+
actionRepo: "chaffbroom/tollbook",
|
|
9462
|
+
/** The moving major tag: follows every release. Opt-in; init pins pinnedRef. */
|
|
9380
9463
|
actionRef: "chaffbroom/tollbook@v0",
|
|
9381
9464
|
sourceActionRef: "chaffbroom/chaffbroom/tollbook@v0",
|
|
9465
|
+
/** What init writes: the commit of the Action repo's v<pinnedVersion> tag. */
|
|
9466
|
+
pinnedRef: "chaffbroom/tollbook@b4c3a0abdcffb03fdf6777365f9b4e9ca6ca9924",
|
|
9467
|
+
pinnedVersion: "0.3.2",
|
|
9382
9468
|
configFile: ".tollbook.yml",
|
|
9383
9469
|
docsUrl: "https://github.com/chaffbroom/chaffbroom/tree/main/tollbook#readme"
|
|
9384
9470
|
}
|
|
9385
9471
|
};
|
|
9386
9472
|
|
|
9387
9473
|
// src/init.ts
|
|
9388
|
-
import { execFileSync } from "node:child_process";
|
|
9389
9474
|
import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync4, statSync } from "node:fs";
|
|
9390
9475
|
|
|
9391
9476
|
// src/safe-write.ts
|
|
@@ -9464,13 +9549,13 @@ import { parseArgs as parseArgs3 } from "node:util";
|
|
|
9464
9549
|
var winnow_default = "# Example config. Copy to the repo root as .winnow.yml and keep only the providers you use.\nversion: 1\ngithub:\n repo: your-org/your-repo # defaults to $GITHUB_REPOSITORY in Actions\n\ndefaults:\n ttl: 7d # delete previews older than this (\"never\" to disable) -- but see reap_open\n grace_after_close: 1h # wait this long after a PR closes/merges before reaping\n reap_unmapped: false # resources with no PR mapping are listed, not deleted\n reap_open: false # TTL never deletes a preview whose PR is still open (or whose PR state\n # is unknown); true lets it. Merged/closed/missing-PR rules ignore this.\n\nprotect: # names or git branches that are never touched\n - main\n - staging\n\nproviders:\n neon:\n project_id: your-neon-project-id\n ttl: 3d\n branch_pattern: '^preview/(.+)$' # Neon's Vercel integration names branches preview/<git-branch>\n\n supabase:\n project_ref: yourprojectref # PR number comes from the branch's pr_number / git_branch\n\n vercel:\n project_id: prj_yourproject\n team_id: team_yourteam\n ttl: 14d # PR number from meta.githubPrId\n\n fly:\n mode: apps # one app per PR\n org_slug: your-org\n app_pattern: '^yourapp-pr-\\d+$' # required: only names matching this are in scope\n\n railway:\n project_id: your-railway-project-id # only ephemeral (PR) environments are listed; PR number is\n # read from the environment NAME (pr_pattern) -- Railway's PR\n # naming is unverified, check `winnow plan` before `apply`\n token_kind: account # or \"project\" (uses the Project-Access-Token header)\n\n cloudflare_pages:\n account_id: your-account-id\n project_name: your-pages-project\n\n cloudflare_workers: # report-only: Cloudflare has no version delete API, never deleted\n account_id: your-account-id\n script_name: your-worker\n ttl: 30d\n";
|
|
9465
9550
|
|
|
9466
9551
|
// templates/tollbook-pr.yml
|
|
9467
|
-
var tollbook_pr_default = "# Written by `npx chaffbroom init`. Chaffbroom Tollbook posts what GitHub Actions cost on each\n# pull request (reruns and cancelled runs included) as one sticky comment, updated after each\n# workflow below finishes. It uses GITHUB_TOKEN only.\n#\n# For a budget gate that shows as a check on the PR, add the `cost` job to your PR workflow\n# instead: see examples/workflows/tollbook-pr.yml in the Chaffbroom repository.\nname: PR
|
|
9552
|
+
var tollbook_pr_default = "# Written by `npx chaffbroom init`. Chaffbroom Tollbook posts what GitHub Actions cost on each\n# pull request (reruns and cancelled runs included) as one sticky comment, updated after each\n# workflow below finishes. It uses GITHUB_TOKEN only.\n#\n# For a budget gate that shows as a check on the PR, add the `cost` job to your PR workflow\n# instead: see examples/workflows/tollbook-pr.yml in the Chaffbroom repository.\nname: Chaffbroom Tollbook PR\n\non:\n workflow_run:\n workflows: [\"CI\"] # the workflows that run on your pull requests\n types: [completed]\n\npermissions:\n actions: read\n contents: read\n pull-requests: write\n\nconcurrency:\n group: pr-cost-${{ github.event.workflow_run.head_branch }}\n cancel-in-progress: false # the newest run reports; nothing is cancelled\n\njobs:\n cost:\n # Only runs made for a PR in this repository (fork PRs are not listed on the run).\n if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.pull_requests[0] != null\n runs-on: ubuntu-slim\n steps:\n - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0\n # Pinned to the commit of a release, so a moved tag cannot change what runs. @v0\n # instead takes every 0.x release as it comes out.\n - uses: chaffbroom/tollbook@b4c3a0abdcffb03fdf6777365f9b4e9ca6ca9924 # v0.3.2\n with:\n mode: pr\n";
|
|
9468
9553
|
|
|
9469
9554
|
// templates/tollbook-weekly.yml
|
|
9470
|
-
var tollbook_weekly_default = '# Written by `npx chaffbroom init`. Chaffbroom Tollbook\'s weekly summary: the most expensive\n# workflows and the rerun waste of the last 7 days, in the job summary and as an issue.\nname:
|
|
9555
|
+
var tollbook_weekly_default = '# Written by `npx chaffbroom init`. Chaffbroom Tollbook\'s weekly summary: the most expensive\n# workflows and the rerun waste of the last 7 days, in the job summary and as an issue.\nname: Chaffbroom Tollbook weekly\n\non:\n schedule:\n - cron: "0 7 * * 1" # Mondays 07:00 UTC\n workflow_dispatch:\n\npermissions:\n actions: read\n contents: read\n issues: write\n pull-requests: read # to name the PRs of merged branches\n\njobs:\n summary:\n runs-on: ubuntu-slim\n steps:\n - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0\n # Pinned to the commit of a release, so a moved tag cannot change what runs. @v0\n # instead takes every 0.x release as it comes out.\n - uses: chaffbroom/tollbook@b4c3a0abdcffb03fdf6777365f9b4e9ca6ca9924 # v0.3.2\n with:\n mode: weekly\n days: "7"\n top: "5"\n issue: "true" # also opens an issue; the job summary always has it\n';
|
|
9471
9556
|
|
|
9472
9557
|
// templates/winnow.yml
|
|
9473
|
-
var winnow_default2 = "# Written by `npx chaffbroom init`. Chaffbroom Winnow deletes preview environments whose pull\n# request is merged, closed or missing, or that are past their TTL (rules in .winnow.yml).\n#\n# It starts in plan mode: each run lists what it would delete in the job summary and deletes\n# nothing. When the plan looks right, set WINNOW_MODE below to apply. A manual run can pick\n# the mode either way (Actions >
|
|
9558
|
+
var winnow_default2 = "# Written by `npx chaffbroom init`. Chaffbroom Winnow deletes preview environments whose pull\n# request is merged, closed or missing, or that are past their TTL (rules in .winnow.yml).\n#\n# It starts in plan mode: each run lists what it would delete in the job summary and deletes\n# nothing. When the plan looks right, set WINNOW_MODE below to apply. A manual run can pick\n# the mode either way (Actions > Chaffbroom Winnow > Run workflow).\nname: Chaffbroom Winnow\n\non:\n schedule:\n - cron: \"17 3 * * *\" # nightly: everything past its TTL or orphaned\n pull_request:\n types: [closed] # as soon as a PR closes or merges: only that PR's previews\n workflow_dispatch:\n inputs:\n mode:\n description: plan or apply\n default: plan\n\nenv:\n WINNOW_MODE: plan # plan lists, apply deletes\n\npermissions:\n contents: read\n pull-requests: read\n\nconcurrency:\n group: preview-cleanup\n cancel-in-progress: false\n\njobs:\n winnow:\n # Fork PRs get no secrets, so there is nothing to clean up with.\n if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0\n # Pinned to the commit of a release, so a moved tag cannot change what runs. @v0\n # instead takes every 0.x release as it comes out.\n - uses: chaffbroom/winnow@76ac2825f14cc3083bd99a73e1a92abdaf2eff84 # v0.3.2\n with:\n mode: ${{ inputs.mode || env.WINNOW_MODE }}\n yes: ${{ (inputs.mode || env.WINNOW_MODE) == 'apply' }}\n pr: ${{ github.event.pull_request.number }}\n max-deletes: \"50\"\n neon-api-key: ${{ secrets.NEON_API_KEY }}\n supabase-access-token: ${{ secrets.SUPABASE_ACCESS_TOKEN }}\n vercel-token: ${{ secrets.VERCEL_TOKEN }}\n fly-api-token: ${{ secrets.FLY_API_TOKEN }}\n railway-token: ${{ secrets.RAILWAY_TOKEN }}\n cloudflare-api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}\n";
|
|
9474
9559
|
|
|
9475
9560
|
// src/init.ts
|
|
9476
9561
|
var PROVIDER_SECRETS = {
|
|
@@ -9537,10 +9622,12 @@ function detectProviders(dir) {
|
|
|
9537
9622
|
}
|
|
9538
9623
|
return found;
|
|
9539
9624
|
}
|
|
9540
|
-
|
|
9625
|
+
var PUSH_TYPES = ["opened", "synchronize", "reopened"];
|
|
9626
|
+
function scanPrWorkflows(dir) {
|
|
9541
9627
|
const wf = join2(dir, WORKFLOWS);
|
|
9542
|
-
if (!existsSync2(wf)) return [];
|
|
9543
9628
|
const names = [];
|
|
9629
|
+
const skipped = [];
|
|
9630
|
+
if (!existsSync2(wf)) return { names, skipped };
|
|
9544
9631
|
for (const f of readdirSync(wf).sort()) {
|
|
9545
9632
|
if (!/\.ya?ml$/.test(f) || ["tollbook-pr.yml", "tollbook-weekly.yml", "winnow.yml"].includes(f)) continue;
|
|
9546
9633
|
let doc;
|
|
@@ -9551,20 +9638,19 @@ function prWorkflows(dir) {
|
|
|
9551
9638
|
}
|
|
9552
9639
|
if (!doc || typeof doc !== "object") continue;
|
|
9553
9640
|
const on = doc.on;
|
|
9554
|
-
const
|
|
9555
|
-
|
|
9641
|
+
const triggers = typeof on === "string" ? [[on, null]] : Array.isArray(on) ? on.map((e) => [String(e), null]) : on && typeof on === "object" ? Object.entries(on) : [];
|
|
9642
|
+
const pr = triggers.filter(([e]) => e === "pull_request" || e === "pull_request_target");
|
|
9643
|
+
if (!pr.length) continue;
|
|
9556
9644
|
const name = doc.name;
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
|
|
9562
|
-
|
|
9563
|
-
|
|
9564
|
-
return /github\.com[:/]([\w.-]+\/[\w.-]+?)(?:\.git)?\/?$/.exec(url)?.[1];
|
|
9565
|
-
} catch {
|
|
9566
|
-
return void 0;
|
|
9645
|
+
const label = typeof name === "string" && name.trim() ? name.trim() : `${WORKFLOWS}/${f}`.replaceAll("\\", "/");
|
|
9646
|
+
const onPush = pr.some(([, cfg]) => {
|
|
9647
|
+
const types = cfg && typeof cfg === "object" ? cfg.types : void 0;
|
|
9648
|
+
const list = typeof types === "string" ? [types] : Array.isArray(types) ? types.map(String) : void 0;
|
|
9649
|
+
return !list || list.some((t) => PUSH_TYPES.includes(t));
|
|
9650
|
+
});
|
|
9651
|
+
(onPush ? names : skipped).push(label);
|
|
9567
9652
|
}
|
|
9653
|
+
return { names, skipped };
|
|
9568
9654
|
}
|
|
9569
9655
|
function winnowConfig(providers, repo) {
|
|
9570
9656
|
const lines = winnow_default.split("\n");
|
|
@@ -9679,12 +9765,16 @@ async function init(argv, io = {}) {
|
|
|
9679
9765
|
}
|
|
9680
9766
|
if (doTollbook) {
|
|
9681
9767
|
const named = (v["pr-workflow"] ?? []).map((w) => w.trim()).filter(Boolean);
|
|
9682
|
-
const
|
|
9768
|
+
const scan = scanPrWorkflows(dir);
|
|
9769
|
+
const workflows = named.length ? named : scan.names;
|
|
9770
|
+
if (!named.length && scan.skipped.length) {
|
|
9771
|
+
out(`Not costed: ${scan.skipped.join(", ")} (no run when a PR is opened or pushed to, e.g. only on close). --pr-workflow NAME costs one anyway.`);
|
|
9772
|
+
}
|
|
9683
9773
|
if (workflows.length) {
|
|
9684
9774
|
out(`Workflows Tollbook costs: ${workflows.join(", ")}`);
|
|
9685
9775
|
files.push(plan2(dir, join2(WORKFLOWS, "tollbook-pr.yml"), tollbookPrWorkflow(workflows), force));
|
|
9686
9776
|
} else {
|
|
9687
|
-
out("Tollbook: no workflow here runs
|
|
9777
|
+
out("Tollbook: no workflow here runs when a pull request is opened or pushed to, so the PR cost comment is skipped. Name one with --pr-workflow.");
|
|
9688
9778
|
}
|
|
9689
9779
|
files.push(plan2(dir, join2(WORKFLOWS, "tollbook-weekly.yml"), tollbookWeeklyWorkflow(), force));
|
|
9690
9780
|
}
|
|
@@ -9730,7 +9820,18 @@ async function init(argv, io = {}) {
|
|
|
9730
9820
|
out(` Winnow runs in plan mode (it lists, it deletes nothing) until you set WINNOW_MODE: apply in ${join2(WORKFLOWS, "winnow.yml")}.`);
|
|
9731
9821
|
}
|
|
9732
9822
|
if (doTollbook) out(` ${step++}. Tollbook needs no secret: it uses the workflow's GITHUB_TOKEN.`);
|
|
9733
|
-
out(` ${step++}. Commit the files and
|
|
9823
|
+
out(` ${step++}. Commit the files, push, and merge them into your default branch. Nothing runs before that:`);
|
|
9824
|
+
out(` GitHub starts scheduled, workflow_run and manually run workflows only from the default branch,`);
|
|
9825
|
+
out(` so the pull request that adds these files gets no cost comment and no cleanup run.`);
|
|
9826
|
+
if (doTollbook) {
|
|
9827
|
+
out(` After the merge, the next pull request gets the cost comment. To see the weekly summary at once:`);
|
|
9828
|
+
out(` gh workflow run tollbook-weekly.yml${repo ? ` --repo ${repo}` : ""}`);
|
|
9829
|
+
}
|
|
9830
|
+
const pins = [...doWinnow && providers.length ? [BRAND3.winnow] : [], ...doTollbook ? [BRAND3.tollbook] : []];
|
|
9831
|
+
if (pins.length) {
|
|
9832
|
+
out(`The workflows pin ${pins.map((p) => `${p.actionRepo} to the commit of v${p.pinnedVersion}`).join(" and ")}, so a moved tag cannot change`);
|
|
9833
|
+
out(`what runs. To take every 0.x release without editing, use ${pins.map((p) => p.actionRef).join(" or ")} instead.`);
|
|
9834
|
+
}
|
|
9734
9835
|
out(`Docs: ${BRAND3.winnow.docsUrl} ${BRAND3.tollbook.docsUrl}`);
|
|
9735
9836
|
return 0;
|
|
9736
9837
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chaffbroom",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Delete orphaned preview environments (Chaffbroom Winnow) and see what GitHub Actions costs per pull request (Chaffbroom Tollbook). init writes the GitHub workflows.",
|
|
5
5
|
"license": "FSL-1.1-ALv2",
|
|
6
6
|
"author": "Chaffbroom authors",
|