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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

mason/forge:mason/13748-automate-a-review-finding-as-a-lint-or-t → main 1 commit fork

  • Merged. mason/13748-automate-a-review-finding-as-a-lint-or-t was merged into main as be5f669.

Review

Sign in to review this change.
2 files changed +30 −3
src/kernel/direction.ts +15 −3
@@ -6,6 +6,11 @@
66 * `src/checks/`, `forge.json`) must say why it goes ahead of the pipeline
77 * items, as `Direction: <why>` in a commit message.
88 *
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 *
914 * Four more reviews (#11289, #11696, #12177, #12307) accepted that waiver and
1015 * still said "keep it small and single-purpose" (#12363). So the waiver buys
1116 * a small pull only: at most `MAX_FEATURES` added feature files and
@@ -15,6 +20,7 @@
1520 import type { Change } from "./pin_edits.ts";
1621
1722 const FEATURE = /^(src\/web\/pages\/[^/]+\.ts|src\/tui\/.+\.ts|docs\/features\/[^/]+\.md)$/;
23 const VENDORED = /^(.*\/)?vendor\//;
1824 const PIPELINE = /^(scripts\/|src\/flow\/|src\/nightly\/|src\/checks\/|forge\.json$)/;
1925 /** A feature pull that goes ahead of the pipeline: one page and its how-to. */
2026 export const MAX_FEATURES = 2;
@@ -37,9 +43,15 @@ export function directionProblems(
3743 messages: readonly string[],
3844 lines: ReadonlyMap<string, number> = new Map(),
3945 ): 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 ];
4355 if (features.length === 0) return [];
4456 if (changes.some((c) => PIPELINE.test(c.path))) return [];
4557 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", ()
4949 expect(directionProblems(many, why)[0]).toContain("changes 21 files");
5050 expect(directionProblems([...many, ch("M", "scripts/gate.ts")], why)).toEqual([]);
5151 });
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 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs