Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Azure Pipelines code coverage #237

Merged
merged 7 commits into from
Feb 6, 2020
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
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ For older change log history see the [historic changelog](HISTORIC_CHANGELOG.md)
- Added a CONTRIBUTING.md.
- Replaced module CommonResourceHelper with the PowerShell Gallery module
DscResource.Common v0.2.0.
- Adding back publishing code coverage to Codecov.io.
- Add status badge for Codecov.io in README.md.
- Fix Azure Pipelines code coverage ([issue #236](https://github.com/dsccommunity/xFailOverCluster/issues/236)).

### Changed

Expand Down Expand Up @@ -63,8 +66,6 @@ For older change log history see the [historic changelog](HISTORIC_CHANGELOG.md)
DscResource.Test cannot be imported.
- Update the deploy stage so that it is skipped when merging
branch master in forks.
- Adding back publishing code coverage to Codecov.io.
- Add stats badge for Codecov.io in README.md.
- xClusterPreferredOwner
- Fixed broken links to examples in README.md.
- xClusterQuorum
Expand Down
65 changes: 39 additions & 26 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ trigger:
- "v*"
exclude:
- "*-*"
variables:
buildFolderName: output
buildArtifactName: output
testResultFolderName: testResults
testArtifactName: testResults

stages:
- stage: Build
Expand Down Expand Up @@ -37,8 +42,8 @@ stages:
- task: PublishBuildArtifacts@1
displayName: 'Publish Build Artifact'
inputs:
pathToPublish: 'output/'
artifactName: 'output'
pathToPublish: '$(buildFolderName)/'
artifactName: $(buildArtifactName)
publishLocation: 'Container'

- stage: Test
Expand All @@ -47,7 +52,7 @@ stages:
- job: Test_HQRM
displayName: 'HQRM'
pool:
vmImage: 'win1803'
vmImage: 'windows-2019'
timeoutInMinutes: 0
steps:
- task: DownloadBuildArtifacts@0
Expand Down Expand Up @@ -75,21 +80,15 @@ stages:
- job: Test_Unit
displayName: 'Unit'
pool:
vmImage: 'win1803'
vmImage: 'windows-2019'
timeoutInMinutes: 0
steps:
- powershell: |
$repositoryOwner,$repositoryName = $env:BUILD_REPOSITORY_NAME -split '/'
echo "##vso[task.setvariable variable=RepositoryOwner;isOutput=true]$repositoryOwner"
echo "##vso[task.setvariable variable=RepositoryName;isOutput=true]$repositoryName"
name: dscBuildVariable
displayName: 'Set Environment Variables'
- task: DownloadBuildArtifacts@0
displayName: 'Download Build Artifact'
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'output'
artifactName: $(buildArtifactName)
downloadPath: '$(Build.SourcesDirectory)'
- task: PowerShell@2
name: test
Expand All @@ -103,20 +102,13 @@ stages:
condition: succeededOrFailed()
inputs:
testResultsFormat: 'NUnit'
testResultsFiles: 'output/testResults/NUnit*.xml'
testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml'
testRunTitle: 'Unit (Windows Server Core)'
- task: PublishCodeCoverageResults@1
displayName: 'Publish Code Coverage'
condition: succeededOrFailed()
inputs:
codeCoverageTool: 'JaCoCo'
summaryFileLocation: 'output/testResults/CodeCov*.xml'
pathToSources: '$(Build.SourcesDirectory)/output/$(dscBuildVariable.RepositoryName)'
- task: PublishBuildArtifacts@1
displayName: 'Publish Test Artifact'
inputs:
pathToPublish: 'output/testResults/'
artifactName: 'testResults'
pathToPublish: '$(buildFolderName)/$(testResultFolderName)/'
artifactName: $(testArtifactName)
publishLocation: 'Container'

- job: Test_Integration
Expand All @@ -130,7 +122,7 @@ stages:
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'output'
artifactName: $(buildArtifactName)
downloadPath: '$(Build.SourcesDirectory)'
- task: PowerShell@2
name: configureWinRM
Expand All @@ -151,7 +143,7 @@ stages:
condition: succeededOrFailed()
inputs:
testResultsFormat: 'NUnit'
testResultsFiles: 'output/testResults/NUnit*.xml'
testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml'
testRunTitle: 'Integration (Windows Server Core)'

- job: Code_Coverage
Expand All @@ -161,16 +153,37 @@ stages:
vmImage: 'ubuntu 16.04'
timeoutInMinutes: 0
steps:
- pwsh: |
$repositoryOwner,$repositoryName = $env:BUILD_REPOSITORY_NAME -split '/'
echo "##vso[task.setvariable variable=RepositoryOwner;isOutput=true]$repositoryOwner"
echo "##vso[task.setvariable variable=RepositoryName;isOutput=true]$repositoryName"
name: dscBuildVariable
displayName: 'Set Environment Variables'
- task: DownloadBuildArtifacts@0
displayName: 'Download Build Artifact'
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'testResults'
downloadPath: '$(Build.SourcesDirectory)/output'
artifactName: $(buildArtifactName)
downloadPath: '$(Build.SourcesDirectory)'
- task: DownloadBuildArtifacts@0
displayName: 'Download Test Artifact'
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: $(testArtifactName)
downloadPath: '$(Build.SourcesDirectory)/$(buildFolderName)'
- task: PublishCodeCoverageResults@1
displayName: 'Publish Azure Code Coverage'
condition: succeededOrFailed()
inputs:
codeCoverageTool: 'JaCoCo'
summaryFileLocation: '$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml'
pathToSources: '$(Build.SourcesDirectory)/$(buildFolderName)/$(dscBuildVariable.RepositoryName)'
- script: |
bash <(curl -s https://codecov.io/bash) -f "./output/testResults/JaCoCo_coverage.xml"
bash <(curl -s https://codecov.io/bash) -f "./$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml"
displayName: 'Upload to Codecov.io'
condition: succeededOrFailed()

- stage: Deploy
dependsOn: Test
Expand Down