diff --git a/CHANGELOG.md b/CHANGELOG.md index 31d0e34..4bf31cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 branch to `main`. - Updated `GitVersion.yml` to latest pattern - Fixes [Issue #87](https://github.com/dsccommunity/WSManDsc/issues/87). - Updated build to use `Sampler.GitHubTasks` - Fixes [Issue #90](https://github.com/dsccommunity/WSManDsc/issues/90). +- Added support for publishing code coverage to `CodeCov.io` and + Azure Pipelines - Fixes [Issue #91](https://github.com/dsccommunity/WSManDsc/issues/91). ## [3.1.1] - 2020-01-31 diff --git a/README.md b/README.md index c484e46..0f04465 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ [![Azure DevOps tests](https://img.shields.io/azure-devops/tests/dsccommunity/WSManDsc/6/main)](https://dsccommunity.visualstudio.com/WSManDsc/_test/analytics?definitionId=6&contextType=build) [![PowerShell Gallery (with prereleases)](https://img.shields.io/powershellgallery/vpre/WSManDsc?label=WSManDsc%20Preview)](https://www.powershellgallery.com/packages/WSManDsc/) [![PowerShell Gallery](https://img.shields.io/powershellgallery/v/WSManDsc?label=WSManDsc)](https://www.powershellgallery.com/packages/WSManDsc/) +[![codecov](https://codecov.io/gh/dsccommunity/WSManDsc/branch/main/graph/badge.svg)](https://codecov.io/gh/dsccommunity/WSManDsc) The **WSManDsc** module contains DSC resources for configuring WS-Management and PowerShell Remoting. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 816e11c..7691bd1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,6 +11,13 @@ trigger: exclude: - "*-*" +variables: + buildFolderName: output + buildArtifactName: output + testResultFolderName: testResults + testArtifactName: testResults + sourceFolderName: source + stages: - stage: Build jobs: @@ -36,12 +43,13 @@ stages: env: ModuleVersion: $(gitVersion.Informationalversion) - - task: PublishBuildArtifacts@1 - displayName: 'Publish Build Artifact' + - task: PublishPipelineArtifact@1 + displayName: 'Publish Pipeline Artifact' inputs: - PathtoPublish: 'output/' - ArtifactName: 'output' - publishLocation: 'Container' + targetPath: '$(buildFolderName)/' + artifact: $(buildArtifactName) + publishLocation: 'pipeline' + parallel: true - stage: Test dependsOn: Build @@ -52,13 +60,12 @@ stages: vmImage: 'windows-2019' timeoutInMinutes: 0 steps: - - task: DownloadBuildArtifacts@0 - displayName: 'Download Build Artifact' + - task: DownloadPipelineArtifact@2 + displayName: 'Download Pipeline Artifact' inputs: buildType: 'current' - downloadType: 'single' - artifactName: 'output' - downloadPath: '$(Build.SourcesDirectory)' + artifactName: $(buildArtifactName) + targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)' - task: PowerShell@2 name: Test @@ -72,7 +79,7 @@ stages: displayName: 'Publish Test Results' inputs: testResultsFormat: 'NUnit' - testResultsFiles: 'output/testResults/NUnit*.xml' + testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' testRunTitle: 'HQRM' condition: succeededOrFailed() @@ -87,12 +94,13 @@ stages: echo "##vso[task.setvariable variable=RepositoryOwner;isOutput=true]$repositoryOwner" echo "##vso[task.setvariable variable=RepositoryName;isOutput=true]$repositoryName" name: dscBuildVariable - - task: DownloadBuildArtifacts@0 + + - task: DownloadPipelineArtifact@2 + displayName: 'Download Pipeline Artifact' inputs: buildType: 'current' - downloadType: 'single' - artifactName: 'output' - downloadPath: '$(Build.SourcesDirectory)' + artifactName: $(buildArtifactName) + targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)' - task: PowerShell@2 name: test @@ -106,17 +114,48 @@ stages: displayName: 'Publish Test Results' inputs: testResultsFormat: 'NUnit' - testResultsFiles: 'output/testResults/NUnit*.xml' + testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' testRunTitle: 'Unit (Windows Server 2016)' condition: succeededOrFailed() + - task: PublishPipelineArtifact@1 + displayName: 'Publish Test Artifact' + inputs: + targetPath: '$(buildFolderName)/$(testResultFolderName)/' + artifactName: $(testArtifactName) + parallel: true + + - job: Code_Coverage + displayName: 'Publish Code Coverage' + dependsOn: Test_Unit_2016 + pool: + vmImage: 'ubuntu 16.04' + timeoutInMinutes: 0 + steps: + - task: DownloadPipelineArtifact@2 + displayName: 'Download Pipeline Artifact' + inputs: + buildType: 'current' + artifactName: $(buildArtifactName) + targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)' + + - task: DownloadPipelineArtifact@2 + displayName: 'Download Test Artifact' + inputs: + buildType: 'current' + artifactName: $(testArtifactName) + targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)' + - task: PublishCodeCoverageResults@1 - displayName: 'Publish Code Coverage' - condition: succeededOrFailed() + displayName: 'Publish Code Coverage to Azure DevOps' inputs: codeCoverageTool: 'JaCoCo' - summaryFileLocation: 'output/testResults/CodeCov*.xml' - pathToSources: '$(Build.SourcesDirectory)/output/$(dscBuildVariable.RepositoryName)' + summaryFileLocation: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml' + pathToSources: '$(Build.SourcesDirectory)/$(sourceFolderName)/' + + - script: | + bash <(curl -s https://codecov.io/bash) -f "./$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml" + displayName: 'Publish Code Coverage to Codecov.io' - job: Test_Integration_2016 displayName: 'Integration (Windows Server 2016)' @@ -124,13 +163,12 @@ stages: vmImage: 'vs2017-win2016' timeoutInMinutes: 0 steps: - - task: DownloadBuildArtifacts@0 - displayName: 'Download Build Artifact' + - task: DownloadPipelineArtifact@2 + displayName: 'Download Pipeline Artifact' inputs: buildType: 'current' - downloadType: 'single' - artifactName: 'output' - downloadPath: '$(Build.SourcesDirectory)' + artifactName: $(buildArtifactName) + targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)' - task: PowerShell@2 name: configureWinRM @@ -152,7 +190,7 @@ stages: displayName: 'Publish Test Results' inputs: testResultsFormat: 'NUnit' - testResultsFiles: 'output/testResults/NUnit*.xml' + testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' testRunTitle: 'Integration (Windows Server 2016)' condition: succeededOrFailed() @@ -167,12 +205,13 @@ stages: echo "##vso[task.setvariable variable=RepositoryOwner;isOutput=true]$repositoryOwner" echo "##vso[task.setvariable variable=RepositoryName;isOutput=true]$repositoryName" name: dscBuildVariable - - task: DownloadBuildArtifacts@0 + + - task: DownloadPipelineArtifact@2 + displayName: 'Download Pipeline Artifact' inputs: buildType: 'current' - downloadType: 'single' - artifactName: 'output' - downloadPath: '$(Build.SourcesDirectory)' + artifactName: $(buildArtifactName) + targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)' - task: PowerShell@2 name: test @@ -186,31 +225,22 @@ stages: displayName: 'Publish Test Results' inputs: testResultsFormat: 'NUnit' - testResultsFiles: 'output/testResults/NUnit*.xml' + testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' testRunTitle: 'Unit (Windows Server 2019)' condition: succeededOrFailed() - - task: PublishCodeCoverageResults@1 - displayName: 'Publish Code Coverage' - condition: succeededOrFailed() - inputs: - codeCoverageTool: 'JaCoCo' - summaryFileLocation: 'output/testResults/CodeCov*.xml' - pathToSources: '$(Build.SourcesDirectory)/output/$(dscBuildVariable.RepositoryName)' - - job: Test_Integration_2019 displayName: 'Integration (Windows Server 2019)' pool: vmImage: 'windows-2019' timeoutInMinutes: 0 steps: - - task: DownloadBuildArtifacts@0 - displayName: 'Download Build Artifact' + - task: DownloadPipelineArtifact@2 + displayName: 'Download Pipeline Artifact' inputs: buildType: 'current' - downloadType: 'single' - artifactName: 'output' - downloadPath: '$(Build.SourcesDirectory)' + artifactName: $(buildArtifactName) + targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)' - task: PowerShell@2 name: configureWinRM @@ -232,7 +262,7 @@ stages: displayName: 'Publish Test Results' inputs: testResultsFormat: 'NUnit' - testResultsFiles: 'output/testResults/NUnit*.xml' + testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' testRunTitle: 'Integration (Windows Server 2019)' condition: succeededOrFailed() @@ -253,13 +283,12 @@ stages: pool: vmImage: 'ubuntu 16.04' steps: - - task: DownloadBuildArtifacts@0 - displayName: 'Download Build Artifact' + - task: DownloadPipelineArtifact@2 + displayName: 'Download Pipeline Artifact' inputs: buildType: 'current' - downloadType: 'single' - artifactName: 'output' - downloadPath: '$(Build.SourcesDirectory)' + artifactName: $(buildArtifactName) + targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)' - task: PowerShell@2 name: publishRelease diff --git a/build.yaml b/build.yaml index 5fc768a..23b354b 100644 --- a/build.yaml +++ b/build.yaml @@ -47,8 +47,8 @@ BuildWorkflow: - Pester_If_Code_Coverage_Under_Threshold publish: - - Publish_Release_to_GitHub - - Publish_Module_to_gallery + - Publish_Release_To_GitHub + - Publish_Module_To_gallery - Publish_GitHub_Wiki_Content #################################################### @@ -63,6 +63,8 @@ Pester: - tests/Unit ExcludeTag: Tag: + CodeCoverageOutputFile: JaCoCo_coverage.xml + CodeCoverageOutputFileEncoding: ascii CodeCoverageThreshold: 85 DscTest: diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..8b65b72 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,28 @@ +codecov: + require_ci_to_pass: no + # main should be the baseline for reporting + branch: main + +comment: + layout: "reach, diff, flags, files" + behavior: default + +coverage: + range: 50..80 + round: down + precision: 0 + + status: + project: + default: + # Set the overall project code coverage requirement to 70% + target: 85 + 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"