Skip to content

Commit 4d3c374

Browse files
committed
fix(detail): ensure workingDirectory is taken into account
When using `working-directory`, the paths in the output of `lcov` do not have the prefix. This means that the filenames from GitHub will never match those of the coverage report, and no changes will be shown.
1 parent fea161a commit 4d3c374

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

dist/main/index.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ async function run() {
1818
const titlePrefix = core.getInput('title-prefix');
1919
const additionalMessage = core.getInput('additional-message');
2020
const updateComment = core.getInput('update-comment') === 'true';
21+
const workingDirectory = core.getInput('working-directory').trim() || './';
2122

22-
await genhtml(coverageFiles, tmpPath);
23+
await genhtml(coverageFiles, tmpPath, workingDirectory);
2324

2425
const coverageFile = await mergeCoverages(coverageFiles, tmpPath);
2526
const totalCoverage = lcovTotal(coverageFile);
@@ -34,7 +35,7 @@ async function run() {
3435
if (hasGithubToken && isPR) {
3536
const octokit = await github.getOctokit(gitHubToken);
3637
const summary = await summarize(coverageFile);
37-
const details = await detail(coverageFile, octokit);
38+
const details = await detail(coverageFile, workingDirectory, octokit);
3839
const sha = github.context.payload.pull_request.head.sha;
3940
const shaShort = sha.substr(0, 7);
4041
const commentHeaderPrefix = `### ${titlePrefix ? `${titlePrefix} ` : ''}[LCOV](https://github.com/marketplace/actions/report-lcov) of commit`;
@@ -101,8 +102,7 @@ async function upsertComment(body, commentHeaderPrefix, octokit) {
101102
}
102103
}
103104

104-
async function genhtml(coverageFiles, tmpPath) {
105-
const workingDirectory = core.getInput('working-directory').trim() || './';
105+
async function genhtml(coverageFiles, tmpPath, workingDirectory) {
106106
const artifactName = core.getInput('artifact-name').trim();
107107
const artifactPath = path.resolve(tmpPath, 'html').trim();
108108
const args = [...coverageFiles, '--rc', 'lcov_branch_coverage=1'];
@@ -178,7 +178,7 @@ async function summarize(coverageFile) {
178178
return lines.join('\n');
179179
}
180180

181-
async function detail(coverageFile, octokit) {
181+
async function detail(coverageFile, workingDirectory, octokit) {
182182
let output = '';
183183

184184
const options = {};
@@ -222,7 +222,7 @@ async function detail(coverageFile, octokit) {
222222
for (const changedFile of changedFiles) {
223223
console.log(`${line} === ${changedFile}`);
224224

225-
if (line.startsWith(changedFile)) return true;
225+
if (path.join(workingDirectory, line).startsWith(changedFile)) return true;
226226
}
227227

228228
return false;

0 commit comments

Comments
 (0)