Skip to content

Commit d5cb76f

Browse files
authored
Use vmImage in yaml and merge build definitions into 1 by using jobs. Disable all AppVeyor images except for WMF4. Disable flaky UseCompatibleCommand tests on Ubuntu in CI (#1403)
* 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
1 parent 8b2c02d commit d5cb76f

File tree

7 files changed

+91
-62
lines changed

7 files changed

+91
-62
lines changed

.azure-pipelines-ci/ci-windows-ps5.yaml

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

.azure-pipelines-ci/ci-windows.yaml

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

.azure-pipelines-ci/ci.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
variables:
2+
pwsh: true
3+
# Avoid expensive initialization of dotnet cli, see: https://donovanbrown.com/post/Stop-wasting-time-during-NET-Core-builds
4+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
5+
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
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
variables:
2-
pwsh: true
3-
# Avoid expensive initialization of dotnet cli, see: https://donovanbrown.com/post/Stop-wasting-time-during-NET-Core-builds
4-
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
51
steps:
62
- pwsh: |
73
Import-Module .\tools\appveyor.psm1
84
Invoke-AppveyorInstall
95
./build.ps1 -Configuration 'Release' -PSVersion 6
106
./PSCompatibilityCollector/build.ps1 -Configuration 'Release' -Framework 'netstandard2.0'
117
displayName: 'Build'
12-
- template: templates/test.yaml
8+
- template: test.yaml

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
<img src="logo.png" width="180">
44

5-
[![Build status](https://ci.appveyor.com/api/projects/status/h5mot3vqtvxw5d7l/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/psscriptanalyzer/branch/master) [![Join the chat at https://gitter.im/PowerShell/PSScriptAnalyzer](https://badges.gitter.im/PowerShell/PSScriptAnalyzer.svg)](https://gitter.im/PowerShell/PSScriptAnalyzer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5+
[![Build Status](https://dev.azure.com/powershell/psscriptanalyzer/_apis/build/status/psscriptanalyzer-ci?branchName=master)](https://dev.azure.com/powershell/psscriptanalyzer/_build/latest?definitionId=80&branchName=master)
6+
[![Build status](https://ci.appveyor.com/api/projects/status/h5mot3vqtvxw5d7l/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/psscriptanalyzer/branch/master)
7+
[![Join the chat at https://gitter.im/PowerShell/PSScriptAnalyzer](https://badges.gitter.im/PowerShell/PSScriptAnalyzer.svg)](https://gitter.im/PowerShell/PSScriptAnalyzer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
68

79
Table of Contents
810
=================

Tests/Rules/UseCompatibleCommands.Tests.ps1

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33

4+
$script:RunningInCIOnUbuntu = $IsLinux -and ($env:TF_BUILD -or $env:APPVEYOR) # some test cases randomly start and stop to fail in Ubuntu CI tests
45
$script:RuleName = 'PSUseCompatibleCommands'
56
$script:AnyProfileConfigKey = 'AnyProfilePath'
67
$script:TargetProfileConfigKey = 'TargetProfiles'
@@ -23,6 +24,7 @@ $script:CompatibilityTestCases = @(
2324
@{ Target = $script:Srv2012_3_profile; Script = '"Hello World" | ConvertFrom-String | Get-Member'; Commands = @("ConvertFrom-String"); Version = "3.0"; OS = "Windows"; ProblemCount = 1 }
2425
@{ Target = $script:Srv2012_3_profile; Script = 'Compress-Archive -LiteralPath C:\Reference\Draftdoc.docx, C:\Reference\Images\diagram2.vsd -CompressionLevel Optimal -DestinationPath C:\Archives\Draft.Zip'; Commands = @("Compress-Archive"); Version = "3.0"; OS = "Windows"; ProblemCount = 1 }
2526
@{ Target = $script:Srv2012_3_profile; Script = 'Get-Runspace -Id 2'; Commands = @("Get-Runspace"); Version = "3.0"; OS = "Windows"; ProblemCount = 1 }
27+
@{ Target = $script:Srv2012_3_profile; Script = '$Protected = "Hello World" | Protect-CmsMessage -To "*[email protected]*"'; Commands = @("Protect-CmsMessage"); Version = "3.0"; OS = "Windows"; ProblemCount = 1 }
2628
@{ Target = $script:Srv2012_3_profile; Script = 'Format-Hex -Path "C:\temp\temp.t7f"'; Commands = @("Format-Hex"); Version = "3.0"; OS = "Windows"; ProblemCount = 1 }
2729
@{ Target = $script:Srv2012_3_profile; Script = 'Set-Clipboard -Value "This is a test string"'; Commands = @("Set-Clipboard"); Version = "3.0"; OS = "Windows"; ProblemCount = 1 }
2830
@{ Target = $script:Srv2012_3_profile; Script = 'Clear-RecycleBin -Force'; Commands = @("Clear-RecycleBin"); Version = "3.0"; OS = "Windows"; ProblemCount = 1 }
@@ -62,7 +64,6 @@ $script:CompatibilityTestCases = @(
6264
@{ Target = $script:Srv2019_5_profile; Script = 'gci .'; Commands = @(); Version = "5.1"; OS = "Windows"; ProblemCount = 0 }
6365
@{ Target = $script:Srv2019_5_profile; Script = 'iex $expr | % { Transform $_ }'; Commands = @(); Version = "5.1"; OS = "Windows"; ProblemCount = 0 }
6466
@{ Target = $script:Srv2019_5_profile; Script = 'fhx $filePath'; Commands = @(); Version = "5.1"; OS = "Windows"; ProblemCount = 0 }
65-
6667
@{ Target = $script:Srv2019_6_1_profile; Script = "Add-PSSnapIn MySnapIn"; Commands = @("Add-PSSnapIn"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
6768
@{ Target = $script:Srv2019_6_1_profile; Script = "Get-PSSnapIn MySnapIn"; Commands = @("Get-PSSnapIn"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
6869
@{ Target = $script:Srv2019_6_1_profile; Script = "Get-Content $pshome\about_signing.help.txt | Out-Printer"; Commands = @("Out-Printer"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
@@ -78,6 +79,23 @@ $script:CompatibilityTestCases = @(
7879
@{ Target = $script:Srv2019_6_1_profile; Script = 'Get-ChildItem ./ | Format-List'; Commands = @(); Version = "3.0"; OS = "Windows"; ProblemCount = 0 }
7980
@{ Target = $script:Srv2019_6_1_profile; Script = 'gci .'; Commands = @(); Version = "6.1"; OS = "Windows"; ProblemCount = 0 }
8081
@{ Target = $script:Srv2016_6_1_profile; Script = 'iex $expr | % { Transform $_ }'; Commands = @(); Version = "6.1"; OS = "Windows"; ProblemCount = 0 }
82+
@{ Target = $script:Srv2019_6_1_profile; Script = 'ConvertFrom-String $str'; Commands = @("ConvertFrom-String"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
83+
@{ Target = $script:Srv2019_6_1_profile; Script = "Get-WmiObject -Class Win32_Process"; Commands = @("Get-WmiObject"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
84+
@{ Target = $script:Srv2019_6_1_profile; Script = "Invoke-WmiMethod -Path win32_process -Name create -ArgumentList notepad.exe"; Commands = @("Invoke-WmiMethod"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
85+
@{ Target = $script:Srv2019_6_1_profile; Script = '$np | Remove-WmiObject'; Commands = @("Remove-WmiObject"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
86+
@{ Target = $script:Srv2019_6_1_profile; Script = 'Set-Clipboard -Value "This is a test string"'; Commands = @("Set-Clipboard"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
87+
@{ Target = $script:Srv2019_6_1_profile; Script = "Set-WmiInstance -Class Win32_WMISetting -Argument @{LoggingLevel=2}"; Commands = @("Set-WmiInstance"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
88+
@{ Target = $script:Srv2019_6_1_profile; Script = 'Add-Computer -DomainName "Domain01" -Restart'; Commands = @("Add-Computer"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
89+
@{ Target = $script:Srv2019_6_1_profile; Script = 'Checkpoint-Computer -Description "Install MyApp"'; Commands = @("Checkpoint-Computer"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
90+
@{ Target = $script:Srv2019_6_1_profile; Script = 'Clear-EventLog "Windows PowerShell"'; Commands = @("Clear-EventLog"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
91+
@{ Target = $script:Srv2019_6_1_profile; Script = 'Clear-RecycleBin'; Commands = @("Clear-RecycleBin"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
92+
@{ Target = $script:Srv2019_6_1_profile; Script = 'Start-Transaction; New-Item MyCompany -UseTransaction; Complete-Transaction'; Commands = @("Start-Transaction", "Complete-Transaction"); Version = "6.1"; OS = "Windows"; ProblemCount = 2 }
93+
@{ Target = $script:Srv2019_6_1_profile; Script = 'Disable-ComputerRestore -Drive "C:\"'; Commands = @("Disable-ComputerRestore"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
94+
@{ Target = $script:Srv2019_6_1_profile; Script = 'Enable-ComputerRestore -Drive "C:\", "D:\"'; Commands = @("Enable-ComputerRestore"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
95+
@{ Target = $script:Srv2019_6_1_profile; Script = 'Get-ControlPanelItem -Name "*Program*", "*App*"'; Commands = @("Get-ControlPanelItem"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
96+
@{ Target = $script:Srv2019_6_1_profile; Script = 'Get-EventLog -Newest 5 -LogName "Application"'; Commands = @("Get-EventLog"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
97+
@{ Target = $script:Srv2019_6_1_profile; Script = 'Get-HotFix -Description "Security*" -ComputerName "Server01", "Server02" -Cred "Server01\admin01"'; Commands = @("Get-HotFix"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
98+
@{ Target = $script:Srv2019_6_1_profile; Script = '$zip = New-WebServiceProxy -Uri "http://www.webservicex.net/uszip.asmx?WSDL"'; Commands = @("New-WebServiceProxy"); Version = "6.1"; OS = "Windows"; ProblemCount = 1 }
8199

82100
@{ Target = $script:Ubuntu1804_6_1_profile; Script = 'Get-AuthenticodeSignature ./script.ps1'; Commands = @("Get-AuthenticodeSignature"); Version = "6.1"; OS = "Linux"; ProblemCount = 1 }
83101
@{ Target = $script:Ubuntu1804_6_1_profile; Script = 'Get-Service systemd'; Commands = @("Get-Service"); Version = "6.1"; OS = "Linux"; ProblemCount = 1 }
@@ -120,6 +138,9 @@ $script:ParameterCompatibilityTestCases = @(
120138
@{ Target = $script:Srv2012_3_profile; Script = 'Get-Command -ShowCommandInfo'; Commands = @('Get-Command'); Parameters = @('ShowCommandInfo'); Version = '3.0'; OS = 'Windows'; ProblemCount = 1 }
121139
@{ Target = $script:Srv2012_3_profile; Script = 'Import-Module -FullyQualifiedName @{ ModuleName = "PSScriptAnalyzer"; ModuleVersion = "1.17" }'; Commands = @('Import-Module'); Parameters = @('FullyQualifiedName'); Version = '3.0'; OS = 'Windows'; ProblemCount = 1 }
122140
@{ Target = $script:Srv2012_3_profile; Script = 'Remove-Module -FullyQualifiedName @{ ModuleName = "PSScriptAnalyzer"; ModuleVersion = "1.17" }'; Commands = @('Remove-Module'); Parameters = @('FullyQualifiedName'); Version = '3.0'; OS = 'Windows'; ProblemCount = 1 }
141+
@{ Target = $script:Srv2012_3_profile; Script = 'Register-ScheduledJob -RunNow -Trigger $t'; Commands = @('Register-ScheduledJob'); Parameters = @('RunNow'); Version = '3.0'; OS = 'Windows'; ProblemCount = 1 }
142+
@{ Target = $script:Srv2012_3_profile; Script = 'New-JobTrigger -At "1/20/2012 3:00 AM" -RepeatIndefinitely'; Commands = @('New-JobTrigger'); Parameters = @('RepeatIndefinitely'); Version = '3.0'; OS = 'Windows'; ProblemCount = 1 }
143+
@{ Target = $script:Srv2012_3_profile; Script = '$t = Get-ScheduledJob | Get-JobTrigger | Enable-JobTrigger -PassThru'; Commands = @('Enable-JobTrigger'); Parameters = @('PassThru'); Version = '3.0'; OS = 'Windows'; ProblemCount = 1 }
123144
@{ Target = $script:Srv2012_3_profile; Script = 'Save-Help -FullyQualifiedModule @{ ModuleName = "MyModule"; MaximumVersion = "2.7" }'; Commands = @('Save-Help'); Parameters = @('FullyQualifiedModule'); Version = '3.0'; OS = 'Windows'; ProblemCount = 1 }
124145
@{ Target = $script:Srv2012_3_profile; Script = 'Export-PSSession -FullyQualifiedModule @{ ModuleName = "MyModule"; RequiredVersion = $reqVer }'; Commands = @('Export-PSSession'); Parameters = @('FullyQualifiedModule'); Version = '3.0'; OS = 'Windows'; ProblemCount = 1 }
125146
@{ Target = $script:Srv2012_3_profile; Script = 'Get-Command -FullyQualifiedModule @{ ModuleName = $m; MaximumVersion = $maxVer }'; Commands = @('Get-Command'); Parameters = @('FullyQualifiedModule'); Version = '3.0'; OS = 'Windows'; ProblemCount = 1 }
@@ -155,23 +176,9 @@ $script:ParameterCompatibilityTestCases = @(
155176
@{ Target = $script:Srv2019_6_1_profile; Script = 'Start-Service "eventlog" -ComputerName "MyComputer"'; Commands = @('Start-Service'); Parameters = @('ComputerName'); Version = '6.1'; OS = 'Windows'; ProblemCount = 1 }
156177
)
157178

158-
# Disabled on AppVeyor's Ubuntu image until fixed
159-
if (-not $IsLinux -and $env:APPVEYOR) {
160-
$script:CompatibilityTestCases += @(
161-
@{ Target = $script:Srv2012_3_profile; Script = '$Protected = "Hello World" | Protect-CmsMessage -To "*[email protected]*"'; Commands = @("Protect-CmsMessage"); Version = "3.0"; OS = "Windows"; ProblemCount = 1 }
162-
)
163-
164-
$script:ParameterCompatibilityTestCases += @(
165-
@{ Target = $script:Srv2012_3_profile; Script = 'Register-ScheduledJob -RunNow -Trigger $t'; Commands = @('Register-ScheduledJob'); Parameters = @('RunNow'); Version = '3.0'; OS = 'Windows'; ProblemCount = 1 }
166-
@{ Target = $script:Srv2012_3_profile; Script = 'New-JobTrigger -At "1/20/2012 3:00 AM" -RepeatIndefinitely'; Commands = @('New-JobTrigger'); Parameters = @('RepeatIndefinitely'); Version = '3.0'; OS = 'Windows'; ProblemCount = 1 }
167-
@{ Target = $script:Srv2012_3_profile; Script = '$t = Get-ScheduledJob | Get-JobTrigger | Enable-JobTrigger -PassThru'; Commands = @('Enable-JobTrigger'); Parameters = @('PassThru'); Version = '3.0'; OS = 'Windows'; ProblemCount = 1 }
168-
)
169-
}
170-
171-
172179
Describe 'UseCompatibleCommands' {
173180
Context 'Targeting a single profile' {
174-
It "Reports <ProblemCount> command incompatibilties with '<Script>' on <OS> with PowerShell <Version>" -TestCases $script:CompatibilityTestCases {
181+
It "Reports <ProblemCount> command incompatibilties with '<Script>' on <OS> with PowerShell <Version>" -TestCases $script:CompatibilityTestCases -Skip:$script:RunningInCIOnUbuntu {
175182
param($Script, [string]$Target, [string[]]$Commands, [version]$Version, [string]$OS, [int]$ProblemCount)
176183

177184
$settings = @{
@@ -197,7 +204,7 @@ Describe 'UseCompatibleCommands' {
197204
}
198205
}
199206

200-
It "Reports <ProblemCount> parameter incompatibilties for '<Parameters>' on '<Commands>' with '<Script>' on <OS> with PowerShell <Version>" -TestCases $script:ParameterCompatibilityTestCases {
207+
It "Reports <ProblemCount> parameter incompatibilties for '<Parameters>' on '<Commands>' with '<Script>' on <OS> with PowerShell <Version>" -TestCases $script:ParameterCompatibilityTestCases -Skip:$script:RunningInCIOnUbuntu {
201208
param($Script, [string]$Target, [string[]]$Commands, [string[]]$Parameters, [version]$Version, [string]$OS, [int]$ProblemCount)
202209

203210
$settings = @{
@@ -225,7 +232,7 @@ Describe 'UseCompatibleCommands' {
225232
}
226233

227234
Context "Checking a file against many targets" {
228-
It "Finds all command problems" {
235+
It "Finds all command problems" -Skip:$script:RunningInCIOnUbuntu {
229236
$settings = @{
230237
Rules = @{
231238
$script:RuleName = @{
@@ -244,7 +251,7 @@ Describe 'UseCompatibleCommands' {
244251
$diagnostics = Invoke-ScriptAnalyzer -Path "$PSScriptRoot/CompatibilityRuleAssets/IncompatibleScript.ps1" -IncludeRule $script:RuleName -Settings $settings `
245252
| Where-Object { $_.RuleName -eq $script:RuleName }
246253

247-
$expectedNumber = if ($env:TF_BUILD -and $IsLinux) { 13 } else { 14 }
254+
$expectedNumber = 14
248255

249256
$diagnostics.Count | Should -Be $expectedNumber -Because "Got diagnostics: $($diagnostics.Message -join ", ")"
250257

appveyor.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ environment:
33
BuildConfiguration: Release
44
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # For faster CI builds
55
matrix:
6-
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
7-
PowerShellEdition: PowerShellCore
8-
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
9-
PowerShellEdition: WindowsPowerShell
10-
- APPVEYOR_BUILD_WORKER_IMAGE: WMF 4
11-
PowerShellEdition: WindowsPowerShell
12-
PSVersion: 4
13-
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
14-
PowerShellEdition: PowerShellCore
6+
- APPVEYOR_BUILD_WORKER_IMAGE: WMF 4
7+
PowerShellEdition: WindowsPowerShell
8+
PSVersion: 4
9+
## Only the tests for WMF4 remain active in AppVeyor due to Azure DevOps not offering such images ##
10+
# - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
11+
# PowerShellEdition: PowerShellCore
12+
# - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
13+
# PowerShellEdition: WindowsPowerShell
14+
# - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
15+
# PowerShellEdition: PowerShellCore
1516

1617
# cache Nuget packages and dotnet CLI cache
1718
cache:

0 commit comments

Comments
 (0)