Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions release-files.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@
"tests/repo/vue-scope.test.ts",
"tests/repo/workspaces.test.ts",
"tests/research/baseline/matcher.test.ts",
"tests/research/baseline/path-baseline.test.ts",
"tests/research/baseline/test-activity.test.ts",
"tests/research/baseline/workflow-parser.test.ts",
"tsconfig.check.json",
Expand Down
4 changes: 3 additions & 1 deletion src/research/baseline/path-baseline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type { TaskRegistry } from "../../planner/task-registry.js";
import { matchesAny } from "./matcher.js";
import type { ChangedFile } from "../../git/types.js";
import { LOCKFILE } from "../../repo/lockfiles.js";

export interface GenericPathBaselineResult {
selectedTaskIds: string[];
Expand Down Expand Up @@ -51,7 +52,8 @@ export function runGenericPathBaseline(taskRegistry: TaskRegistry, changedFiles:

function globalFallbackPattern(path: string): boolean {
const p = path.toLowerCase();
if (["package.json", "package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lock", "bun.lockb", "go.mod", "go.sum", "requirements.txt", "setup.py", "pyproject.toml", "cargo.toml", "cargo.lock", "pom.xml", "build.gradle", "gradle.lockfile"].includes(p)) return true;
if (LOCKFILE.test(p)) return true;
if (["package.json", "go.mod", "go.sum", "requirements.txt", "setup.py", "pyproject.toml", "cargo.toml", "cargo.lock", "pom.xml", "build.gradle", "gradle.lockfile"].includes(p)) return true;
if (p.startsWith(".github/workflows/")) return true;
if (p.startsWith("database/") || p.startsWith("migrations/")) return true;
if (p.startsWith("ops/") || p.startsWith("terraform/") || p.startsWith("docker") || p.includes("dockerfile")) return true;
Expand Down
44 changes: 44 additions & 0 deletions tests/research/baseline/path-baseline.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: MIT
import { strict as assert } from "node:assert";
import { describe, it } from "node:test";
import { runGenericPathBaseline } from "../../../src/research/baseline/path-baseline.js";
import type { ChangedFile } from "../../../src/git/types.js";
import { createTaskRegistry } from "../../../src/planner/task-registry.js";
import { LOCKFILE_NAMES } from "../../../src/repo/lockfiles.js";

describe("runGenericPathBaseline", () => {
const registry = createTaskRegistry([
{ id: "unit", command: "npm test", category: "test", inputPatterns: ["src/**"] },
{ id: "lint", command: "npm run lint", category: "lint", alwaysRun: true },
]);

function changed(...paths: string[]): ChangedFile[] {
return paths.map((p) => ({ path: p, changeType: "modified" }));
}

const FULL_FALLBACK = "global/dependency/config/workflow -> full fallback";

for (const name of LOCKFILE_NAMES) {
it(`falls back to every task when only ${name} changes (issue #97)`, () => {
const result = runGenericPathBaseline(registry, changed(name));
assert.deepEqual(result.selectedTaskIds.sort(), ["lint", "unit"]);
assert.ok(result.fallbackRequired);
assert.deepEqual(result.matchedRules, [FULL_FALLBACK]);
});
}

it("still falls back on the non-lockfile manifests", () => {
for (const name of ["package.json", "go.sum", "Cargo.lock", "pyproject.toml"]) {
const result = runGenericPathBaseline(registry, changed(name));
assert.ok(result.fallbackRequired, name);
assert.deepEqual(result.matchedRules, [FULL_FALLBACK], name);
}
});

it("does not treat a nested lockfile as a root dependency change", () => {
const result = runGenericPathBaseline(registry, changed("src/fixtures/package-lock.json"));
assert.ok(!result.fallbackRequired);
assert.deepEqual(result.selectedTaskIds.sort(), ["lint", "unit"]);
assert.ok(!result.matchedRules.includes(FULL_FALLBACK));
});
});
Loading