willfire 0.1.36 → 0.1.37

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.
@@ -11,9 +11,8 @@ export function parseArgs(argv) {
11
11
  console.error(USAGE);
12
12
  process.exit(2);
13
13
  }
14
- // An unrecognised action is refused rather than ignored. Silently falling
15
- // back to the guess would turn a typo into a wrong prediction, which is the
16
- // failure this flag exists to remove.
14
+ // Refused, not ignored: falling back to the guess would turn a typo into a
15
+ // wrong prediction, the failure this flag exists to remove.
17
16
  const action = get("--action");
18
17
  if (action !== undefined && !isPrEventAction(action)) {
19
18
  console.error(`unknown --action: ${action}`);
package/dist/cli.js CHANGED
@@ -1,9 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  // Usage: pnpm predict --repo owner/name --pr N [--json]
3
- //
4
- // Auth: GH_TOKEN or GITHUB_TOKEN env var (any token with
5
- // contents/actions/pull-requests read). Inside an action, pass the workflow's
6
- // GITHUB_TOKEN.
3
+ // Auth: GH_TOKEN or GITHUB_TOKEN, needing contents/actions/pull-requests read.
7
4
  import { parseArgs } from "./cli/parseArgs.js";
8
5
  import { isWorkflowEntry } from "./entries/isWorkflowEntry.js";
9
6
  import { makeGithubClient } from "./predict/makeGithubClient.js";
@@ -33,8 +30,8 @@ if (isMain) {
33
30
  }
34
31
  }
35
32
  }
36
- // Last, and on the skip path too, so a red gate's first question which
37
- // commits was this read from? — is answered wherever the reader lands.
33
+ // Last, and on the skip path too, so a red gate's reader always sees which
34
+ // commits this was read from.
38
35
  for (const s of sources) {
39
36
  console.log(`# read ${s.owner}/${s.repo}@${s.ref} -> ${s.sha}`);
40
37
  }
@@ -1,10 +1,3 @@
1
1
  import type { Scope } from "../expr/val.js";
2
- /**
3
- * A scope with the fixed pull-request facts filled in.
4
- *
5
- * Every `${{ }}` this module evaluates — a job `if:`, a matrix axis — is
6
- * evaluated for the same event, so they all get the same `github.*`. Anything
7
- * the caller states wins; there is nothing here worth overriding, but a scope
8
- * that silently ignored what it was handed would be the wrong shape.
9
- */
2
+ /** Anything the caller states wins over the defaults. */
10
3
  export declare const prScope: (scope: Scope) => Scope;
@@ -1,18 +1,10 @@
1
1
  /**
2
- * The `github.*` values that are fixed for everything this module predicts.
3
- * `predict` only ever answers for a pull request, so `event_name` is not a
4
- * variable which is what lets a `github.event_name == 'pull_request'` guard
5
- * resolve instead of hanging the job on an unknown.
2
+ * `predict` only ever answers for a pull request, so `event_name` is fixed —
3
+ * which is what lets a `github.event_name == 'pull_request'` guard resolve
4
+ * instead of hanging the job on an unknown.
6
5
  */
7
6
  const PR_GITHUB_CONTEXT = { event_name: "pull_request" };
