Skip to content
Merged
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
96 changes: 50 additions & 46 deletions .pipelines/templates/run-unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ stages:
} 3>&1;
} | { read xs; exit $xs; }
} 4>&1

# combine coverage from multiple modules
(echo "mode: atomic"; tail -q -n +2 coverage-*.out) > coverage.cover
mv coverage.cover linux-coverage.out
Expand Down Expand Up @@ -62,53 +62,57 @@ stages:
targetPath: 'windows-coverage.out'
artifactName: 'windows-coverage'

- stage: code_coverage
displayName: Code Coverage Check
dependsOn:
- test
jobs:
- job: coverage
displayName: Check Coverage
pool:
name: "$(BUILD_POOL_NAME_DEFAULT)"
steps:
- task: DownloadPipelineArtifact@2
inputs:
artifact: 'linux-coverage'
path: './'
- bash: |
# use go work to include multiple modules or gocov will omit results from those modules
make workspace
# Looking for PRs from merge queue
# Expected output refs/heads/gh-readonly-queue/master/pr-3780-f0a96a1
- ${{ if contains(variables['Build.SourceBranch'], 'master/pr') }}:
- stage: code_coverage
displayName: Code Coverage Check
dependsOn:
- test
jobs:
- job: coverage
displayName: Check Coverage
pool:
name: "$(BUILD_POOL_NAME_DEFAULT)"
steps:
- task: DownloadPipelineArtifact@2
inputs:
artifact: 'linux-coverage'
path: './'
- bash: |
# use go work to include multiple modules or gocov will omit results from those modules
make workspace

make tools
sudo ln -s $(pwd)/build/tools/bin/gocov /usr/local/bin/gocov
sudo ln -s $(pwd)/build/tools/bin/gocov-xml /usr/local/bin/gocov-xml
make tools
sudo ln -s $(pwd)/build/tools/bin/gocov /usr/local/bin/gocov
sudo ln -s $(pwd)/build/tools/bin/gocov-xml /usr/local/bin/gocov-xml

GOOS=linux gocov convert linux-coverage.out > linux-coverage.json
GOOS=linux gocov-xml < linux-coverage.json > linux-coverage.xml
GOOS=linux gocov convert linux-coverage.out > linux-coverage.json
GOOS=linux gocov-xml < linux-coverage.json > linux-coverage.xml

# TODO: Add windows coverage back in once PublishCodeCoverageResults v2 works with BuildQualityChecks
# TODO: Add windows coverage back in once PublishCodeCoverageResults v2 works with BuildQualityChecks

mkdir coverage
mkdir coverage

mv linux-coverage.xml coverage/
name: "Coverage"
displayName: "Generate Coverage Report"
condition: always()
- task: PublishCodeCoverageResults@1
displayName: "Publish Code Coverage Report"
condition: always()
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: coverage/linux-coverage.xml
- task: BuildQualityChecks@8
displayName: "Check Code Coverage Regression"
condition: always()
inputs:
checkCoverage: true
coverageFailOption: "build"
coverageType: "lines"
fallbackOnPRTargetBranch: false
baseBranchRef: "master"
allowCoverageVariance: true
coverageVariance: 0.25
mv linux-coverage.xml coverage/
name: "Coverage"
displayName: "Generate Coverage Report"
condition: always()

- task: PublishCodeCoverageResults@1
displayName: "Publish Code Coverage Report"
condition: always()
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: coverage/linux-coverage.xml
- task: BuildQualityChecks@8
displayName: "Check Code Coverage Regression"
condition: always()
inputs:
checkCoverage: true
coverageFailOption: "build"
coverageType: "lines"
fallbackOnPRTargetBranch: false
baseBranchRef: "master"
allowCoverageVariance: true
coverageVariance: 0.25
Loading