diff --git a/build-tools/packages/build-cli/src/codeCoverage/compareCodeCoverage.ts b/build-tools/packages/build-cli/src/codeCoverage/compareCodeCoverage.ts
index 05d68b8e541d..89113bdd382f 100644
--- a/build-tools/packages/build-cli/src/codeCoverage/compareCodeCoverage.ts
+++ b/build-tools/packages/build-cli/src/codeCoverage/compareCodeCoverage.ts
@@ -34,7 +34,8 @@ const codeCoverageComparisonIgnoreList: string[] = [
];
/**
- * Type for the code coverage report generated by comparing the baseline and pr code coverage
+ * Type for the code coverage report generated by comparing the baseline and pr code coverage. We are noting both line and branch coverage
+ * here but as part of the code coverage comparison check, we are only using branch coverage.
*/
export interface CodeCoverageComparison {
/**
@@ -159,8 +160,7 @@ export function getPackagesWithCodeCoverageChanges(
// Find existing packages that have reported a change in coverage for the current PR
const existingPackagesWithCoverageChange = codeCoverageComparisonData.filter(
- (codeCoverageReport) =>
- codeCoverageReport.branchCoverageDiff !== 0 || codeCoverageReport.lineCoverageDiff !== 0,
+ (codeCoverageReport) => codeCoverageReport.branchCoverageDiff !== 0,
);
logger?.verbose(
`Found ${existingPackagesWithCoverageChange.length} packages with code coverage changes`,
@@ -184,8 +184,7 @@ export function isCodeCoverageCriteriaPassed(
const { codeCoverageComparisonForNewPackages, codeCoverageComparisonForExistingPackages } =
codeCoverageChangeForPackages;
const packagesWithNotableRegressions = codeCoverageComparisonForExistingPackages.filter(
- (codeCoverageReport: CodeCoverageComparison) =>
- codeCoverageReport.branchCoverageDiff < -1 || codeCoverageReport.lineCoverageDiff < -1,
+ (codeCoverageReport: CodeCoverageComparison) => codeCoverageReport.branchCoverageDiff < -1,
);
logger?.verbose(
@@ -194,8 +193,7 @@ export function isCodeCoverageCriteriaPassed(
// Code coverage for the newly added package should be less than 50% to fail.
const newPackagesWithNotableRegressions = codeCoverageComparisonForNewPackages.filter(
- (codeCoverageReport) =>
- codeCoverageReport.branchCoverageInPr < 50 || codeCoverageReport.lineCoverageInPr < 50,
+ (codeCoverageReport) => codeCoverageReport.branchCoverageInPr < 50,
);
logger?.verbose(
diff --git a/build-tools/packages/build-cli/src/codeCoverage/getCommentForCodeCoverage.ts b/build-tools/packages/build-cli/src/codeCoverage/getCommentForCodeCoverage.ts
index 8ba80fb57b6f..cb03f7eac83c 100644
--- a/build-tools/packages/build-cli/src/codeCoverage/getCommentForCodeCoverage.ts
+++ b/build-tools/packages/build-cli/src/codeCoverage/getCommentForCodeCoverage.ts
@@ -73,10 +73,8 @@ const getCodeCoverageSummary = (
const summary = codeCoverageComparisonReport
.sort(
(report1, report2) =>
- // Sort the diff summary of packages based on the total coverage diff(line coverage + branch coverage)
- report1.branchCoverageDiff +
- report1.lineCoverageDiff -
- (report2.branchCoverageDiff + report2.lineCoverageDiff),
+ // Sort the diff summary of packages based on the total coverage diff(branch coverage)
+ report1.branchCoverageDiff - report2.branchCoverageDiff,
)
.map((coverageReport) => getCodeCoverageSummaryForPackages(coverageReport))
.reduce((prev, current) => prev + current);
@@ -87,9 +85,9 @@ const getCodeCoverageSummary = (
const getCodeCoverageSummaryForPackages = (coverageReport: CodeCoverageComparison): string => {
const metrics = codeCoverageDetailsHeader + getMetricRows(coverageReport);
- return `${getGlyphForHtml(coverageReport.branchCoverageDiff + coverageReport.lineCoverageDiff)} ${
+ return `
${metrics}${getGlyphForHtml(coverageReport.branchCoverageDiff)} ${
coverageReport.packagePath
- }:
Line Coverage Change: ${formatDiff(coverageReport.lineCoverageDiff)} Branch Coverage Change: ${formatDiff(
+ }:
Branch Coverage Change: ${formatDiff(
coverageReport.branchCoverageDiff,
)}