8
- /**
9
- * A scope with the fixed pull-request facts filled in.
10
- *
11
- * Every `${{ }}` this module evaluates — a job `if:`, a matrix axis — is
12
- * evaluated for the same event, so they all get the same `github.*`. Anything
13
- * the caller states wins; there is nothing here worth overriding, but a scope
14
- * that silently ignored what it was handed would be the wrong shape.
15
- */
7
+ /** Anything the caller states wins over the defaults. */
16
8
  export const prScope = (scope) => ({
17
9
  ...scope,
18
10
  github: { ...PR_GITHUB_CONTEXT, ...scope.github },
@@ -1,6 +1,6 @@
1
1
  /**
2
- * GitHub cuts a display name over 100 characters to 97 plus `...`. Verified
3
- * on a live dispatch (dirsql PR #1013): the cap applies to the leaf name
4
- * before any reusable-call prefixing, so it lives here, not on the entry.
2
+ * GitHub cuts a display name over 100 characters to 97 plus `...`. Verified on
3
+ * dirsql PR #1013: the cap applies to the leaf name before any reusable-call
4
+ * prefixing, so it lives here, not on the entry.
5
5
  */
6
6
  export declare function capDisplayName(name: string): string;
@@ -1,7 +1,7 @@
1
1
  /**
2
- * GitHub cuts a display name over 100 characters to 97 plus `...`. Verified
3
- * on a live dispatch (dirsql PR #1013): the cap applies to the leaf name
4
- * before any reusable-call prefixing, so it lives here, not on the entry.
2
+ * GitHub cuts a display name over 100 characters to 97 plus `...`. Verified on
3
+ * dirsql PR #1013: the cap applies to the leaf name before any reusable-call
4
+ * prefixing, so it lives here, not on the entry.
5
5
  */
6
6
  export function capDisplayName(name) {
7
7
  return name.length > 100 ? `${name.slice(0, 97)}...` : name;
@@ -70,7 +70,6 @@ export interface GithubClient {
70
70
  }): Promise<{
71
71
  data: GithubCommit;
72
72
  }>;
73
- /** The file at `path` as text — always the `raw` media type. */
74
73
  getContent(params: RepoParams & {
75
74
  path: string;
76
75
  ref: string;
@@ -1,6 +1,5 @@
1
- // The GitHub REST surface willfire uses: a handful of GET endpoints plus the
2
- // tarball download, over plain `fetch`. The shape mirrors the octokit subset
3
- // it replaced (#75) so call sites and their fakes carry over unchanged.
1
+ // Plain `fetch`, shaped to mirror the octokit subset it replaced (#75) so call
2
+ // sites and their fakes carry over unchanged.
4
3
  export function makeGithubClient() {
5
4
  const token = process.env.GH_TOKEN ?? process.env.GITHUB_TOKEN;
6
5
  if (!token) {
@@ -76,9 +75,8 @@ export function makeGithubClient() {
76
75
  },
77
76
  },
78
77
  },
79
- // A short page ends the walk. A count landing exactly on a page boundary
80
- // costs one extra empty-page request, which keeps this free of Link-header
81
- // parsing.
78
+ // A short page ends the walk. An exact page boundary costs one extra empty
79
+ // request, which keeps this free of Link-header parsing.
82
80
  paginate: async (route, params) => {
83
81
  const perPage = params.per_page ?? 30;
84
82
  const all = [];
@@ -1,7 +1,4 @@
1
- /**
2
- * The node major the image ships — also the refusal boundary for `setup-node`
3
- * and `node2x` runtimes asking for any other major.
4
- */
1
+ /** Also the refusal boundary: `setup-node` and `node2x` get no other major. */
5
2
  export declare const SANDBOX_NODE_MAJOR = 24;
6
3
  export declare const DOCKERFILE = "FROM node:24-slim\nRUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates python3 && rm -rf /var/lib/apt/lists/*\n";
7
4
  export interface SandboxConfig {
@@ -1,7 +1,4 @@
1
- /**
2
- * The node major the image ships — also the refusal boundary for `setup-node`
3
- * and `node2x` runtimes asking for any other major.
4
- */
1
+ /** Also the refusal boundary: `setup-node` and `node2x` get no other major. */
5
2
  export const SANDBOX_NODE_MAJOR = 24;
6
3
  // git and python3: checkout's postcondition and the interpreters a script on
7
4
  // a GitHub-hosted runner takes for granted.
@@ -1,15 +1,12 @@
1
1
  import type { UsesTarget } from "../types.js";
2
2
  /**
3
- * Split a job-level `uses:` into the file it names and the repo it lives in.
4
- *
5
3
  * Two spellings are legal:
6
4
  *
7
5
  * `./.github/workflows/x.yml` -> the caller's repo, same commit
8
6
  * `owner/repo/.github/workflows/x.yml@ref` -> another repo, at `ref`
9
7
  *
10
- * The ref is taken from the last `@` so a branch containing a slash
11
- * (`@feature/foo`) survives. Returns null for anything elseincluding a
12
- * reference built from an expression, which we cannot evaluate and so must not
13
- * guess a fetch target for.
8
+ * The ref comes off the last `@`, so a branch with a slash survives. Anything
9
+ * else is null, including a reference built from an expression no fetch
10
+ * target to guess at.
14
11
  */
15
12
  export declare function parseUses(uses: string): UsesTarget | null;
@@ -1,16 +1,13 @@
1
1
  import { EXPRESSION_RE } from "../names/jobDisplayName.js";
2
2
  /**
3
- * Split a job-level `uses:` into the file it names and the repo it lives in.
4
- *
5
3
  * Two spellings are legal:
6
4
  *
7
5
  * `./.github/workflows/x.yml` -> the caller's repo, same commit
8
6
  * `owner/repo/.github/workflows/x.yml@ref` -> another repo, at `ref`
9
7
  *
10
- * The ref is taken from the last `@` so a branch containing a slash
11
- * (`@feature/foo`) survives. Returns null for anything elseincluding a
12
- * reference built from an expression, which we cannot evaluate and so must not
13
- * guess a fetch target for.
8
+ * The ref comes off the last `@`, so a branch with a slash survives. Anything
9
+ * else is null, including a reference built from an expression no fetch
10
+ * target to guess at.
14
11
  */
15
12
  export function parseUses(uses) {
16
13
  if (EXPRESSION_RE.test(uses)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "willfire",
3
- "version": "0.1.36",
3
+ "version": "0.1.37",
4
4
  "description": "Predict the set of CI check entries GitHub Actions will create for a pull request",
5
5
  "license": "MIT",
6
6
  "packageManager": "pnpm@10.33.0",