@vvedantb/config 0.12.0 → 0.13.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#333](https://github.com/vvedantb/packages/pull/333) [`659811a`](https://github.com/vvedantb/packages/commit/659811aa48efa54b1a6f3c8f908d1fa78d34d16b) Thanks [@vvedantb](https://github.com/vvedantb)! - `ci-runner` now matches the new Boat runner policy. Check jobs use `boat` (or `boat-small`). `boat-large` is only for Android release builds: the `release-android-apk.yml` and `release-gallery-android.yml` workflows, or a workflow file with `android` in its name. A `boat-large` runner on a `ci-app.yml` job fails. An unknown `boat*` label such as `boat-medium` fails and the message lists the valid labels.
8
+
3
9
  ## 0.12.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -202,7 +202,7 @@ Each check has a stable id:
202
202
  | `oxlint-script` | No `lint` script that runs `oxlint`. |
203
203
  | `config-version` | The `@vvedantb/config` range floor is an older minor than the running `vvedantb-doctor` version. |
204
204
  | `ci-reusable-workflow` | No workflow calls `vvedantb/packages/.github/workflows/ci-app.yml`. |
205
- | `ci-runner` | A workflow has `runs-on: boat` or `runs_on: boat`. Every boat.dev job runs on `boat-large`. GitHub-hosted labels pass. |
205
+ | `ci-runner` | A job uses a runner the Boat policy does not allow. `boat`, `boat-small` and `boat-xlarge` pass, as do GitHub-hosted labels and `${{ ... }}` expressions. `boat-large` is for Android release builds only: it passes as `runs_on` for `release-android-apk.yml` or `release-gallery-android.yml`, or in a workflow file with `android` in its name, and fails on check jobs such as `ci-app.yml`. An unknown `boat*` label such as `boat-medium` fails. |
206
206
  | `ci-commands` | A line in the `commands` input of the shared workflow is not `lint`, `typecheck` or `test` and has no written reason, or a reason names a command that CI does not run. |
207
207
 
208
208
  **CI commands.** The standard commands are `pnpm lint`, `pnpm typecheck` and `pnpm test` (`npm run` or `bun run` also pass, and so does `--filter <package>`). Every other line needs a reason, keyed by the exact command, in `.vvedantb-doctor.json` or under `vvedantbDoctor.ciCommands` in the root `package.json`:
package/dist/doctor.d.ts CHANGED
@@ -62,8 +62,15 @@ export declare function isOlderMinor(range: string, running: string): boolean;
62
62
  export declare function checkConfigVersion(repo: RepoModel, runningVersion: string): CheckResult;
63
63
  export declare function checkCiReusableWorkflow(repo: RepoModel): CheckResult;
64
64
  /**
65
- * Fails on a job that names the small `boat` runner, as `runs-on: boat` or as the `runs_on: boat`
66
- * input of a reusable workflow. GitHub-hosted labels and `boat-large` pass.
65
+ * Checks the Boat runner policy on every `runs-on` line and every `runs_on` input of a reusable
66
+ * workflow.
67
+ *
68
+ * - `boat-small`, `boat` and `boat-xlarge` pass.
69
+ * - GitHub-hosted labels (any label not starting `boat`) and expressions (`${{ ... }}`) pass.
70
+ * - `boat-large` passes as the `runs_on` input of a job that calls `release-android-apk.yml` or
71
+ * `release-gallery-android.yml`, and on any job in a workflow file whose name contains `android`.
72
+ * It fails elsewhere, including on a job that calls the shared `ci-app.yml`.
73
+ * - An unknown `boat*` label (for example `boat-medium`) fails.
67
74
  */
68
75
  export declare function checkCiRunner(repo: RepoModel): CheckResult;
69
76
  /** The lines of every `commands: |` block in the workflows that call the shared ci-app.yml. */
package/dist/doctor.js CHANGED
@@ -341,29 +341,93 @@ function workflowFiles(root) {
341
341
  }
342
342
  return files;
343
343
  }
344
- /** The plain `boat` runner label. Every boat.dev job runs on `boat-large` (8 cores, 15 GB). */
345
- const SMALL_RUNNER = "boat";
344
+ const BOAT_LABELS = ["boat-small", "boat", "boat-large", "boat-xlarge"];
345
+ const BOAT_GUIDANCE = "check jobs use boat; boat-large is for Android release builds";
346
+ const ANDROID_RELEASE_WORKFLOW = /(?:^|\/)(?:release-android-apk|release-gallery-android)\.ya?ml(?:@|$)/;
347
+ const CI_APP_WORKFLOW = /(?:^|\/)ci-app\.ya?ml(?:@|$)/;
346
348
  /**
347
- * Fails on a job that names the small `boat` runner, as `runs-on: boat` or as the `runs_on: boat`
348
- * input of a reusable workflow. GitHub-hosted labels and `boat-large` pass.
349
+ * Scans a workflow for runner lines and for each job's own `uses:` value (the reusable workflow
350
+ * it calls). Jobs are the keys one level under `jobs:`. A `uses:` counts only at the job's own
351
+ * level, so a step's `uses: actions/checkout` is ignored.
349
352
  */
