From ed2e10d4f4b29af750b96899f703b6b47cf4dbfd Mon Sep 17 00:00:00 2001 From: luvs01 Date: Fri, 7 Aug 2026 20:14:59 +0900 Subject: [PATCH] fix(ci): reject renamed-away tests as coverage --- .github/scripts/pr-hygiene.cjs | 6 ++++-- .github/scripts/pr-hygiene.test.cjs | 13 +++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/scripts/pr-hygiene.cjs b/.github/scripts/pr-hygiene.cjs index a910be674c..554d4851eb 100644 --- a/.github/scripts/pr-hygiene.cjs +++ b/.github/scripts/pr-hygiene.cjs @@ -143,8 +143,10 @@ function assessHygiene({ files = [], labels = [] }) { const behaviorChanged = allPaths.some( (path) => isBehaviorPath(path) && !commentOnlyPaths.has(path), ); - // Deleted tests add no coverage and must not satisfy the regression gate. - const testsChanged = allPaths.some( + // Deleted or renamed-away tests add no coverage and must not satisfy the + // regression gate. Previous paths still classify behavior and generated + // files above, but only a current test path counts as regression coverage. + const testsChanged = filenames.some( (path) => isTestPath(path) && !removedFilenames.has(path), ); diff --git a/.github/scripts/pr-hygiene.test.cjs b/.github/scripts/pr-hygiene.test.cjs index 16f5f79a37..1a2565a7ea 100644 --- a/.github/scripts/pr-hygiene.test.cjs +++ b/.github/scripts/pr-hygiene.test.cjs @@ -186,6 +186,19 @@ describe("assessHygiene", () => { assert.equal(failures[0].code, "missing_regression_test"); }); + it("does not count renamed-away tests as regression coverage", () => { + const failures = assessHygiene({ files: [ + { filename: "src/router.ts", patch: "+change" }, + { + filename: "docs/router.md", + previous_filename: "tests/router.test.ts", + status: "renamed", + patch: "", + }, + ] }); + assert.equal(failures[0].code, "missing_regression_test"); + }); + it("allows maintainer-approved narrow exceptions", () => { const failures = assessHygiene({ files: [