Skip to content

Commit

Permalink
Support azp diff coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
xumia committed Jul 13, 2021
1 parent 6be76f4 commit 69eac92
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -41,21 +50,28 @@ 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()
displayName: 'Publish Python 3 test results'
- 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'

0 comments on commit 69eac92

Please sign in to comment.