Public: anyone can read this; the crew can change it.
Automate a review finding as a lint or test: Direction: the owner's order is pipeline first (#6534, #6611, #5276, #3316, #621 #13753
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/13748-automate-a-review-finding-as-a-lint-or-t → main 1 commit fork
2 files
changed +30
−3
src/kernel/direction.ts +15 −3
| @@ -6,6 +6,11 @@ | ||
| 6 | 6 | * `src/checks/`, `forge.json`) must say why it goes ahead of the pipeline |
| 7 | 7 | * items, as `Direction: <why>` in a commit message. |
| 8 | 8 | * |
| 9 | * Vendored code is a feature too (#13748): four reviews (#10317, #11263, | |
| 10 | * #12444, #13651) asked for the same direction, and #10317 added about 90k | |
| 11 | * lines of vendored code that no page or screen path caught. A file added | |
| 12 | * under a `vendor/` directory counts once per directory. | |
| 13 | * | |
| 9 | 14 | * Four more reviews (#11289, #11696, #12177, #12307) accepted that waiver and |
| 10 | 15 | * still said "keep it small and single-purpose" (#12363). So the waiver buys |
| 11 | 16 | * a small pull only: at most `MAX_FEATURES` added feature files and |
| @@ -15,6 +20,7 @@ | ||
| 15 | 20 | import type { Change } from "./pin_edits.ts"; |
| 16 | 21 | |
| 17 | 22 | const FEATURE = /^(src\/web\/pages\/[^/]+\.ts|src\/tui\/.+\.ts|docs\/features\/[^/]+\.md)$/; |
| 23 | const VENDORED = /^(.*\/)?vendor\//; | |
| 18 | 24 | const PIPELINE = /^(scripts\/|src\/flow\/|src\/nightly\/|src\/checks\/|forge\.json$)/; |
| 19 | 25 | /** A feature pull that goes ahead of the pipeline: one page and its how-to. */ |
| 20 | 26 | export const MAX_FEATURES = 2; |
| @@ -37,9 +43,15 @@ export function directionProblems( | ||
| 37 | 43 | messages: readonly string[], |
| 38 | 44 | lines: ReadonlyMap<string, number> = new Map(), |
| 39 | 45 | ): string[] { |
| 40 | const features = changes | |
| 41 | .filter((c) => FEATURE.test(c.path) && (c.status.startsWith("A") || (lines.get(c.path) ?? 0) >= REDESIGN_LINES)) | |
| 42 | .map((c) => c.path); | |
| 46 | const vendored = changes | |
| 47 | .filter((c) => c.status.startsWith("A") && VENDORED.test(c.path)) | |
| 48 | .map((c) => `${VENDORED.exec(c.path)?.[0]}`); | |
| 49 | const features = [ | |
| 50 | ...changes | |
| 51 | .filter((c) => FEATURE.test(c.path) && (c.status.startsWith("A") || (lines.get(c.path) ?? 0) >= REDESIGN_LINES)) | |
| 52 | .map((c) => c.path), | |
| 53 | ...new Set(vendored), | |
| 54 | ]; | |
| 43 | 55 | if (features.length === 0) return []; |
| 44 | 56 | if (changes.some((c) => PIPELINE.test(c.path))) return []; |
| 45 | 57 | if (!messages.some((m) => WAIVER.test(m))) return [problem(features)]; |
test/direction.test.ts +15
| @@ -49,3 +49,18 @@ test("a waived feature pull stays small and single-purpose, naming the rule", () | ||
| 49 | 49 | expect(directionProblems(many, why)[0]).toContain("changes 21 files"); |
| 50 | 50 | expect(directionProblems([...many, ch("M", "scripts/gate.ts")], why)).toEqual([]); |
| 51 | 51 | }); |
| 52 | ||
| 53 | test("vendored code added under vendor/ is a feature, once per directory, naming the rule (#13748)", () => { | |
| 54 | const vendored = [ | |
| 55 | ch("A", "src/web/render/vendor/three/build/three.core.js"), | |
| 56 | ch("A", "src/web/render/vendor/three/build/three.module.js"), | |
| 57 | ]; | |
| 58 | const out = directionProblems(vendored, ["Render STL"]); | |
| 59 | expect(out).toHaveLength(1); | |
| 60 | expect(out[0]).toContain('rule "pipeline first"'); | |
| 61 | expect(out[0]).toContain("src/web/render/vendor/"); | |
| 62 | expect(out[0]).not.toContain("and 1 more"); | |
| 63 | expect(directionProblems(vendored, ["Direction: the owner asked for 3D files on #10317"])).toEqual([]); | |
| 64 | expect(directionProblems([...vendored, ch("M", "scripts/gate.ts")], [])).toEqual([]); | |
| 65 | expect(directionProblems([ch("M", "src/web/render/vendor/three/README.md")], [])).toEqual([]); | |
| 66 | }); |
new above
offline