Skip to content

Commit

Permalink
fix: handle new files in cov report (#968)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgwozdz authored Apr 11, 2024
1 parent 5543f19 commit 9a0ebda
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions ci/format-branch-coverage-changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ const coverageSummary = require('../.coverage_json/coverage-summary.json');
const markdownFilePath = '.branch-coverage-changes.md';

if (!existsSync('.coverage_changes_json/coverage-summary.json')) {
writeFileSync(markdownFilePath, `## Coverage Report (change vs master)
writeFileSync(
markdownFilePath,
`## Coverage Report (change vs master)
No changes.
`, 'utf8');
return;
`,
'utf8',
);
process.exit();
}

const coverageChangesSummary = require('../.coverage_changes_json/coverage-summary.json');
Expand All @@ -21,10 +25,22 @@ const rows = Object.entries(coverageChangesSummary)
const masterCoverage = coverageSummary[packageFilePath];
return [
packageFilePath,
formatCovComparison(changesCoverage.statements.pct, masterCoverage.statements.pct),
formatCovComparison(changesCoverage.branches.pct, masterCoverage.branches.pct),
formatCovComparison(changesCoverage.functions.pct, masterCoverage.functions.pct),
formatCovComparison(changesCoverage.lines.pct, masterCoverage.lines.pct)
formatCovComparison(
changesCoverage.statements.pct,
masterCoverage?.statements?.pct || 0,
),
formatCovComparison(
changesCoverage.branches.pct,
masterCoverage?.branches?.pct || 0,
),
formatCovComparison(
changesCoverage.functions.pct,
masterCoverage?.functions?.pct || 0,
),
formatCovComparison(
changesCoverage.lines.pct,
masterCoverage?.lines?.pct || 0,
),
];
});

Expand Down

0 comments on commit 9a0ebda

Please sign in to comment.