From a02ee8640c7de7f56cde17d457333ed8ac2d151b Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Fri, 14 Feb 2020 06:43:36 +0100 Subject: [PATCH] Add support to upload coverage to Codecov.io (#17) - 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). --- CHANGELOG.md | 7 ++++++ README.md | 1 + azure-pipelines.yml | 60 ++++++++++++++++++++++++++++++++++----------- build.yaml | 2 ++ codecov.yml | 28 +++++++++++++++++++++ 5 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 codecov.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index dc670c0..90ccecc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/README.md b/README.md index 0695ccc..3aadb26 100644 --- a/README.md +++ b/README.md @@ -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/) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ce200f9..af2f76f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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: @@ -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 @@ -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: | diff --git a/build.yaml b/build.yaml index 2de4280..c052e03 100644 --- a/build.yaml +++ b/build.yaml @@ -51,6 +51,8 @@ Pester: ExcludeTag: Tag: CodeCoverageThreshold: 85 + CodeCoverageOutputFile: JaCoCo_coverage.xml + CodeCoverageOutputFileEncoding: ascii DscTest: ExcludeTag: diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..801349a --- /dev/null +++ b/codecov.yml @@ -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/"