From 17208a085fabec4ba16c4e6a29080947fb6b33be Mon Sep 17 00:00:00 2001 From: xumia <59720581+xumia@users.noreply.github.com> Date: Tue, 14 Sep 2021 23:14:04 +0800 Subject: [PATCH] [ci]: Support PR coverage (#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 --- azure-pipelines.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 002d4dffdd69..be1bd8e5f3b9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -91,6 +91,14 @@ stages: python3 setup.py test displayName: 'Test Python 3' + - script: | + sudo pip3 install diff-cover + target_branch=$(System.PullRequest.TargetBranch) + compare_branch=origin/${target_branch#refs/heads/} + diff-cover coverage.xml --compare-branch=$compare_branch + condition: eq(variables['Build.Reason'], 'PullRequest') + displayName: "Diff coverage" + - task: PublishTestResults@2 inputs: testResultsFiles: '$(System.DefaultWorkingDirectory)/test-results.xml'