Skip to content

Commit

Permalink
Add support to upload coverage to Codecov.io (#17)
Browse files Browse the repository at this point in the history
- GPRegistryPolicyDsc
  - Add support to upload coverage to Codecov.io (issue #16).
- GPRegistryPolicyDsc
  - Change the Azure Pipelines Microsoft Host Agents to use the image 
    `windows-2019` (issue #15).
  • Loading branch information
johlju authored Feb 14, 2020
1 parent c54daed commit a02ee86
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 14 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- GPRegistryPolicyDsc
- Add support to upload coverage to Codecov.io ([issue #16](https://github.com/dsccommunity/GPRegistryPolicyDsc/issues/16)).

### Fixed

- GPRegistryPolicyDsc
Expand All @@ -14,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- GPRegistryPolicyDsc
- Set a display name on all the jobs and tasks in the CI pipeline.
- Change the Azure Pipelines Microsoft Host Agents to use the image
`windows-2019` ([issue #15](https://github.com/dsccommunity/GPRegistryPolicyDsc/issues/15)).

## [1.1.0] - 2020-01-05

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Build Status](https://dev.azure.com/dsccommunity/GPRegistryPolicyDsc/_apis/build/status/dsccommunity.GPRegistryPolicyDsc?branchName=master)](https://dev.azure.com/dsccommunity/GPRegistryPolicyDsc/_build/latest?definitionId=12&branchName=master)
![Azure DevOps coverage (branch)](https://img.shields.io/azure-devops/coverage/dsccommunity/GPRegistryPolicyDsc/12/master)
[![codecov](https://codecov.io/gh/dsccommunity/GPRegistryPolicyDsc/branch/master/graph/badge.svg)](https://codecov.io/gh/dsccommunity/GPRegistryPolicyDsc)
[![Azure DevOps tests](https://img.shields.io/azure-devops/tests/dsccommunity/GPRegistryPolicyDsc/12/master)](https://dsccommunity.visualstudio.com/GPRegistryPolicyDsc/_test/analytics?definitionId=12&contextType=build)
[![PowerShell Gallery (with prereleases)](https://img.shields.io/powershellgallery/vpre/GPRegistryPolicyDsc?label=GPRegistryPolicyDsc%20Preview)](https://www.powershellgallery.com/packages/GPRegistryPolicyDsc/)
[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/GPRegistryPolicyDsc?label=GPRegistryPolicyDsc)](https://www.powershellgallery.com/packages/GPRegistryPolicyDsc/)
Expand Down
60 changes: 46 additions & 14 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,9 @@ 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:
Expand All @@ -102,18 +96,17 @@ stages:
testResultsFormat: 'NUnit'
testResultsFiles: 'output/testResults/NUnit*.xml'
testRunTitle: 'Unit (Windows Server Core)'
- task: PublishCodeCoverageResults@1
displayName: 'Publish Code Coverage'
condition: succeededOrFailed()
- task: PublishBuildArtifacts@1
displayName: 'Publish Test Artifact'
inputs:
codeCoverageTool: 'JaCoCo'
summaryFileLocation: 'output/testResults/CodeCov*.xml'
pathToSources: '$(Build.SourcesDirectory)/output/$(dscBuildVariable.RepositoryName)'
pathToPublish: 'output/testResults/'
artifactName: 'testResults'
publishLocation: 'Container'

- job: Test_Integration
displayName: 'Integration'
pool:
vmImage: 'win1803'
vmImage: 'windows-2019'
timeoutInMinutes: 0
steps:
- task: DownloadBuildArtifacts@0
Expand Down Expand Up @@ -145,6 +138,45 @@ stages:
testResultsFiles: 'output/testResults/NUnit*.xml'
testRunTitle: 'Integration (Windows Server Core)'

- job: Code_Coverage
displayName: 'Publish Code Coverage'
dependsOn: Test_Unit
pool:
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: 'output'
downloadPath: '$(Build.SourcesDirectory)'
- task: DownloadBuildArtifacts@0
displayName: 'Download Test Artifact'
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'testResults'
downloadPath: '$(Build.SourcesDirectory)/output'
- task: PublishCodeCoverageResults@1
displayName: 'Publish Code Coverage'
condition: succeededOrFailed()
inputs:
codeCoverageTool: 'JaCoCo'
summaryFileLocation: 'output/testResults/JaCoCo_coverage.xml'
pathToSources: '$(Build.SourcesDirectory)/output/$(dscBuildVariable.RepositoryName)'
- script: |
bash <(curl -s https://codecov.io/bash) -f "./output/testResults/JaCoCo_coverage.xml"
displayName: 'Upload to Codecov.io'
condition: succeededOrFailed()
- stage: Deploy
dependsOn: Test
condition: |
Expand Down
2 changes: 2 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Pester:
ExcludeTag:
Tag:
CodeCoverageThreshold: 85
CodeCoverageOutputFile: JaCoCo_coverage.xml
CodeCoverageOutputFileEncoding: ascii

DscTest:
ExcludeTag:
Expand Down
28 changes: 28 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
codecov:
require_ci_to_pass: no
# master should be the baseline for reporting
branch: master

comment:
layout: "reach, diff"
behavior: default

coverage:
range: 50..80
round: down
precision: 0

status:
project:
default:
# Set the overall project code coverage requirement to 70%
target: 70
patch:
default:
# Set the pull request requirement to not regress overall coverage by more than 5%
# and let codecov.io set the goal for the code changed in the patch.
target: auto
threshold: 5

fixes:
- "\d+\.\d+\.\d+\/::source/" # move path "X.Y.Z/" => "source/"

0 comments on commit a02ee86

Please sign in to comment.