Skip to content

Commit c28fb22

Browse files
xumiaqiluo-msft
authored andcommitted
[ci]: Support PR coverage (sonic-net#1806)
The output log will be collected by subsequent pipelines to generate Pull Request coverage reports. And if a branch wants to enforce the coverage rate, we can simply and "--fail-under SCORE" in the cover-diff command, see detail in https://diff-cover.readthedocs.io/en/latest/README.html
1 parent 2a8957d commit c28fb22

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

azure-pipelines.yml

+8
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ stages:
8282
python3 setup.py test
8383
displayName: 'Test Python 3'
8484
85+
- script: |
86+
sudo pip3 install diff-cover
87+
target_branch=$(System.PullRequest.TargetBranch)
88+
compare_branch=origin/${target_branch#refs/heads/}
89+
diff-cover coverage.xml --compare-branch=$compare_branch
90+
condition: eq(variables['Build.Reason'], 'PullRequest')
91+
displayName: "Diff coverage"
92+
8593
- task: PublishTestResults@2
8694
inputs:
8795
testResultsFiles: '$(System.DefaultWorkingDirectory)/test-results.xml'

0 commit comments

Comments
 (0)