Skip to content

Commit

Permalink
Multi-stage pipelines (to split build->test) (#1404)
Browse files Browse the repository at this point in the history
* try using multi-job yaml with different images

* fix indentation

* add vm images to windows build and templatify unix build. Images now are latest ubuntu image

* trigger

* fix yaml path

* disable sporadic tests generally and add both Ubuntu images to the tests

* job name in quotes and disable redundant appveyor matrix entries

* whitespace not allowed for job name

* dots arent allowed either...

* last fix

* Merge all entry path yaml files into one yaml.ci file

* fix windows powershell job

* tweak step name for ps5 to be consistent

* re-trigger

* add badge

* multi stage build-test

* bootstrap pester

* Cleanup and avoid Pester bootstrap in build stage

* download pipeline artifact in test stage

* try fix artifact download path

* try fix artifact path using '$(Build.SourcesDirectory)/out' and add debugging info

* fix ps syntax

* remove debugging step

* Fix suggestion text to have platform specific newlines and enable test on Linux

* add more windows images

* try use strategy

* try

* fix job name

* rename and try to not use a job name

* remove pwsh variable, which is now redundant as it is now in test.yaml

* remove old comment

* try fix tests on wmf4

* try use -be instead of -match operator

* fix wmf4 test failure due to CRLF not being correctly used in this version

* make pscompatiblitycollector build against all frameworks again
  • Loading branch information
bergmeister authored Feb 4, 2020
1 parent a415198 commit 1305c88
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 70 deletions.
90 changes: 43 additions & 47 deletions .azure-pipelines-ci/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,51 +1,47 @@
variables:
pwsh: true
# Avoid expensive initialization of dotnet cli, see: https://donovanbrown.com/post/Stop-wasting-time-during-NET-Core-builds
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1

jobs:
- job: 'Ubuntu_16_04'
pool:
vmImage: ubuntu-16.04
steps:
- template: templates/unix.yaml

- job: 'Ubuntu_18_04'
pool:
vmImage: ubuntu-18.04
steps:
- template: templates/unix.yaml

- job: macOS
pool:
vmImage: macos-latest
steps:
- template: templates/unix.yaml

- job: 'Windows_PowerShell_5_1'
pool:
vmImage: windows-latest
steps:
- powershell: |
Import-Module .\tools\appveyor.psm1
Invoke-AppveyorInstall
./build.ps1 -Configuration 'Release' -PSVersion 5
./PSCompatibilityCollector/build.ps1 -Configuration 'Release' -Framework 'net452'
displayName: 'Build'
- template: templates/test.yaml
parameters:
pwsh: false

- job: 'Windows_PowerShell_Core'
pool:
vmImage: windows-latest
steps:
- pwsh: |
Import-Module .\tools\appveyor.psm1
Invoke-AppveyorInstall
./build.ps1 -Configuration 'Release' -All
./PSCompatibilityCollector/build.ps1 -Configuration 'Release' -Framework 'netstandard2.0'
displayName: 'Full Build'
- template: templates/test.yaml
parameters:
pwsh: true
stages:
- stage: Build
jobs:
- job: 'Full_Build'
pool:
vmImage: windows-latest
steps:
- pwsh: |
Import-Module .\tools\appveyor.psm1
Invoke-AppveyorInstall -SkipPesterInstallation
./build.ps1 -Configuration 'Release' -All
./PSCompatibilityCollector/build.ps1 -Configuration 'Release'
displayName: 'Full Build'
- task: PublishPipelineArtifact@1
displayName: 'Publish Pipeline Artifact: out Folder'
inputs:
targetPath: '$(Build.SourcesDirectory)/out'
artifactName: out
- stage: Test
jobs:
- job:
strategy:
matrix:
Ubuntu_16_04:
vmImage: ubuntu-16.04
Ubuntu_18_04:
vmImage: ubuntu-18.04
macOS:
vmImage: macos-latest
Windows_Server2016_PowerShell_Core:
vmImage: windows-2019
Windows_Server2019_PowerShell_Core:
vmImage: windows-2019
Windows_Server2016_PowerShell_5_1:
vmImage: vs2017-win2016
pwsh: false
Windows_Server2019_PowerShell_5_1:
vmImage: vs2017-win2016
pwsh: false
pool:
vmImage: $[ variables['vmImage'] ]
steps:
- template: templates/test.yaml
10 changes: 10 additions & 0 deletions .azure-pipelines-ci/templates/test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
parameters:
- name: pwsh
type: boolean
default: true

steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download Pipeline Artifact: out Folder'
inputs:
artifactName: out
targetPath: '$(Build.SourcesDirectory)/out'
- task: PowerShell@2
displayName: 'Test'
inputs:
Expand Down
8 changes: 0 additions & 8 deletions .azure-pipelines-ci/templates/unix.yaml

This file was deleted.

7 changes: 3 additions & 4 deletions Rules/MissingModuleManifestField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,9 @@ private List<CorrectionExtent> GetCorrectionExtent(HashtableAst ast)
Strings.MissingModuleManifestFieldCorrectionDescription,
fieldName,
fieldValue);
var correctionTextTemplate = @"
# Version number of this module.
{0} = '{1}'
";
var correctionTextTemplate = string.Concat(Environment.NewLine,
"# Version number of this module.", Environment.NewLine,
"{0} = '{1}'", Environment.NewLine);
var correctionText = string.Format(
correctionTextTemplate,
fieldName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ Describe "MissingRequiredFieldModuleManifest" {
$violations.SuggestedCorrections.Count | Should -Be $numExpectedCorrections
}

# On Linux, mismatch in line endings cause this to fail
It "has the right suggested correction" -Skip:($IsLinux) {
$expectedText = @'
# Version number of this module.
ModuleVersion = '1.0.0.0'
'@
$violations[0].SuggestedCorrections[0].Text | Should -Match $expectedText
Get-ExtentText $violations[0].SuggestedCorrections[0] $violationFilepath | Should -BeNullOrEmpty
It "has the right suggested correction" {
$expectedText = [System.Environment]::NewLine + '# Version number of this module.' +
[System.Environment]::NewLine + "ModuleVersion = '1.0.0.0'" + [System.Environment]::NewLine

$violations[0].SuggestedCorrections[0].Text | Should -BeExactly $expectedText
Get-ExtentText $violations[0].SuggestedCorrections[0] $violationFilepath | Should -BeNullOrEmpty
}
}

Expand Down
17 changes: 14 additions & 3 deletions tools/appveyor.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

$ErrorActionPreference = 'Stop'

# Implements the AppVeyor 'install' step and installs the required versions of Pester, platyPS and the .Net Core SDK if needed.
function Invoke-AppVeyorInstall {
$requiredPesterVersion = '4.4.4'
function Install-Pester {
$requiredPesterVersion = '4.10.0'
$pester = Get-Module Pester -ListAvailable | Where-Object { $_.Version -eq $requiredPesterVersion }
if ($null -eq $pester) {
if ($null -eq (Get-Module -ListAvailable PowershellGet)) {
Expand All @@ -19,6 +18,16 @@ function Invoke-AppVeyorInstall {
Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser -Repository PSGallery
}
}
}

# Implements the AppVeyor 'install' step and installs the required versions of Pester, platyPS and the .Net Core SDK if needed.
function Invoke-AppVeyorInstall {
param(
# For the multi-stage build in Azure DevOps, Pester is not needed for bootstrapping the build environment
[switch] $SkipPesterInstallation
)

if (-not $SkipPesterInstallation.IsPresent) { Install-Pester }

if ($null -eq (Get-Module -ListAvailable PowershellGet)) {
# WMF 4 image build
Expand Down Expand Up @@ -72,6 +81,8 @@ function Invoke-AppveyorTest {
$CheckoutPath
)

Install-Pester

# enforce the language to utf-8 to avoid issues
$env:LANG = "en_US.UTF-8"
Write-Verbose -Verbose ("Running tests on PowerShell version " + $PSVersionTable.PSVersion)
Expand Down

0 comments on commit 1305c88

Please sign in to comment.