From f42034e35edb7753c9b60ba0f6d3bffddc81c662 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sun, 2 Feb 2020 09:27:37 +0100 Subject: [PATCH 1/7] Fix Azure Pipelines code coverage (issue #236) --- CHANGELOG.md | 5 +++-- azure-pipelines.yml | 14 +++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9e95be..d3d3143 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 stats badge for Codecov.io in README.md. + - Fix Azure Pipelines code coverage ([issue #236](https://github.com/dsccommunity/xFailOverCluster/issues/236)). ### Changed @@ -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 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c7065b3..06cb325 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -105,13 +105,6 @@ stages: testResultsFormat: 'NUnit' testResultsFiles: 'output/testResults/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: @@ -168,6 +161,13 @@ stages: 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' From 3ff35165fd840e3ca6d6f11473b69002bb927843 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sun, 2 Feb 2020 09:42:36 +0100 Subject: [PATCH 2/7] Move task --- azure-pipelines.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 06cb325..0476a5f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -78,12 +78,6 @@ stages: vmImage: 'win1803' 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: @@ -154,6 +148,12 @@ 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: From 155392b8c4459380dbda954b2ee650f10fb13539 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sun, 2 Feb 2020 15:40:52 +0100 Subject: [PATCH 3/7] Add task to download output artifact --- azure-pipelines.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0476a5f..c6ba6ee 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -154,6 +154,13 @@ stages: 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 Build Artifact' inputs: From bff69563ff06a4e7c371783df1997fcaf4d8f126 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 4 Feb 2020 17:48:36 +0100 Subject: [PATCH 4/7] Fix review comment --- CHANGELOG.md | 2 +- azure-pipelines.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3d3143..5d4d95d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ For older change log history see the [historic changelog](HISTORIC_CHANGELOG.md) - Replaced module CommonResourceHelper with the PowerShell Gallery module DscResource.Common v0.2.0. - Adding back publishing code coverage to Codecov.io. - - Add stats badge for Codecov.io in README.md. + - Add status badge for Codecov.io in README.md. - Fix Azure Pipelines code coverage ([issue #236](https://github.com/dsccommunity/xFailOverCluster/issues/236)). ### Changed diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c6ba6ee..4ddafdd 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -162,7 +162,7 @@ stages: artifactName: 'output' downloadPath: '$(Build.SourcesDirectory)' - task: DownloadBuildArtifacts@0 - displayName: 'Download Build Artifact' + displayName: 'Download Test Artifact' inputs: buildType: 'current' downloadType: 'single' From 5b6791edb7d7989c46309bc5ed9965d8e8039077 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 4 Feb 2020 17:53:46 +0100 Subject: [PATCH 5/7] Add condition --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4ddafdd..968a532 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -178,6 +178,7 @@ stages: - 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 From e70b828a87ecccbb0d2049cb1d92a890159f50b2 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 6 Feb 2020 20:19:20 +0100 Subject: [PATCH 6/7] Update pipeline with variables --- azure-pipelines.yml | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 968a532..bcadccd 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,6 +10,11 @@ trigger: - "v*" exclude: - "*-*" +variables: + buildFolderName: output + buildArtifactName: output + testResultFolderName: testResults + testArtifactName: testResults stages: - stage: Build @@ -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 @@ -47,7 +52,7 @@ stages: - job: Test_HQRM displayName: 'HQRM' pool: - vmImage: 'win1803' + vmImage: 'windows-2019' timeoutInMinutes: 0 steps: - task: DownloadBuildArtifacts@0 @@ -75,7 +80,7 @@ stages: - job: Test_Unit displayName: 'Unit' pool: - vmImage: 'win1803' + vmImage: 'windows-2019' timeoutInMinutes: 0 steps: - task: DownloadBuildArtifacts@0 @@ -83,7 +88,7 @@ stages: inputs: buildType: 'current' downloadType: 'single' - artifactName: 'output' + artifactName: $(buildArtifactName) downloadPath: '$(Build.SourcesDirectory)' - task: PowerShell@2 name: test @@ -97,13 +102,13 @@ stages: condition: succeededOrFailed() inputs: testResultsFormat: 'NUnit' - testResultsFiles: 'output/testResults/NUnit*.xml' + testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' testRunTitle: 'Unit (Windows Server Core)' - task: PublishBuildArtifacts@1 displayName: 'Publish Test Artifact' inputs: - pathToPublish: 'output/testResults/' - artifactName: 'testResults' + pathToPublish: '$(buildFolderName)/$(testResultFolderName)/' + artifactName: $(testArtifactName) publishLocation: 'Container' - job: Test_Integration @@ -117,7 +122,7 @@ stages: inputs: buildType: 'current' downloadType: 'single' - artifactName: 'output' + artifactName: $(buildArtifactName) downloadPath: '$(Build.SourcesDirectory)' - task: PowerShell@2 name: configureWinRM @@ -138,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 @@ -159,24 +164,24 @@ stages: inputs: buildType: 'current' downloadType: 'single' - artifactName: 'output' + artifactName: $(buildArtifactName) downloadPath: '$(Build.SourcesDirectory)' - task: DownloadBuildArtifacts@0 displayName: 'Download Test Artifact' inputs: buildType: 'current' downloadType: 'single' - artifactName: 'testResults' - downloadPath: '$(Build.SourcesDirectory)/output' + artifactName: $(testArtifactName) + downloadPath: '$(Build.SourcesDirectory)/$(buildFolderName)' - task: PublishCodeCoverageResults@1 - displayName: 'Publish Code Coverage' + displayName: 'Publish Azure Code Coverage' condition: succeededOrFailed() inputs: codeCoverageTool: 'JaCoCo' - summaryFileLocation: 'output/testResults/JaCoCo_coverage.xml' - pathToSources: '$(Build.SourcesDirectory)/output/$(dscBuildVariable.RepositoryName)' + 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() From b3681aa662abc6e8eeb0902cbbbb2b075e2fb7fa Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 6 Feb 2020 20:24:15 +0100 Subject: [PATCH 7/7] Fix missing quote --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index bcadccd..f85e608 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -42,7 +42,7 @@ stages: - task: PublishBuildArtifacts@1 displayName: 'Publish Build Artifact' inputs: - pathToPublish: $(buildFolderName)/' + pathToPublish: '$(buildFolderName)/' artifactName: $(buildArtifactName) publishLocation: 'Container'