-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
appveyor: Run tests for PowerShell 5 and 6
- Add commit flag to skip PSScriptAnalyzer - Add commit flag to skip manifest validation - Skips manifest validation if no JSON has changed - Skips test and linting if no PowerShell script has changed
- Loading branch information
Showing
11 changed files
with
140 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Write-Host "PowerShell: $($PSVersionTable.PSVersion)" | ||
|
||
Write-Host "Install dependencies ..." | ||
Install-Module -Repository PSGallery -Scope CurrentUser -Force -Name Pester -SkipPublisherCheck | ||
Install-Module -Repository PSGallery -Scope CurrentUser -Name PSScriptAnalyzer,BuildHelpers | ||
|
||
if($env:CI -eq $true) { | ||
Write-Host "Load 'BuildHelpers' environment variables ..." | ||
Set-BuildEnvironment -Force | ||
} | ||
|
||
$buildVariables = ( Get-ChildItem -Path 'Env:' ).Where( { $_.Name -match "^(?:BH|CI(?:_|$)|APPVEYOR)" } ) | ||
$buildVariables += ( Get-Variable -Name 'CI_*' -Scope 'Script' ) | ||
$details = $buildVariables | | ||
Where-Object -FilterScript { $_.Name -notmatch 'EMAIL' } | | ||
Sort-Object -Property 'Name' | | ||
Format-Table -AutoSize -Property 'Name', 'Value' | | ||
Out-String | ||
Write-Host "CI variables:" | ||
Write-Host $details -ForegroundColor DarkGray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#requires -Version 5.0 | ||
#requires -Modules @{ ModuleName = 'BuildHelpers'; ModuleVersion = '1.2.0' } | ||
#requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '4.4.0' } | ||
#requires -Modules @{ ModuleName = 'PSScriptAnalyzer'; ModuleVersion = '1.17.1' } | ||
|
||
$resultsXml = "$PSScriptRoot/TestResults.xml" | ||
$excludes = @() | ||
|
||
$splat = @{ | ||
Path = 'test/' | ||
OutputFile = $resultsXml | ||
OutputFormat = 'NUnitXML' | ||
PassThru = $true | ||
} | ||
|
||
if($env:CI -eq $true) { | ||
$commit = if($env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT) { $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT } else { $env:APPVEYOR_REPO_COMMIT } | ||
$commitMessage = "$env:APPVEYOR_REPO_COMMIT_MESSAGE $env:APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED".TrimEnd() | ||
|
||
if($commitMessage -match '!linter') { | ||
Write-Warning "Skipping code linting per commit flag '!linter'" | ||
$excludes += 'Linter' | ||
} | ||
|
||
$changed_scripts = (Get-GitChangedFile -Include '*.ps1' -Commit $commit) | ||
if(!$changed_scripts) { | ||
Write-Warning "Skipping tests and code linting for *.ps1 files because they didn't change" | ||
$excludes += 'Linter' | ||
$excludes += 'Scoop' | ||
} | ||
|
||
if($commitMessage -match '!manifests') { | ||
Write-Warning "Skipping manifest validation per commit flag '!manifests'" | ||
$excludes += 'Manifests' | ||
} | ||
|
||
$changed_manifests = (Get-GitChangedFile -Include '*.json' -Commit $commit) | ||
if(!$changed_manifests) { | ||
Write-Warning "Skipping tests and validation for manifest files because they didn't change" | ||
$excludes += 'Manifests' | ||
} | ||
|
||
if($excludes.Length -gt 0) { | ||
$splat.ExcludeTag = $excludes | ||
} | ||
} | ||
|
||
Write-Host 'Invoke-Pester' @splat | ||
$result = Invoke-Pester @splat | ||
|
||
(New-Object Net.WebClient).UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", $resultsXml) | ||
|
||
if($result.FailedCount -gt 0) { | ||
exit $result.FailedCount | ||
} |