Add inline diff coverage check to Azure Pipeline#597
Add inline diff coverage check to Azure Pipeline#597hdwhdw wants to merge 5 commits intosonic-net:masterfrom
Conversation
Replace the black-box Azure-Pipelines-Wrapper GitHub App with an inline DiffCoverageCheck job that runs diff-cover against combined pure and integration coverage artifacts. Changes: - Add DiffCoverageCheck job depending on PureCIJob and build - Publish coverage XML as pipeline artifacts from both jobs - Add fetchDepth: 0 to build job for git merge-base support - Remove unused DIFF_COVER_* variables from MemoryLeakJob and build - Add DIFF_COVER_THRESHOLD top-level variable (80%) - Upgrade PublishCodeCoverageResults to v2 - Add diff-cover Makefile target for local testing - Add dummy test packages for PR validation Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
This PR replaces the Azure-Pipelines-Wrapper GitHub App with a first-party Azure Pipelines job that runs diff-cover against combined pure + integration coverage artifacts to enforce inline diff coverage on PRs.
Changes:
- Adds a
DiffCoverageCheckjob that downloads published coverage artifacts and runsdiff-coverwith a configurable threshold. - Publishes pure and integration Cobertura XML files as pipeline artifacts and upgrades
PublishCodeCoverageResultsto v2. - Adds a local
make diff-covertarget and introduces dummy packages wired into pure/integration test package lists.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
azure-pipelines.yml |
Adds diff-cover gating job, publishes coverage artifacts, sets fetchDepth: 0, and upgrades coverage publishing task version. |
pure.mk |
Adds testpkg/pure to the “pure” package set so it runs in pure CI/coverage. |
Makefile |
Adds testpkg/integration to integration basic packages and introduces a diff-cover convenience target. |
testpkg/pure/math.go |
Dummy pure functions to generate diff lines for coverage validation. |
testpkg/pure/math_test.go |
Dummy tests with intentionally incomplete coverage. |
testpkg/integration/helper.go |
Dummy integration-like helper functions to generate diff lines for coverage validation. |
testpkg/integration/helper_test.go |
Dummy tests with intentionally incomplete coverage. |
testpkg/integration/helper.go
Outdated
| // Repeat returns s repeated n times. | ||
| func Repeat(s string, n int) string { | ||
| result := "" | ||
| for i := 0; i < n; i++ { | ||
| result += s | ||
| } | ||
| return result | ||
| } |
There was a problem hiding this comment.
Repeat builds the result via result += s inside a loop, which causes repeated allocations/copies (quadratic behavior as n grows). Use strings.Repeat(s, n) or a strings.Builder/[]byte preallocation approach to keep runtime and allocations predictable.
There was a problem hiding this comment.
Dismissed — dummy packages have been removed.
With a single checkout step, Azure Pipelines checks out directly into the working directory without a subdirectory. Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
The DiffCoverageCheck job was validated in build 1048370. Removing the temporary testpkg/ packages and their Makefile/pure.mk entries. Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
…re coverage in Makefile - Remove codeCoverageTool input from PublishCodeCoverageResults@2 (v2 auto-detects) - Add succeeded() guard to DiffCoverageCheck condition to skip on upstream failure - Include test-results/coverage-pure.xml in Makefile diff-cover target for parity with pipeline Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
…lity The Azure-Pipelines-Wrapper GitHub App needs these variables to complete its check. They can be removed once the app is uninstalled. Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Why I did it
The
coverage.sonic-net.sonic-gnmi.buildGitHub Check is posted by a black-box GitHub App ("Azure-Pipelines-Wrapper") with no code visibility. Moving diff coverage enforcement into the publicazure-pipelines.ymlfollows infrastructure-as-code principles and makes the check transparent and maintainable.How I did it
Added a new DiffCoverageCheck job in the Build stage that:
PureCIJobandbuildjobsdiff-coveragainst the combined coverage datacondition: eq(variables['Build.Reason'], 'PullRequest'))Other changes:
fetchDepth: 0to build job checkout forgit merge-basesupportDIFF_COVER_*variables from MemoryLeakJob and build jobDIFF_COVER_THRESHOLDtop-level variable (80%)PublishCodeCoverageResultsfrom v1 to v2diff-coverMakefile target for local testingHow to verify it
Validated in build 1048370. The DiffCoverageCheck job ran and correctly reported diff coverage on the dummy test packages (which were intentionally under-tested):
The dummy test packages have been removed in the latest commit since they served only as validation vehicles.
After merging, the Azure-Pipelines-Wrapper GitHub App can be uninstalled from the repository.
Which release branch to backport (provide reason below if selected)
Description for the changelog
Replace black-box Azure-Pipelines-Wrapper GitHub App with inline diff coverage check in Azure Pipeline YAML.
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)