350
- export function checkCiRunner(repo) {
351
- const details = [];
352
- for (const file of workflowFiles(repo.root)) {
353
- file.text.split(/\r?\n/).forEach((line, index) => {
354
- const match = line.match(/^\s*(?:-\s+)?(runs[-_]on)\s*:\s*(.+?)\s*(?:#.*)?$/);
355
- if (!match?.[1] || match[2] === undefined)
353
+ function scanRunners(text) {
354
+ const runners = [];
355
+ const jobUses = [];
356
+ let inJobs = false;
357
+ let jobIndent = -1;
358
+ let childIndent = -1;
359
+ let job = -1;
360
+ text.split(/\r?\n/).forEach((line, index) => {
361
+ if (line.trim() === "" || line.trim().startsWith("#"))
362
+ return;
363
+ const indent = line.length - line.trimStart().length;
364
+ if (indent === 0)
365
+ inJobs = /^jobs\s*:/.test(line);
366
+ if (inJobs && indent > 0) {
367
+ if (jobIndent < 0)
368
+ jobIndent = indent;
369
+ if (indent === jobIndent && /^\s*[\w.-]+\s*:/.test(line)) {
370
+ job = jobUses.length;
371
+ jobUses.push(undefined);
372
+ childIndent = -1;
356
373
  return;
357
- const labels = match[2]
374
+ }
375
+ if (job >= 0 && childIndent < 0 && indent > jobIndent)
376
+ childIndent = indent;
377
+ const uses = line.match(/^\s*uses\s*:\s*(.+?)\s*(?:#.*)?$/);
378
+ if (uses?.[1] && job >= 0 && indent === childIndent)
379
+ jobUses[job] = stripQuotes(uses[1]);
380
+ }
381
+ const match = line.match(/^\s*(?:-\s+)?(runs[-_]on)\s*:\s*(.+?)\s*(?:#.*)?$/);
382
+ if (!match?.[1] || match[2] === undefined)
383
+ return;
384
+ const labels = match[2].includes("${{")
385
+ ? [match[2]]
386
+ : match[2]
358
387
  .replace(/^\[|\]$/g, "")
359
388
  .split(",")
360
389
  .map((label) => stripQuotes(label));
361
- if (labels.includes(SMALL_RUNNER)) {
362
- details.push(`.github/workflows/${file.name}:${index + 1} ${match[1]} is ${SMALL_RUNNER}; use boat-large`);
390
+ runners.push({ line: index + 1, key: match[1], labels, job: inJobs ? job : -1 });
391
+ });
392
+ return { runners, jobUses };
393
+ }
394
+ /**
395
+ * Checks the Boat runner policy on every `runs-on` line and every `runs_on` input of a reusable
396
+ * workflow.
397
+ *
398
+ * - `boat-small`, `boat` and `boat-xlarge` pass.
399
+ * - GitHub-hosted labels (any label not starting `boat`) and expressions (`${{ ... }}`) pass.
400
+ * - `boat-large` passes as the `runs_on` input of a job that calls `release-android-apk.yml` or
401
+ * `release-gallery-android.yml`, and on any job in a workflow file whose name contains `android`.
402
+ * It fails elsewhere, including on a job that calls the shared `ci-app.yml`.
403
+ * - An unknown `boat*` label (for example `boat-medium`) fails.
404
+ */
405
+ export function checkCiRunner(repo) {
406
+ const details = [];
407
+ for (const file of workflowFiles(repo.root)) {
408
+ const { runners, jobUses } = scanRunners(file.text);
409
+ const androidFile = /android/i.test(file.name);
410
+ for (const runner of runners) {
411
+ const uses = runner.job >= 0 ? jobUses[runner.job] : undefined;
412
+ const where = `.github/workflows/${file.name}:${runner.line} ${runner.key}`;
413
+ for (const label of runner.labels) {
414
+ if (label.includes("${{") || !label.startsWith("boat"))
415
+ continue;
416
+ if (label === "boat-large") {
417
+ if (androidFile)
418
+ continue;
419
+ if (runner.key === "runs_on" && uses !== undefined && ANDROID_RELEASE_WORKFLOW.test(uses))
420
+ continue;
421
+ const caller = uses !== undefined && CI_APP_WORKFLOW.test(uses) ? " on a ci-app.yml job" : "";
422
+ details.push(`${where} is boat-large${caller}; ${BOAT_GUIDANCE}`);
423
+ }
424
+ else if (!BOAT_LABELS.includes(label)) {
425
+ details.push(`${where} is ${label}, an unknown boat label; valid labels are ${BOAT_LABELS.join(", ")}`);
426
+ }
363
427
  }
364
- });
428
+ }
365
429
  }
366
- return result("ci-runner", "No job runs on the small boat runner", details);
430
+ return result("ci-runner", "Jobs use valid Boat runners and boat-large only for Android release builds", details);
367
431
  }
368
432
  /** The lines of every `commands: |` block in the workflows that call the shared ci-app.yml. */
369
433
  export function ciCommands(repo) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vvedantb/config",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "license": "MIT",
5
5
  "description": "Shared tsconfig bases, oxlint base, Vite, Vitest, Babel and Metro presets, a WXT preset and host-permission helper for Chrome extensions, pinned tool versions, a sync CLI for Claude commands, CLAUDE.md, Cursor environment and Convex tsconfig, a packaged Electron app.asar module check, a shared header and footer check, a no-source-text-in-tests check, shared oxlint JS plugins and a CLI that adds an extension to Clerk's allowed origins.",
6
6
  "type": "module",