diff --git a/CHANGELOG.md b/CHANGELOG.md index d1e4cf8c..54f72e8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - WindowsEventLog - Reformatted code to better align with current DSCResources coding standards. - Renamed `master` branch to `main` - Fixes [Issue #348](https://github.com/dsccommunity/ComputerManagementDsc/issues/348). +- Added support for publishing code coverage to `CodeCov.io` and + Azure Pipelines - Fixes [Issue #367](https://github.com/dsccommunity/ComputerManagementDsc/issues/367). +- Updated build to use `Sampler.GitHubTasks` - Fixes [Issue #365](https://github.com/dsccommunity/ComputerManagementDsc/issues/365). +- Corrected case of module publish tasks - Fixes [Issue #368](https://github.com/dsccommunity/ComputerManagementDsc/issues/368). ### Fixed diff --git a/README.md b/README.md index 867953a5..03e1788d 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ [![Azure DevOps tests](https://img.shields.io/azure-devops/tests/dsccommunity/ComputerManagementDsc/18/main)](https://dsccommunity.visualstudio.com/ComputerManagementDsc/_test/analytics?definitionId=18&contextType=build) [![PowerShell Gallery (with prereleases)](https://img.shields.io/powershellgallery/vpre/ComputerManagementDsc?label=ComputerManagementDsc%20Preview)](https://www.powershellgallery.com/packages/ComputerManagementDsc/) [![PowerShell Gallery](https://img.shields.io/powershellgallery/v/ComputerManagementDsc?label=ComputerManagementDsc)](https://www.powershellgallery.com/packages/ComputerManagementDsc/) +[![codecov](https://codecov.io/gh/dsccommunity/ComputerManagementDsc/branch/main/graph/badge.svg)](https://codecov.io/gh/dsccommunity/StorageDsc) +![Azure DevOps coverage (branch)](https://img.shields.io/azure-devops/coverage/dsccommunity/ComputerManagementDsc/14/main) ## Code of Conduct diff --git a/RequiredModules.psd1 b/RequiredModules.psd1 index 2d31193f..78a848aa 100644 --- a/RequiredModules.psd1 +++ b/RequiredModules.psd1 @@ -14,6 +14,7 @@ ModuleBuilder = 'latest' ChangelogManagement = 'latest' Sampler = 'latest' + 'Sampler.GitHubTasks' = 'latest' MarkdownLinkCheck = 'latest' 'DscResource.Test' = 'latest' 'DscResource.AnalyzerRules' = 'latest' diff --git a/azure-pipelines.yml b/azure-pipelines.yml index db7779a8..073bb5c5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,6 +11,12 @@ trigger: exclude: - "*-*" +variables: + buildFolderName: output + buildArtifactName: output + testResultFolderName: testResults + testArtifactName: testResults + stages: - stage: Build jobs: @@ -72,7 +78,7 @@ stages: displayName: 'Publish Test Results' inputs: testResultsFormat: 'NUnit' - testResultsFiles: 'output/testResults/NUnit*.xml' + testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' testRunTitle: 'HQRM' condition: succeededOrFailed() @@ -109,17 +115,53 @@ 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: PublishBuildArtifacts@1 + displayName: 'Publish Test Artifact' + inputs: + pathToPublish: '$(buildFolderName)/$(testResultFolderName)/' + artifactName: $(testArtifactName) + publishLocation: 'Container' + + - job: Code_Coverage + displayName: 'Publish Code Coverage' + dependsOn: Test_Unit_2016 + 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: $(buildArtifactName) + downloadPath: '$(Build.SourcesDirectory)' + + - 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)/' + - job: Test_Integration_2016 displayName: 'Integration (Windows Server 2016)' @@ -159,7 +201,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() @@ -196,18 +238,10 @@ 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: @@ -242,7 +276,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() diff --git a/build.yaml b/build.yaml index f37758fc..400b63b0 100644 --- a/build.yaml +++ b/build.yaml @@ -48,8 +48,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 #################################################### @@ -64,7 +64,9 @@ Pester: - tests/Unit ExcludeTag: Tag: - CodeCoverageThreshold: 70 + CodeCoverageOutputFile: JaCoCo_coverage.xml + CodeCoverageOutputFileEncoding: ascii + CodeCoverageThreshold: 80 DscTest: OutputFormat: NUnitXML @@ -84,6 +86,8 @@ Resolve-Dependency: ModuleBuildTasks: Sampler: - '*.build.Sampler.ib.tasks' + Sampler.GitHubTasks: + - '*.ib.tasks' DscResource.DocGenerator: - 'Task.*' diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..0034d7da --- /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: 80 + 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"