Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions .azure-devops/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,32 @@ stages:
- template: templates/run-tests.yml
parameters:
path: 'azext_iot/tests/central'
name: 'IoT-Central'
name: 'iot-central'

- job: 'testADT'
displayName: 'Test Azure DigitalTwins'
steps:
- template: templates/run-tests.yml
parameters:
path: 'azext_iot/tests/digitaltwins'
name: 'Azure-DigitalTwins'
name: 'azure-digitaltwins'

- job: 'testDPS'
displayName: 'Test DPS'
steps:
- template: templates/run-tests.yml
parameters:
path: 'azext_iot/tests/dps'
name: 'Device-Provisioning-Service'
name: 'device-provisioning-service'

- job: 'testHub'
displayName: 'Test IoT Hub'
steps:
- template: templates/run-tests.yml
parameters:
path: 'azext_iot/tests/iothub'
name: 'IoT-Hub'
name: 'iot-hub'

- job: 'unitTests'
displayName: 'Unit tests and code coverage'
steps:
Expand All @@ -95,6 +95,18 @@ stages:

- template: templates/install-and-record-version.yml

- stage: 'kpi'
displayName: 'Build KPIs'
dependsOn: [build, test]
jobs:
- job: 'calculateCodeCoverage'
displayName: 'Calculate distributed code coverage'
steps:
- template: templates/calculate-code-coverage.yml
parameters:
pythonVersion: $(pythonVersion)
architecture: $(architecture)

- stage: 'release'
displayName: 'Stage GitHub release'
dependsOn: [build, test]
Expand Down
2 changes: 2 additions & 0 deletions .azure-devops/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ jobs:
runUnitTests: 'true'
runIntTests: 'false'

- template: templates/calculate-code-coverage.yml

- job: 'run_unit_tests_windows'
dependsOn : [ 'build_and_publish_azure_iot_cli_ext', 'build_and_publish_azure_cli_test_sdk']
pool:
Expand Down
34 changes: 34 additions & 0 deletions .azure-devops/templates/calculate-code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
parameters:
pythonVersion: '3.6.x'
architecture: 'x64'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: ${{ parameters.pythonVersion }}
architecture: ${{ parameters.architecture }}

- template: setup-ci-machine.yml

- task: DownloadBuildArtifacts@0
displayName : 'Download code coverage KPIs'
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'coverage'
downloadPath: '$(System.ArtifactsDirectory)/aziotext_kpi/'

- bash: |
ls -l ./coverage
export COVERAGE_FILE=.coverage.combined
for i in ./coverage/.coverage.*; do
coverage combine -a $i
done
coverage xml --rcfile="$(System.DefaultWorkingDirectory)/.coveragerc"
workingDirectory: '$(System.ArtifactsDirectory)/aziotext_kpi/'
displayName: 'Merging code coverage data'

- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(System.ArtifactsDirectory)/aziotext_kpi/coverage.xml'
24 changes: 14 additions & 10 deletions .azure-devops/templates/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ parameters:
runIntTests: 'true'
runWithAzureCliReleased: 'true'
path: 'azext_iot/tests'
name: 'All'
name: 'all'

steps:
- template: setup-dev-test-env.yml
Expand All @@ -23,18 +23,22 @@ steps:
azureSubscription: AzIoTCLIService
scriptType: bash
scriptLocation: inlineScript
inlineScript: pytest -vv ${{ parameters.path }} -k "_int" --junitxml=junit/test-iotext-int-${{ parameters.name }}.xml
inlineScript: |
export COVERAGE_FILE=.coverage.${{ parameters.name }}
pytest -vv ${{ parameters.path }} -k "_int" --cov=azext_iot --cov-config .coveragerc --junitxml=junit/test-iotext-int-${{ parameters.name }}.xml

- ${{ if eq(parameters.runUnitTests, 'true') }}:
- script: pytest -vv ${{ parameters.path }} -k "_unit" --cov=azext_iot --cov-config .coveragerc --junitxml=junit/test-iotext-unit-${{ parameters.name }}.xml --cov-report=xml
- script: |
pytest -vv ${{ parameters.path }} -k "_unit" --cov=azext_iot --cov-config .coveragerc --junitxml=junit/test-iotext-unit-${{ parameters.name }}.xml
displayName: '${{ parameters.name }} unit tests'

- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/htmlcov'
additionalCodeCoverageFiles: '$(System.DefaultWorkingDirectory)/htmlcov/**/*.*'
env:
COVERAGE_FILE: .coverage.${{ parameters.name }}

- task: PublishBuildArtifacts@1
inputs:
pathToPublish: .coverage.${{ parameters.name }}
publishLocation: 'Container'
artifactName: 'coverage'

- task: PublishTestResults@2
condition: succeededOrFailed()
Expand Down