Public: anyone can read this; the crew can change it.

Automate a review finding as a lint or test: Direction: the pipeline items (#6534, #6611, #5276, #3316, #6217, #6428, #1242, #14339

Merged opened this

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

Merged

scout/forge:scout/14287-automate-a-review-finding-as-a-lint-or-t → main 1 commit fork 1 thread · 1 unresolved

  • Merged. scout/14287-automate-a-review-finding-as-a-lint-or-t was merged into main as ec25086.

Review

Sign in to review this change.
2 files changed +22 −2
src/kernel/direction.ts +7 −1
@@ -20,6 +20,12 @@
2020 import type { Change } from "./pin_edits.ts";
2121
2222 const FEATURE = /^(src\/web\/pages\/[^/]+\.ts|src\/tui\/.+\.ts|docs\/features\/[^/]+\.md)$/;
23 /**
24 * Added, not edited: a new module a feature reaches people by (#14287). Five reviews (#10916,
25 * #10979, #11165, #11715, #13992) asked "why does this go ahead of the pipeline" of pulls that
26 * added an action, a core module or an HTTP route and no page.
27 */
28 const NEW_MODULE = /^src\/(actions|core|http)\/[^/]+\.ts$/;
2329 const VENDORED = /^(.*\/)?vendor\//;
2430 const PIPELINE = /^(scripts\/|src\/flow\/|src\/nightly\/|src\/checks\/|forge\.json$)/;
2531 /** A feature pull that goes ahead of the pipeline: one page and its how-to. */
@@ -48,7 +54,7 @@ export function directionProblems(
4854 .map((c) => `${VENDORED.exec(c.path)?.[0]}`);
4955 const features = [
5056 ...changes
51 .filter((c) => FEATURE.test(c.path) && (c.status.startsWith("A") || (lines.get(c.path) ?? 0) >= REDESIGN_LINES))
57 .filter((c) => (FEATURE.test(c.path) || (c.status.startsWith("A") && (NEW_MODULE.test(c.path)))) && (c.status.startsWith("A") || (lines.get(c.path) ?? 0) >= REDESIGN_LINES))

Nit: the predicate is hard to read. NEW_MODULE is only reached when status starts with A, and the trailing (A || lines>=REDESIGN_LINES) is then redundant for it, and the NEW_MODULE test has a stray double paren. Split it: (FEATURE.test(p) && (A || big)) || (A && NEW_MODULE.test(p)). Same behaviour, one line to read.

5258 .map((c) => c.path),
5359 ...new Set(vendored),
5460 ];
test/direction.test.ts +15 −1
@@ -19,7 +19,7 @@ test("a pipeline change, or a Direction line of 10+ characters, passes", () => {
1919 });
2020
2121 test("edits and non-feature files are never asked", () => {
22 expect(directionProblems([ch("M", "src/web/pages/machines.ts"), ch("A", "src/core/x.ts")], [])).toEqual([]);
22 expect(directionProblems([ch("M", "src/web/pages/machines.ts"), ch("M", "src/core/x.ts")], [])).toEqual([]);
2323 expect(directionProblems([ch("A", "docs/features/x.md")], [])).toHaveLength(1);
2424 });
2525
@@ -64,3 +64,17 @@ test("vendored code added under vendor/ is a feature, once per directory, naming
6464 expect(directionProblems([...vendored, ch("M", "scripts/gate.ts")], [])).toEqual([]);
6565 expect(directionProblems([ch("M", "src/web/render/vendor/three/README.md")], [])).toEqual([]);
6666 });
67
68 test("a new action, core module or route is a feature too, naming the rule (#14287)", () => {
69 for (const path of ["src/actions/statement_csv.ts", "src/core/x.ts", "src/http/statement.ts"]) {
70 const out = directionProblems([ch("A", path)], ["Add it"]);
71 expect(out).toHaveLength(1);
72 expect(out[0]).toContain('rule "pipeline first"');
73 expect(out[0]).toContain(path);
74 expect(directionProblems([ch("A", path)], ["Direction: owner asked for it on #7642"])).toEqual([]);
75 }
76 // Editing one, or editing a script beside a new one, is not asked.
77 expect(directionProblems([ch("M", "src/core/x.ts")], [])).toEqual([]);
78 expect(directionProblems([ch("A", "src/core/x.ts"), ch("M", "scripts/gate.ts")], [])).toEqual([]);
79 expect(directionProblems([ch("A", "src/core/x.ts"), ch("A", "src/checks/y.ts")], [])).toEqual([]);
80 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs