Skip to content

Commit

Permalink
Merge pull request #111 from xumia/azp-coverage
Browse files Browse the repository at this point in the history
Install dot net 5.0 to support code coverage to improve the azp coverage ui
Support pull request diff coverage
  • Loading branch information
xumia authored Aug 28, 2021
2 parents 482cac2 + 69eac92 commit d07682e
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 d07682e

Please sign in to comment.