Skip to content

Commit 1305c88

Browse files
authored
Multi-stage pipelines (to split build->test) (#1404)
* 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
1 parent a415198 commit 1305c88

File tree

6 files changed

+76
-70
lines changed

6 files changed

+76
-70
lines changed

.azure-pipelines-ci/ci.yaml

Lines changed: 43 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,47 @@
11
variables:
2-
pwsh: true
32
# Avoid expensive initialization of dotnet cli, see: https://donovanbrown.com/post/Stop-wasting-time-during-NET-Core-builds
43
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
54

6-
jobs:
7-
- job: 'Ubuntu_16_04'
8-
pool:
9-
vmImage: ubuntu-16.04
10-
steps:
11-
- template: templates/unix.yaml
12-
13-
- job: 'Ubuntu_18_04'
14-
pool:
15-
vmImage: ubuntu-18.04
16-
steps:
17-
- template: templates/unix.yaml
18-
19-
- job: macOS
20-
pool:
21-
vmImage: macos-latest
22-
steps:
23-
- template: templates/unix.yaml
24-
25-
- job: 'Windows_PowerShell_5_1'
26-
pool:
27-
vmImage: windows-latest
28-
steps:
29-
- powershell: |
30-
Import-Module .\tools\appveyor.psm1
31-
Invoke-AppveyorInstall
32-
./build.ps1 -Configuration 'Release' -PSVersion 5
33-
./PSCompatibilityCollector/build.ps1 -Configuration 'Release' -Framework 'net452'
34-
displayName: 'Build'
35-
- template: templates/test.yaml
36-
parameters:
37-
pwsh: false
38-
39-
- job: 'Windows_PowerShell_Core'
40-
pool:
41-
vmImage: windows-latest
42-
steps:
43-
- pwsh: |
44-
Import-Module .\tools\appveyor.psm1
45-
Invoke-AppveyorInstall
46-
./build.ps1 -Configuration 'Release' -All
47-
./PSCompatibilityCollector/build.ps1 -Configuration 'Release' -Framework 'netstandard2.0'
48-
displayName: 'Full Build'
49-
- template: templates/test.yaml
50-
parameters:
51-
pwsh: true
5+
stages:
6+
- stage: Build
7+
jobs:
8+
- job: 'Full_Build'
9+
pool:
10+
vmImage: windows-latest
11+
steps:
12+
- pwsh: |
13+
Import-Module .\tools\appveyor.psm1
14+
Invoke-AppveyorInstall -SkipPesterInstallation
15+
./build.ps1 -Configuration 'Release' -All
16+
./PSCompatibilityCollector/build.ps1 -Configuration 'Release'
17+
displayName: 'Full Build'
18+
- task: PublishPipelineArtifact@1
19+
displayName: 'Publish Pipeline Artifact: out Folder'
20+
inputs:
21+
targetPath: '$(Build.SourcesDirectory)/out'
22+
artifactName: out
23+
- stage: Test
24+
jobs:
25+
- job:
26+
strategy:
27+
matrix:
28+
Ubuntu_16_04:
29+
vmImage: ubuntu-16.04
30+
Ubuntu_18_04:
31+
vmImage: ubuntu-18.04
32+
macOS:
33+
vmImage: macos-latest
34+
Windows_Server2016_PowerShell_Core:
35+
vmImage: windows-2019
36+
Windows_Server2019_PowerShell_Core:
37+
vmImage: windows-2019
38+
Windows_Server2016_PowerShell_5_1:
39+
vmImage: vs2017-win2016
40+
pwsh: false
41+
Windows_Server2019_PowerShell_5_1:
42+
vmImage: vs2017-win2016
43+
pwsh: false
44+
pool:
45+
vmImage: $[ variables['vmImage'] ]
46+
steps:
47+
- template: templates/test.yaml

.azure-pipelines-ci/templates/test.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1+
parameters:
2+
- name: pwsh
3+
type: boolean
4+
default: true
5+
16
steps:
7+
- task: DownloadPipelineArtifact@2
8+
displayName: 'Download Pipeline Artifact: out Folder'
9+
inputs:
10+
artifactName: out
11+
targetPath: '$(Build.SourcesDirectory)/out'
212
- task: PowerShell@2
313
displayName: 'Test'
414
inputs:

.azure-pipelines-ci/templates/unix.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.

Rules/MissingModuleManifestField.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,9 @@ private List<CorrectionExtent> GetCorrectionExtent(HashtableAst ast)
115115
Strings.MissingModuleManifestFieldCorrectionDescription,
116116
fieldName,
117117
fieldValue);
118-
var correctionTextTemplate = @"
119-
# Version number of this module.
120-
{0} = '{1}'
121-
";
118+
var correctionTextTemplate = string.Concat(Environment.NewLine,
119+
"# Version number of this module.", Environment.NewLine,
120+
"{0} = '{1}'", Environment.NewLine);
122121
var correctionText = string.Format(
123122
correctionTextTemplate,
124123
fieldName,

Tests/Rules/AvoidUnloadableModuleOrMissingRequiredFieldInManifest.tests.ps1

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@ Describe "MissingRequiredFieldModuleManifest" {
3232
$violations.SuggestedCorrections.Count | Should -Be $numExpectedCorrections
3333
}
3434

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

tools/appveyor.psm1

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
$ErrorActionPreference = 'Stop'
55

6-
# Implements the AppVeyor 'install' step and installs the required versions of Pester, platyPS and the .Net Core SDK if needed.
7-
function Invoke-AppVeyorInstall {
8-
$requiredPesterVersion = '4.4.4'
6+
function Install-Pester {
7+
$requiredPesterVersion = '4.10.0'
98
$pester = Get-Module Pester -ListAvailable | Where-Object { $_.Version -eq $requiredPesterVersion }
109
if ($null -eq $pester) {
1110
if ($null -eq (Get-Module -ListAvailable PowershellGet)) {
@@ -19,6 +18,16 @@ function Invoke-AppVeyorInstall {
1918
Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser -Repository PSGallery
2019
}
2120
}
21+
}
22+
23+
# Implements the AppVeyor 'install' step and installs the required versions of Pester, platyPS and the .Net Core SDK if needed.
24+
function Invoke-AppVeyorInstall {
25+
param(
26+
# For the multi-stage build in Azure DevOps, Pester is not needed for bootstrapping the build environment
27+
[switch] $SkipPesterInstallation
28+
)
29+
30+
if (-not $SkipPesterInstallation.IsPresent) { Install-Pester }
2231

2332
if ($null -eq (Get-Module -ListAvailable PowershellGet)) {
2433
# WMF 4 image build
@@ -72,6 +81,8 @@ function Invoke-AppveyorTest {
7281
$CheckoutPath
7382
)
7483

84+
Install-Pester
85+
7586
# enforce the language to utf-8 to avoid issues
7687
$env:LANG = "en_US.UTF-8"
7788
Write-Verbose -Verbose ("Running tests on PowerShell version " + $PSVersionTable.PSVersion)

0 commit comments

Comments
 (0)