From 69eac92a05b5dd61293b9787d5d35a8e3559bf0d Mon Sep 17 00:00:00 2001 From: xumia Date: Tue, 13 Jul 2021 09:21:35 +0000 Subject: [PATCH] Support azp diff coverage --- azure-pipelines.yml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6b4455d6..7a2117a3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -30,6 +30,15 @@ stages: clean: true submodules: recursive displayName: 'Checkout code' + - script: | + set -x + wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb + sudo dpkg -i packages-microsoft-prod.deb + sudo apt-get update + sudo apt-get install -y dotnet-sdk-5.0 + sudo pip3 install pytest pytest-azurepipelines + sudo pip3 install pytest-cov + displayName: "Install build tools" - script: | set -ex @@ -41,14 +50,21 @@ stages: set -ex sudo python3 -m pip install dist/swsssdk-2.0.1-py3-none-any.whl - python3 setup.py test + python3 -m pytest --doctest-modules --junitxml=junit/test-results.xml --cov=. --cov-report=xml displayName: "Unit tests" + - 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" - publish: $(Build.ArtifactStagingDirectory) artifact: sonic-py-swsssdk displayName: "Archive artifacts" - task: PublishTestResults@2 inputs: - testResultsFiles: '$(System.DefaultWorkingDirectory)/test-results.xml' + testResultsFiles: '**/test-*.xml' testRunTitle: Python 3 failTaskOnFailedTests: true condition: succeededOrFailed() @@ -56,6 +72,6 @@ stages: - task: PublishCodeCoverageResults@1 inputs: codeCoverageTool: Cobertura - summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage.xml' - reportDirectory: '$(System.DefaultWorkingDirectory)/htmlcov/' + summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' + additionalCodeCoverageFiles: '$(System.DefaultWorkingDirectory)/**/*.coverage' displayName: 'Publish Python 3 test coverage'