From e5ca3138abde1c1ce0a5c0c953bb2b5365672552 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Mon, 16 Mar 2020 20:02:58 +1300 Subject: [PATCH] Remove AppVeyor CI Build - Fixes #329 (#331) --- .codecovio/CodeCovIo.psm1 | 17 +- .github/CONTRIBUTING.md | 28 -- CHANGELOG.md | 7 + README.md | 15 +- appveyor.yml | 13 - azure-pipelines.daily.yml | 447 +++++++++++++++++------------ azure-pipelines.yml | 478 ++++++++++++++++++-------------- psakefile.ps1 | 90 ++---- test/TestHelper/TestHelper.psm1 | 2 +- 9 files changed, 588 insertions(+), 509 deletions(-) delete mode 100644 appveyor.yml diff --git a/.codecovio/CodeCovIo.psm1 b/.codecovio/CodeCovIo.psm1 index 36c52c63..369b9ce6 100644 --- a/.codecovio/CodeCovIo.psm1 +++ b/.codecovio/CodeCovIo.psm1 @@ -150,7 +150,7 @@ function Export-CodeCovIoJson [Parameter()] [ValidateNotNullOrEmpty()] [String] - $Path = (Join-Path -Path $env:TEMP -ChildPath 'codeCov.json') + $Path = (Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath 'codeCov.json') ) Write-Verbose -Message "RepoRoot: $RepoRoot" @@ -312,7 +312,7 @@ function Export-CodeCovIoJson .PARAMETER Path The path to the code coverage report (gcov not supported) #> -function Invoke-UploadCoveCoveIoReport +function Invoke-UploadCodeCovIoReport { [CmdletBinding()] param @@ -324,11 +324,6 @@ function Invoke-UploadCoveCoveIoReport $resolvedResultFile = (Resolve-Path -Path $Path).ProviderPath - if ($env:APPVEYOR_REPO_BRANCH) - { - Push-AppveyorArtifact -Path $resolvedResultFile - } - <# See this link for information around codecov.exe https://github.com/codecov/codecov-exe @@ -336,12 +331,4 @@ function Invoke-UploadCoveCoveIoReport $uploadResults = & choco install codecov --yes $uploadResults += codecov -f $resolvedResultFile --required - - if ($env:APPVEYOR_REPO_BRANCH) - { - $logPath = (Join-Path -Path $env:TEMP -ChildPath 'codeCovUpload.log') - $uploadResults | Out-File -Encoding ascii -LiteralPath $logPath -Force - $resolvedLogPath = (Resolve-Path -Path $logPath).ProviderPath - Push-AppveyorArtifact -Path $resolvedLogPath - } } diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 08ac797f..1d302e26 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -103,34 +103,6 @@ about it. This is used to test the module on PowerShell on Windows and PowerShell Core on Linux. -### AppVeyor - -We use [AppVeyor](http://www.appveyor.com/) as a continuous integration (CI) system. - -![AppVeyor-Badge-Green.png](Images/AppVeyor-Badge-Green.png) - -This badge is **clickable**, you can open corresponding build page with logs, artifacts -and tests results. -From there you can easily navigate to the whole build history. - -AppVeyor builds and runs tests on every pull request and provides quick feedback -about it. - -This is used to test the module on PowerShell on Windows. - -### TravisCI - -We use [TravisCI](http://travis-ci.org/) as a continuous integration (CI) system. - -![TravisCI-Badge-Green.png](Images/TravisCI-Badge-Green.png) - -This badge is **clickable**, you can open corresponding build page with logs, artifacts -and tests results. -From there you can easily navigate to the whole build history. - -TravisCI builds and runs tests on every pull request and provides quick feedback -about it. - ## Testing - Any changed code should not cause Unit Tests to fail. diff --git a/CHANGELOG.md b/CHANGELOG.md index a1b98106..0c804e5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## Unreleased + +- Remove AppVeyor CI pipeline - fixes [Issue #329](https://github.com/PlagueHO/CosmosDB/issues/329). +- Restructure Azure Pipeline: + - Add testing on Windows Server 2019 and separate module build process. + - Convert to multi stage pipeline. + ## 3.5.2.487 - Update `BuildHelpers` to version 2.0.11. diff --git a/README.md b/README.md index 3f875fc8..51310aec 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,10 @@ ## Module Build Status -| Branch | AzurePipelines CI | AppVeyor CI | Code Coverage | -| ------ | -------------------------------------- | -------------------------------------- | -------------------------------------- | -| dev | [![ap-image-dev][]][ap-site-dev] | [![av-image-dev][]][av-site-dev] | [![cc-image-dev][]][cc-site-dev] | -| master | [![ap-image-master][]][ap-site-master] | [![av-image-master][]][av-site-master] | [![cc-image-master][]][cc-site-master] | +| Branch | Azure Pipelines CI | Code Coverage | +| ------ | --------------------------------------- | -------------------------------------- | +| dev | [![ap-image-dev][]][ap-site-dev] | [![cc-image-dev][]][cc-site-dev] | +| master | [![ap-image-master][]][ap-site-master] | [![cc-image-master][]][cc-site-master] | ## Table of Contents @@ -102,9 +102,8 @@ This PowerShell module is automatically tested and validated to run on the following systems: - Windows Server (using Windows PowerShell 5.1): - - Windows Server 2012 R2: Using [AppVeyor CI](https://ci.appveyor.com/project/PlagueHO/cosmosdb). - - Windows Server 2016: Using [AppVeyor CI](https://ci.appveyor.com/project/PlagueHO/cosmosdb). - Windows Server 2016: Using [Azure Pipelines](https://dev.azure.com/dscottraynsford/GitHub/_build?definitionId=4). + - Windows Server 2019: Using [Azure Pipelines](https://dev.azure.com/dscottraynsford/GitHub/_build?definitionId=4). - Linux (using PowerShell Core 6.x): - Ubuntu Trusty 16.04: Using [Azure Pipelines](https://dev.azure.com/dscottraynsford/GitHub/_build?definitionId=4). - Linux (using PowerShell 7.x): @@ -1004,14 +1003,10 @@ For a list of changes to versions, see the [CHANGELOG.md](CHANGELOG.md) file. [ap-image-dev]: https://dev.azure.com/dscottraynsford/GitHub/_apis/build/status/PlagueHO.CosmosDB?branchName=dev [ap-site-dev]: https://dev.azure.com/dscottraynsford/GitHub/_build/latest?definitionId=4 -[av-image-dev]: https://ci.appveyor.com/api/projects/status/v5wqtt63nnmkm94j/branch/dev?svg=true -[av-site-dev]: https://ci.appveyor.com/project/PlagueHO/cosmosdb/branch/dev [cc-image-dev]: https://codecov.io/gh/PlagueHO/CosmosDB/branch/dev/graph/badge.svg [cc-site-dev]: https://codecov.io/gh/PlagueHO/CosmosDB/branch/dev [ap-image-master]: https://dev.azure.com/dscottraynsford/GitHub/_apis/build/status/PlagueHO.CosmosDB?branchName=master [ap-site-master]: https://dev.azure.com/dscottraynsford/GitHub/_build/latest?definitionId=4 -[av-image-master]: https://ci.appveyor.com/api/projects/status/v5wqtt63nnmkm94j/branch/master?svg=true -[av-site-master]: https://ci.appveyor.com/project/PlagueHO/cosmosdb/branch/master [cc-image-master]: https://codecov.io/gh/PlagueHO/CosmosDB/branch/master/graph/badge.svg [cc-site-master]: https://codecov.io/gh/PlagueHO/CosmosDB/branch/master diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 3d1d7cee..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,13 +0,0 @@ -#---------------------------------# -# environment configuration # -#---------------------------------# -version: 1.0.0.{build} - -image: -- Visual Studio 2017 -- Visual Studio 2015 - -build: false - -test_script: - - ps: . .\psake.ps1 -TaskList Test diff --git a/azure-pipelines.daily.yml b/azure-pipelines.daily.yml index f560820d..85510e7a 100644 --- a/azure-pipelines.daily.yml +++ b/azure-pipelines.daily.yml @@ -1,174 +1,279 @@ name: $(rev:r) trigger: none pr: none -jobs: - - job: Build_PS_Win2016 - pool: - vmImage: vs2017-win2016 - - steps: - - checkout: self - persistCredentials: true - - - powershell: | - .\psake.ps1 -TaskList Build -Verbose - displayName: 'Build and Stage Module' - env: - githubRepoToken: $(githubRepoToken) - - - powershell: | - .\psake.ps1 -TaskList UnitTest -Verbose - displayName: 'Execute Unit Tests' - - - task: PublishTestResults@2 - displayName: 'Publish Unit Test Results' - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/Unit/TestResults.unit.xml' - testRunTitle: 'PS_Win2016_Unit' - condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') - - - task: PublishCodeCoverageResults@1 - displayName: 'Publish Unit Test Code Coverage' - inputs: - summaryFileLocation: '**/Unit/CodeCoverage.xml' - failIfCoverageEmpty: true - condition: and(in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed'), eq(variables['System.PullRequest.IsFork'], false)) - - - powershell: | - .\psake.ps1 -TaskList IntegrationTest -Parameters @{ TestStagedModule = $true } -Verbose - displayName: 'Execute Integration Tests' - env: - azureApplicationId: $(azureApplicationId) - azureApplicationPassword: $(azureApplicationPassword) - azureSubscriptionId: $(azureSubscriptionId) - azureTenantId: $(azureTenantId) - - - task: PublishTestResults@2 - displayName: 'Publish Integration Test Results' - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/Integration/TestResults.integration.xml' - testRunTitle: 'PS_Win2016_Integration' - condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') - - - job: Build_PSCore6_Ubuntu1604 - displayName: 'Test Powershell Core 6 on Ubuntu 16.04' - pool: - vmImage: ubuntu-16.04 - - steps: - - script: | - curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list - sudo apt-get update - sudo apt-get install -y --allow-downgrades powershell=6.2.3-1.ubuntu.16.04 - displayName: 'Install PowerShell Core 6' - - - script: | - pwsh -c '.\psake.ps1 -TaskList UnitTest -Verbose' - displayName: 'Execute Unit Tests' - - - task: PublishTestResults@2 - displayName: 'Publish Unit Test Results' - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/Unit/TestResults.unit.xml' - testRunTitle: 'PSCore6_Ubuntu1604_Unit' - condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') - - - script: | - pwsh -c '.\psake.ps1 -TaskList IntegrationTest -Verbose' - displayName: 'Execute Integration Tests' - env: - azureApplicationId: $(azureApplicationId) - azureApplicationPassword: $(azureApplicationPassword) - azureSubscriptionId: $(azureSubscriptionId) - azureTenantId: $(azureTenantId) - - - task: PublishTestResults@2 - displayName: 'Publish Integration Test Results' - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/Integration/TestResults.integration.xml' - testRunTitle: 'PSCore6_Ubuntu1604_Integration' - condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') - - - job: Build_PS7_Ubuntu1604 - displayName: 'Test Powershell 7 on Ubuntu 16.04' - pool: - vmImage: ubuntu-16.04 - - steps: - - script: | - curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list - sudo apt-get update - sudo apt-get install -y powershell - displayName: 'Install PowerShell 7' - - - script: | - pwsh -c '.\psake.ps1 -TaskList UnitTest -Verbose' - displayName: 'Execute Unit Tests' - - - task: PublishTestResults@2 - displayName: 'Publish Unit Test Results' - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/Unit/TestResults.unit.xml' - testRunTitle: 'PSCore7_Ubuntu1604_Unit' - condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') - - - script: | - pwsh -c '.\psake.ps1 -TaskList IntegrationTest -Verbose' - displayName: 'Execute Integration Tests' - env: - azureApplicationId: $(azureApplicationId) - azureApplicationPassword: $(azureApplicationPassword) - azureSubscriptionId: $(azureSubscriptionId) - azureTenantId: $(azureTenantId) - - - task: PublishTestResults@2 - displayName: 'Publish Integration Test Results' - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/Integration/TestResults.integration.xml' - testRunTitle: 'PSCore7_Ubuntu1604_Integration' - condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') - - - job: Build_PSCore6_MacOS1014 - displayName: 'Test Powershell Core 6 on MacOS 10.14' - pool: - vmImage: macos-10.14 - - steps: - - powershell: | - Uninstall-Module -Name Az -Force - .\psake.ps1 -TaskList UnitTest -Verbose - displayName: 'Execute Unit Tests' - - - task: PublishTestResults@2 - displayName: 'Publish Unit Test Results' - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/TestResults.unit.xml' - testRunTitle: 'PSCore_MacOS1013_Unit' - condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') - - - powershell: | - $null = Remove-Item -Path '~/.Azure' -Recurse -Force - .\psake.ps1 -TaskList IntegrationTest -Verbose - displayName: 'Execute Integration Tests' - env: - azureApplicationId: $(azureApplicationId) - azureApplicationPassword: $(azureApplicationPassword) - azureSubscriptionId: $(azureSubscriptionId) - azureTenantId: $(azureTenantId) - - - task: PublishTestResults@2 - displayName: 'Publish Integration Test Results' - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/TestResults.integration.xml' - testRunTitle: 'PSCore_MacOS1013_Integration' - condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + +stages: + - stage: Build + jobs: + - job: Package_Module + displayName: 'Package Module' + pool: + vmImage: vs2017-win2016 + + steps: + - checkout: self + persistCredentials: true + + - powershell: | + .\psake.ps1 -TaskList Build -Verbose + displayName: 'Build and Stage Module' + env: + githubRepoToken: $(githubRepoToken) + + - task: PublishBuildArtifacts@1 + displayName: 'Publish Module' + inputs: + pathtoPublish: 'staging/CosmosDB' + artifactName: 'CosmosDB' + + - task: PublishBuildArtifacts@1 + displayName: 'Publish Module Zip' + inputs: + pathtoPublish: 'staging/zip' + artifactName: 'zip' + + - task: PublishBuildArtifacts@1 + displayName: 'Publish PSake File' + inputs: + pathtoPublish: 'psakefile.ps1' + artifactName: 'scripts' + + - task: PublishBuildArtifacts@1 + displayName: 'Publish PSDepend File' + inputs: + pathtoPublish: 'requirements.psd1' + artifactName: 'scripts' + + - task: PublishBuildArtifacts@1 + displayName: 'Publish Build File' + inputs: + pathtoPublish: 'psake.ps1' + artifactName: 'scripts' + + - stage: Test + dependsOn: Build + jobs: + - job: Test_PS_Win2016 + displayName: 'Test Powershell 5.1 on Windows Server 2016' + pool: + vmImage: vs2017-win2016 + + steps: + - checkout: self + persistCredentials: true + + - powershell: | + .\psake.ps1 -TaskList Build -Verbose + displayName: 'Build and Stage Module' + env: + githubRepoToken: $(githubRepoToken) + + - powershell: | + .\psake.ps1 -TaskList UnitTest -Verbose + displayName: 'Execute Unit Tests' + + - task: PublishTestResults@2 + displayName: 'Publish Unit Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/Unit/TestResults.unit.xml' + testRunTitle: 'PS_Win2016_Unit' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + + - task: PublishCodeCoverageResults@1 + displayName: 'Publish Unit Test Code Coverage' + inputs: + codeCoverageTool: 'JaCoCo' + summaryFileLocation: '**/Unit/CodeCoverage.xml' + failIfCoverageEmpty: true + condition: and(in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed'), eq(variables['System.PullRequest.IsFork'], false)) + + - powershell: | + .\psake.ps1 -TaskList IntegrationTest -Parameters @{ TestStagedModule = $true } -Verbose + displayName: 'Execute Integration Tests on Staged Module' + env: + azureApplicationId: $(azureApplicationId) + azureApplicationPassword: $(azureApplicationPassword) + azureSubscriptionId: $(azureSubscriptionId) + azureTenantId: $(azureTenantId) + + - task: PublishTestResults@2 + displayName: 'Publish Integration Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/Integration/TestResults.integration.xml' + testRunTitle: 'PS_Win2016_Integration' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + + - job: Test_PS_Win2019 + displayName: 'Test Powershell 5.1 on Windows Server 2019' + pool: + vmImage: windows-2019 + + steps: + - checkout: self + persistCredentials: true + + - powershell: | + .\psake.ps1 -TaskList Build -Verbose + displayName: 'Build and Stage Module' + env: + githubRepoToken: $(githubRepoToken) + + - powershell: | + .\psake.ps1 -TaskList UnitTest -Verbose + displayName: 'Execute Unit Tests' + + - task: PublishTestResults@2 + displayName: 'Publish Unit Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/Unit/TestResults.unit.xml' + testRunTitle: 'PS_Win2016_Unit' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + + - task: PublishCodeCoverageResults@1 + displayName: 'Publish Unit Test Code Coverage' + inputs: + codeCoverageTool: 'JaCoCo' + summaryFileLocation: '**/Unit/CodeCoverage.xml' + failIfCoverageEmpty: true + condition: and(in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed'), eq(variables['System.PullRequest.IsFork'], false)) + + - powershell: | + .\psake.ps1 -TaskList IntegrationTest -Parameters @{ TestStagedModule = $true } -Verbose + displayName: 'Execute Integration Tests on Staged Module' + env: + azureApplicationId: $(azureApplicationId) + azureApplicationPassword: $(azureApplicationPassword) + azureSubscriptionId: $(azureSubscriptionId) + azureTenantId: $(azureTenantId) + + - task: PublishTestResults@2 + displayName: 'Publish Integration Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/Integration/TestResults.integration.xml' + testRunTitle: 'PS_Win2016_Integration' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + + - job: Test_PSCore6_Ubuntu1604 + displayName: 'Test Powershell Core 6 on Ubuntu 16.04' + pool: + vmImage: ubuntu-16.04 + + steps: + - script: | + curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - + curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list + sudo apt-get update + sudo apt-get install -y --allow-downgrades powershell=6.2.3-1.ubuntu.16.04 + displayName: 'Install PowerShell Core 6' + + - script: | + pwsh -c '.\psake.ps1 -TaskList UnitTest -Verbose' + displayName: 'Execute Unit Tests' + + - task: PublishTestResults@2 + displayName: 'Publish Unit Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/Unit/TestResults.unit.xml' + testRunTitle: 'PSCore6_Ubuntu1604_Unit' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + + - script: | + pwsh -c '.\psake.ps1 -TaskList IntegrationTest -Verbose' + displayName: 'Execute Integration Tests' + env: + azureApplicationId: $(azureApplicationId) + azureApplicationPassword: $(azureApplicationPassword) + azureSubscriptionId: $(azureSubscriptionId) + azureTenantId: $(azureTenantId) + + - task: PublishTestResults@2 + displayName: 'Publish Integration Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/Integration/TestResults.integration.xml' + testRunTitle: 'PSCore6_Ubuntu1604_Integration' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + + - job: Test_PS7_Ubuntu1604 + displayName: 'Test Powershell 7 on Ubuntu 16.04' + pool: + vmImage: ubuntu-16.04 + + steps: + - script: | + curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - + curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list + sudo apt-get update + sudo apt-get install -y powershell + displayName: 'Install PowerShell 7' + + - script: | + pwsh -c '.\psake.ps1 -TaskList UnitTest -Verbose' + displayName: 'Execute Unit Tests' + + - task: PublishTestResults@2 + displayName: 'Publish Unit Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/Unit/TestResults.unit.xml' + testRunTitle: 'PSCore7_Ubuntu1604_Unit' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + + - script: | + pwsh -c '.\psake.ps1 -TaskList IntegrationTest -Verbose' + displayName: 'Execute Integration Tests' + env: + azureApplicationId: $(azureApplicationId) + azureApplicationPassword: $(azureApplicationPassword) + azureSubscriptionId: $(azureSubscriptionId) + azureTenantId: $(azureTenantId) + + - task: PublishTestResults@2 + displayName: 'Publish Integration Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/Integration/TestResults.integration.xml' + testRunTitle: 'PSCore7_Ubuntu1604_Integration' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + + - job: Test_PSCore6_MacOS1014 + displayName: 'Test Powershell Core 6 on MacOS 10.14' + pool: + vmImage: macos-10.14 + + steps: + - powershell: | + Uninstall-Module -Name Az -Force + .\psake.ps1 -TaskList UnitTest -Verbose + displayName: 'Execute Unit Tests' + + - task: PublishTestResults@2 + displayName: 'Publish Unit Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/TestResults.unit.xml' + testRunTitle: 'PSCore_MacOS1013_Unit' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + + - powershell: | + $null = Remove-Item -Path '~/.Azure' -Recurse -Force + .\psake.ps1 -TaskList IntegrationTest -Verbose + displayName: 'Execute Integration Tests' + env: + azureApplicationId: $(azureApplicationId) + azureApplicationPassword: $(azureApplicationPassword) + azureSubscriptionId: $(azureSubscriptionId) + azureTenantId: $(azureTenantId) + + - task: PublishTestResults@2 + displayName: 'Publish Integration Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/TestResults.integration.xml' + testRunTitle: 'PSCore_MacOS1013_Integration' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5ea0892e..98a22e64 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,205 +7,279 @@ pr: branches: include: - dev -jobs: - - job: Build_PS_Win2016 - displayName: 'Test Powershell 5.1 on Windows Server 2016' - pool: - vmImage: vs2017-win2016 - - steps: - - checkout: self - persistCredentials: true - - - powershell: | - .\psake.ps1 -TaskList Build -Verbose - displayName: 'Build and Stage Module' - env: - githubRepoToken: $(githubRepoToken) - - - powershell: | - .\psake.ps1 -TaskList UnitTest -Verbose - displayName: 'Execute Unit Tests' - - - task: PublishTestResults@2 - displayName: 'Publish Unit Test Results' - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/Unit/TestResults.unit.xml' - testRunTitle: 'PS_Win2016_Unit' - condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') - - - task: PublishCodeCoverageResults@1 - displayName: 'Publish Unit Test Code Coverage' - inputs: - summaryFileLocation: '**/Unit/CodeCoverage.xml' - failIfCoverageEmpty: true - condition: and(in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed'), eq(variables['System.PullRequest.IsFork'], false)) - - - powershell: | - .\psake.ps1 -TaskList IntegrationTest -Parameters @{ TestStagedModule = $true } -Verbose - displayName: 'Execute Integration Tests on Staged Module' - env: - azureApplicationId: $(azureApplicationId) - azureApplicationPassword: $(azureApplicationPassword) - azureSubscriptionId: $(azureSubscriptionId) - azureTenantId: $(azureTenantId) - - - task: PublishTestResults@2 - displayName: 'Publish Integration Test Results' - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/Integration/TestResults.integration.xml' - testRunTitle: 'PS_Win2016_Integration' - condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') - - - task: PublishBuildArtifacts@1 - displayName: 'Publish Module' - inputs: - pathtoPublish: 'staging/CosmosDB' - artifactName: 'CosmosDB' - - - task: PublishBuildArtifacts@1 - displayName: 'Publish Module Zip' - inputs: - pathtoPublish: 'staging/zip' - artifactName: 'zip' - - - task: PublishBuildArtifacts@1 - displayName: 'Publish PSake File' - inputs: - pathtoPublish: 'psakefile.ps1' - artifactName: 'scripts' - - - task: PublishBuildArtifacts@1 - displayName: 'Publish PSDepend File' - inputs: - pathtoPublish: 'requirements.psd1' - artifactName: 'scripts' - - - task: PublishBuildArtifacts@1 - displayName: 'Publish Build File' - inputs: - pathtoPublish: 'psake.ps1' - artifactName: 'scripts' - - - job: Build_PSCore6_Ubuntu1604 - displayName: 'Test Powershell Core 6 on Ubuntu 16.04' - pool: - vmImage: ubuntu-16.04 - - steps: - - script: | - curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list - sudo apt-get update - sudo apt-get install -y --allow-downgrades powershell=6.2.3-1.ubuntu.16.04 - displayName: 'Install PowerShell Core 6' - - - script: | - pwsh -c '.\psake.ps1 -TaskList UnitTest -Verbose' - displayName: 'Execute Unit Tests' - - - task: PublishTestResults@2 - displayName: 'Publish Unit Test Results' - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/Unit/TestResults.unit.xml' - testRunTitle: 'PSCore6_Ubuntu1604_Unit' - condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') - - - script: | - pwsh -c '.\psake.ps1 -TaskList IntegrationTest -Verbose' - displayName: 'Execute Integration Tests' - env: - azureApplicationId: $(azureApplicationId) - azureApplicationPassword: $(azureApplicationPassword) - azureSubscriptionId: $(azureSubscriptionId) - azureTenantId: $(azureTenantId) - - - task: PublishTestResults@2 - displayName: 'Publish Integration Test Results' - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/Integration/TestResults.integration.xml' - testRunTitle: 'PSCore6_Ubuntu1604_Integration' - condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') - - - job: Build_PS7_Ubuntu1604 - displayName: 'Test Powershell 7 on Ubuntu 16.04' - pool: - vmImage: ubuntu-16.04 - - steps: - - script: | - curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list - sudo apt-get update - sudo apt-get install -y powershell - displayName: 'Install PowerShell 7' - - - script: | - pwsh -c '.\psake.ps1 -TaskList UnitTest -Verbose' - displayName: 'Execute Unit Tests' - - - task: PublishTestResults@2 - displayName: 'Publish Unit Test Results' - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/Unit/TestResults.unit.xml' - testRunTitle: 'PSCore7_Ubuntu1604_Unit' - condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') - - - script: | - pwsh -c '.\psake.ps1 -TaskList IntegrationTest -Verbose' - displayName: 'Execute Integration Tests' - env: - azureApplicationId: $(azureApplicationId) - azureApplicationPassword: $(azureApplicationPassword) - azureSubscriptionId: $(azureSubscriptionId) - azureTenantId: $(azureTenantId) - - - task: PublishTestResults@2 - displayName: 'Publish Integration Test Results' - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/Integration/TestResults.integration.xml' - testRunTitle: 'PSCore7_Ubuntu1604_Integration' - condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') - - - job: Build_PSCore6_MacOS1014 - displayName: 'Test Powershell Core 6 on MacOS 10.14' - pool: - vmImage: macos-10.14 - - steps: - - powershell: | - Uninstall-Module -Name Az -Force - .\psake.ps1 -TaskList UnitTest -Verbose - displayName: 'Execute Unit Tests' - - - task: PublishTestResults@2 - displayName: 'Publish Unit Test Results' - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/TestResults.unit.xml' - testRunTitle: 'PSCore_MacOS1013_Unit' - condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') - - - powershell: | - $null = Remove-Item -Path '~/.Azure' -Recurse -Force - .\psake.ps1 -TaskList IntegrationTest -Verbose - displayName: 'Execute Integration Tests' - env: - azureApplicationId: $(azureApplicationId) - azureApplicationPassword: $(azureApplicationPassword) - azureSubscriptionId: $(azureSubscriptionId) - azureTenantId: $(azureTenantId) - - - task: PublishTestResults@2 - displayName: 'Publish Integration Test Results' - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/TestResults.integration.xml' - testRunTitle: 'PSCore_MacOS1013_Integration' - condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + +stages: + - stage: Build + jobs: + - job: Package_Module + displayName: 'Package Module' + pool: + vmImage: vs2017-win2016 + + steps: + - checkout: self + persistCredentials: true + + - powershell: | + .\psake.ps1 -TaskList Build -Verbose + displayName: 'Build and Stage Module' + env: + githubRepoToken: $(githubRepoToken) + + - task: PublishBuildArtifacts@1 + displayName: 'Publish Module' + inputs: + pathtoPublish: 'staging/CosmosDB' + artifactName: 'CosmosDB' + + - task: PublishBuildArtifacts@1 + displayName: 'Publish Module Zip' + inputs: + pathtoPublish: 'staging/zip' + artifactName: 'zip' + + - task: PublishBuildArtifacts@1 + displayName: 'Publish PSake File' + inputs: + pathtoPublish: 'psakefile.ps1' + artifactName: 'scripts' + + - task: PublishBuildArtifacts@1 + displayName: 'Publish PSDepend File' + inputs: + pathtoPublish: 'requirements.psd1' + artifactName: 'scripts' + + - task: PublishBuildArtifacts@1 + displayName: 'Publish Build File' + inputs: + pathtoPublish: 'psake.ps1' + artifactName: 'scripts' + + - stage: Test + dependsOn: Build + jobs: + - job: Test_PS_Win2016 + displayName: 'Test Powershell 5.1 on Windows Server 2016' + pool: + vmImage: vs2017-win2016 + + steps: + - checkout: self + persistCredentials: true + + - powershell: | + .\psake.ps1 -TaskList Build -Verbose + displayName: 'Build and Stage Module' + env: + githubRepoToken: $(githubRepoToken) + + - powershell: | + .\psake.ps1 -TaskList UnitTest -Verbose + displayName: 'Execute Unit Tests' + + - task: PublishTestResults@2 + displayName: 'Publish Unit Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/Unit/TestResults.unit.xml' + testRunTitle: 'PS_Win2016_Unit' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + + - task: PublishCodeCoverageResults@1 + displayName: 'Publish Unit Test Code Coverage' + inputs: + codeCoverageTool: 'JaCoCo' + summaryFileLocation: '**/Unit/CodeCoverage.xml' + failIfCoverageEmpty: true + condition: and(in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed'), eq(variables['System.PullRequest.IsFork'], false)) + + - powershell: | + .\psake.ps1 -TaskList IntegrationTest -Parameters @{ TestStagedModule = $true } -Verbose + displayName: 'Execute Integration Tests on Staged Module' + env: + azureApplicationId: $(azureApplicationId) + azureApplicationPassword: $(azureApplicationPassword) + azureSubscriptionId: $(azureSubscriptionId) + azureTenantId: $(azureTenantId) + + - task: PublishTestResults@2 + displayName: 'Publish Integration Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/Integration/TestResults.integration.xml' + testRunTitle: 'PS_Win2016_Integration' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + + - job: Test_PS_Win2019 + displayName: 'Test Powershell 5.1 on Windows Server 2019' + pool: + vmImage: windows-2019 + + steps: + - checkout: self + persistCredentials: true + + - powershell: | + .\psake.ps1 -TaskList Build -Verbose + displayName: 'Build and Stage Module' + env: + githubRepoToken: $(githubRepoToken) + + - powershell: | + .\psake.ps1 -TaskList UnitTest -Verbose + displayName: 'Execute Unit Tests' + + - task: PublishTestResults@2 + displayName: 'Publish Unit Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/Unit/TestResults.unit.xml' + testRunTitle: 'PS_Win2016_Unit' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + + - task: PublishCodeCoverageResults@1 + displayName: 'Publish Unit Test Code Coverage' + inputs: + codeCoverageTool: 'JaCoCo' + summaryFileLocation: '**/Unit/CodeCoverage.xml' + failIfCoverageEmpty: true + condition: and(in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed'), eq(variables['System.PullRequest.IsFork'], false)) + + - powershell: | + .\psake.ps1 -TaskList IntegrationTest -Parameters @{ TestStagedModule = $true } -Verbose + displayName: 'Execute Integration Tests on Staged Module' + env: + azureApplicationId: $(azureApplicationId) + azureApplicationPassword: $(azureApplicationPassword) + azureSubscriptionId: $(azureSubscriptionId) + azureTenantId: $(azureTenantId) + + - task: PublishTestResults@2 + displayName: 'Publish Integration Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/Integration/TestResults.integration.xml' + testRunTitle: 'PS_Win2016_Integration' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + + - job: Test_PSCore6_Ubuntu1604 + displayName: 'Test Powershell Core 6 on Ubuntu 16.04' + pool: + vmImage: ubuntu-16.04 + + steps: + - script: | + curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - + curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list + sudo apt-get update + sudo apt-get install -y --allow-downgrades powershell=6.2.3-1.ubuntu.16.04 + displayName: 'Install PowerShell Core 6' + + - script: | + pwsh -c '.\psake.ps1 -TaskList UnitTest -Verbose' + displayName: 'Execute Unit Tests' + + - task: PublishTestResults@2 + displayName: 'Publish Unit Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/Unit/TestResults.unit.xml' + testRunTitle: 'PSCore6_Ubuntu1604_Unit' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + + - script: | + pwsh -c '.\psake.ps1 -TaskList IntegrationTest -Verbose' + displayName: 'Execute Integration Tests' + env: + azureApplicationId: $(azureApplicationId) + azureApplicationPassword: $(azureApplicationPassword) + azureSubscriptionId: $(azureSubscriptionId) + azureTenantId: $(azureTenantId) + + - task: PublishTestResults@2 + displayName: 'Publish Integration Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/Integration/TestResults.integration.xml' + testRunTitle: 'PSCore6_Ubuntu1604_Integration' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + + - job: Test_PS7_Ubuntu1604 + displayName: 'Test Powershell 7 on Ubuntu 16.04' + pool: + vmImage: ubuntu-16.04 + + steps: + - script: | + curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - + curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list + sudo apt-get update + sudo apt-get install -y powershell + displayName: 'Install PowerShell 7' + + - script: | + pwsh -c '.\psake.ps1 -TaskList UnitTest -Verbose' + displayName: 'Execute Unit Tests' + + - task: PublishTestResults@2 + displayName: 'Publish Unit Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/Unit/TestResults.unit.xml' + testRunTitle: 'PSCore7_Ubuntu1604_Unit' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + + - script: | + pwsh -c '.\psake.ps1 -TaskList IntegrationTest -Verbose' + displayName: 'Execute Integration Tests' + env: + azureApplicationId: $(azureApplicationId) + azureApplicationPassword: $(azureApplicationPassword) + azureSubscriptionId: $(azureSubscriptionId) + azureTenantId: $(azureTenantId) + + - task: PublishTestResults@2 + displayName: 'Publish Integration Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/Integration/TestResults.integration.xml' + testRunTitle: 'PSCore7_Ubuntu1604_Integration' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + + - job: Test_PSCore6_MacOS1014 + displayName: 'Test Powershell Core 6 on MacOS 10.14' + pool: + vmImage: macos-10.14 + + steps: + - powershell: | + Uninstall-Module -Name Az -Force + .\psake.ps1 -TaskList UnitTest -Verbose + displayName: 'Execute Unit Tests' + + - task: PublishTestResults@2 + displayName: 'Publish Unit Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/TestResults.unit.xml' + testRunTitle: 'PSCore_MacOS1013_Unit' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') + + - powershell: | + $null = Remove-Item -Path '~/.Azure' -Recurse -Force + .\psake.ps1 -TaskList IntegrationTest -Verbose + displayName: 'Execute Integration Tests' + env: + azureApplicationId: $(azureApplicationId) + azureApplicationPassword: $(azureApplicationPassword) + azureSubscriptionId: $(azureSubscriptionId) + azureTenantId: $(azureTenantId) + + - task: PublishTestResults@2 + displayName: 'Publish Integration Test Results' + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/TestResults.integration.xml' + testRunTitle: 'PSCore_MacOS1013_Integration' + condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed') diff --git a/psakefile.ps1 b/psakefile.ps1 index 1f511eb0..74d26759 100644 --- a/psakefile.ps1 +++ b/psakefile.ps1 @@ -79,28 +79,24 @@ Task UnitTest -Depends Init, PrepareTest { # Prepare and uploade code coverage if ($testResults.CodeCoverage) { - # Only bother generating code coverage in AppVeyor - if ($ENV:BHBuildSystem -eq 'AppVeyor') - { - 'Preparing CodeCoverage' - Import-Module ` - -Name (Join-Path -Path $ProjectRoot -ChildPath '.codecovio\CodeCovio.psm1') + 'Preparing CodeCoverage' + Import-Module ` + -Name (Join-Path -Path $ProjectRoot -ChildPath '.codecovio\CodeCovIo.psm1') - $jsonPath = Export-CodeCovIoJson ` - -CodeCoverage $testResults.CodeCoverage ` - -RepoRoot $ProjectRoot + $jsonPath = Export-CodeCovIoJson ` + -CodeCoverage $testResults.CodeCoverage ` + -RepoRoot $ProjectRoot - 'Uploading CodeCoverage to CodeCov.io' - try - { - Invoke-UploadCoveCoveIoReport -Path $jsonPath - } - catch - { - # CodeCov currently reports an error when uploading - # This is not fatal and can be ignored - Write-Warning -Message $_ - } + 'Uploading CodeCoverage to CodeCov.io' + try + { + Invoke-UploadCodeCovIoReport -Path $jsonPath + } + catch + { + # CodeCov currently reports an error when uploading + # This is not fatal and can be ignored + Write-Warning -Message $_ } } else @@ -108,28 +104,9 @@ Task UnitTest -Depends Init, PrepareTest { Write-Warning -Message 'Could not create CodeCov.io report because pester results object did not contain a CodeCoverage object' } - # Upload tests - if ($ENV:BHBuildSystem -eq 'AppVeyor') + if ($testResults.FailedCount -gt 0) { - 'Publishing test results to AppVeyor' - (New-Object 'System.Net.WebClient').UploadFile( - "https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", - (Resolve-Path $testResultsFile)) - - "Publishing test results to AppVeyor as Artifact" - Push-AppveyorArtifact $testResultsFile - - if ($testResults.FailedCount -gt 0) - { - throw "$($testResults.FailedCount) unit tests failed." - } - } - else - { - if ($testResults.FailedCount -gt 0) - { - Write-Error -Exception "$($testResults.FailedCount) unit tests failed." - } + Write-Error -Exception "$($testResults.FailedCount) unit tests failed." } "`n" @@ -169,28 +146,9 @@ Task IntegrationTest -Depends Init, PrepareTest { -PassThru ` -ExcludeTag Incomplete - # Upload tests - if ($ENV:BHBuildSystem -eq 'AppVeyor') - { - 'Publishing test results to AppVeyor' - (New-Object 'System.Net.WebClient').UploadFile( - "https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", - (Resolve-Path $testResultsFile)) - - "Publishing test results to AppVeyor as Artifact" - Push-AppveyorArtifact $testResultsFile - - if ($testResults.FailedCount -gt 0) - { - throw "$($testResults.FailedCount) integration tests failed." - } - } - else + if ($testResults.FailedCount -gt 0) { - if ($testResults.FailedCount -gt 0) - { - Write-Error -Exception "$($testResults.FailedCount) integration tests failed." - } + Write-Error -Exception "$($testResults.FailedCount) integration tests failed." } "`n" @@ -218,12 +176,6 @@ Task Build -Depends Init { -ManifestPath $manifestPath ` -Build $ENV:BHBuildNumber - if ($ENV:BHBuildSystem -eq 'AppVeyor') - { - # Update AppVeyor build version number - Update-AppveyorBuild -Version $newVersion - } - # Determine the folder names for staging the module $stagingFolder = Join-Path -Path $ProjectRoot -ChildPath 'staging' $moduleFolder = Join-Path -Path $stagingFolder -ChildPath $ModuleName @@ -311,7 +263,7 @@ Task Build -Depends Init { # Create the module manifest in the staging folder 'Updating module manifest' $stagedManifestPath = Join-Path -Path $versionFolder -ChildPath "$ModuleName.psd1" - $tempManifestPath = Join-Path -Path $ENV:Temp -ChildPath "$ModuleName.psd1" + $tempManifestPath = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath "$ModuleName.psd1" Import-LocalizedData ` -BindingVariable 'stagedManifestContent' ` diff --git a/test/TestHelper/TestHelper.psm1 b/test/TestHelper/TestHelper.psm1 index 9cf9b623..1d857fc4 100644 --- a/test/TestHelper/TestHelper.psm1 +++ b/test/TestHelper/TestHelper.psm1 @@ -56,7 +56,7 @@ function Connect-AzureServicePrincipal Write-Verbose -Message "Logging in to Azure using Service Principal $ApplicationId" - # Build platform (AppVeyor) does not offer solution for passing secure strings + # Build platform does not offer solution for passing secure strings $azureCredential = New-Object ` -Typename System.Management.Automation.PSCredential ` -Argumentlist $ApplicationId, $applicationPassword