diff --git a/codecov.yml b/codecov.yml index 76dd25a4b..05ee97141 100644 --- a/codecov.yml +++ b/codecov.yml @@ -29,8 +29,9 @@ comment: layout: "condensed_header, diff, flags, files" require_changes: false -# Coverage is collected by vitest (v8) over src/**; mirror its exclusions so the -# Codecov total matches the local report. +# Coverage is collected by vitest (v8) over src/**, packages/gittensory-engine/src/**, +# and packages/gittensory-miner/lib/**; mirror its exclusions so the Codecov total +# matches the local report. ignore: - "src/env.d.ts" - "apps/**" diff --git a/test/unit/codecov-policy.test.ts b/test/unit/codecov-policy.test.ts index 373817946..cd464e092 100644 --- a/test/unit/codecov-policy.test.ts +++ b/test/unit/codecov-policy.test.ts @@ -75,6 +75,16 @@ describe("Codecov policy", () => { expect(testResultsUploadWith.fail_ci_if_error).toBe(false); }); + it("measures miner lib changes for codecov patch coverage (#4864)", () => { + const vitestConfig = readFileSync("vitest.config.ts", "utf8"); + expect(vitestConfig).toMatch(/packages\/gittensory-miner\/lib\/\*\*\/\*\.js/); + + const config = readYaml("codecov.yml"); + const ignore = config.ignore; + if (!Array.isArray(ignore)) throw new Error("codecov.yml ignore must be an array"); + expect(ignore.some((entry) => typeof entry === "string" && entry.includes("gittensory-miner"))).toBe(false); + }); + it("uploads fork PR coverage tokenlessly instead of silently skipping it", () => { // Fork PRs cannot read secrets.CODECOV_TOKEN. Previously the token-gated upload steps simply // excluded forks with no replacement, so codecov/patch had no report to compare against and fell diff --git a/vitest.config.ts b/vitest.config.ts index 2df10ca8f..87d6acfa1 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -26,7 +26,12 @@ export default defineConfig({ ...(junitPath ? { outputFile: { junit: junitPath } } : {}), coverage: { provider: "v8", - include: ["src/**/*.ts", "packages/gittensory-engine/src/**/*.ts", "review-enrichment/src/analyzers/codeowners.ts"], + include: [ + "src/**/*.ts", + "packages/gittensory-engine/src/**/*.ts", + "packages/gittensory-miner/lib/**/*.js", + "review-enrichment/src/analyzers/codeowners.ts", + ], exclude: ["src/env.d.ts", "apps/**"], // Emit lcov for Codecov to compute patch (changed-lines) coverage. reporter: ["text", "lcov"],