|
1 | 1 | environment:
|
2 | 2 | matrix:
|
3 | 3 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
4 |
| - PowerShellEdition: Desktop |
| 4 | + PowerShellEdition: PowerShellCore |
| 5 | + BuildConfiguration: Release |
| 6 | + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 |
| 7 | + PowerShellEdition: WindowsPowerShell |
5 | 8 | BuildConfiguration: Release
|
6 | 9 | - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4
|
7 |
| - PowerShellEdition: Desktop |
| 10 | + PowerShellEdition: WindowsPowerShell |
8 | 11 | BuildConfiguration: PSv3Release
|
9 | 12 |
|
10 |
| -# clone directory |
11 |
| -clone_folder: c:\projects\psscriptanalyzer |
12 |
| - |
13 | 13 | # cache Nuget packages and dotnet CLI cache
|
14 | 14 | cache:
|
15 | 15 | - '%USERPROFILE%\.nuget\packages -> appveyor.yml'
|
16 | 16 | - '%LocalAppData%\Microsoft\dotnet -> appveyor.yml'
|
17 | 17 |
|
18 |
| -# Install Pester |
19 | 18 | install:
|
20 |
| - - ps: nuget install platyPS -Version 0.9.0 -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion |
21 |
| - - ps: | |
22 |
| - $requiredPesterVersion = '4.3.1' |
23 |
| - $pester = Get-Module Pester -ListAvailable | Where-Object { $_.Version -eq $requiredPesterVersion } |
24 |
| - $pester |
25 |
| - if ($null -eq $pester) |
26 |
| - { |
27 |
| - if ($null -eq (Get-Module -ListAvailable PowershellGet)) |
28 |
| - { |
29 |
| - # WMF 4 image build |
30 |
| - nuget install Pester -Version $requiredPesterVersion -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion |
31 |
| - } |
32 |
| - else |
33 |
| - { |
34 |
| - # Visual Studio 2017 build (has already Pester v3, therefore a different installation mechanism is needed to make it also use the new version 4) |
35 |
| - Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser |
36 |
| - } |
37 |
| - } |
38 |
| - - ps: | |
39 |
| - # the legacy WMF4 image only has the old preview SDKs of dotnet |
40 |
| - $globalDotJson = Get-Content .\global.json -Raw | ConvertFrom-Json |
41 |
| - $dotNetCoreSDKVersion = $globalDotJson.sdk.version |
42 |
| - if (-not ((dotnet --version).StartsWith($dotNetCoreSDKVersion))) |
43 |
| - { |
44 |
| - Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1 |
45 |
| - .\dotnet-install.ps1 -Version $dotNetCoreSDKVersion |
46 |
| - } |
| 19 | + - ps: Import-Module .\tools\appveyor.psm1 |
| 20 | + - ps: if ($env:PowerShellEdition -eq 'WindowsPowerShell') { Invoke-AppveyorInstall } |
| 21 | + - pwsh: if ($env:PowerShellEdition -eq 'PowerShellCore') { Import-Module .\tools\appveyor.psm1; Invoke-AppveyorInstall } |
47 | 22 |
|
48 | 23 | build_script:
|
49 |
| - - ps: | |
50 |
| - $PSVersionTable |
51 |
| - Write-Verbose "Pester version: $((Get-Command Invoke-Pester).Version)" -Verbose |
52 |
| - Write-Verbose ".NET SDK version: $(dotnet --version)" -Verbose |
53 |
| - Push-Location C:\projects\psscriptanalyzer |
54 |
| - # Test build using netstandard to test whether APIs are being called that are not available in .Net Core. Remove output afterwards. |
55 |
| - .\buildCoreClr.ps1 -Framework netstandard1.6 -Configuration Release -Build |
56 |
| - git clean -dfx |
57 |
| - C:\projects\psscriptanalyzer\buildCoreClr.ps1 -Framework net451 -Configuration $env:BuildConfiguration -Build |
58 |
| - C:\projects\psscriptanalyzer\build.ps1 -BuildDocs |
59 |
| - Pop-Location |
60 |
| -
|
61 |
| -# branches to build |
62 |
| -branches: |
63 |
| - # whitelist |
64 |
| - only: |
65 |
| - - master |
66 |
| - - development |
| 24 | + - ps: | |
| 25 | + if ($env:PowerShellEdition -eq 'WindowsPowerShell') { |
| 26 | + Invoke-AppveyorBuild -CheckoutPath $env:APPVEYOR_BUILD_FOLDER -BuildConfiguration $env:BuildConfiguration -BuildType 'FullCLR' |
| 27 | + } |
| 28 | + - pwsh: | |
| 29 | + if ($env:PowerShellEdition -eq 'PowerShellCore') { |
| 30 | + Import-Module .\tools\appveyor.psm1 # Appveyor does not persist pwsh sessions like it does for ps |
| 31 | + Invoke-AppveyorBuild -CheckoutPath $env:APPVEYOR_BUILD_FOLDER -BuildConfiguration $env:BuildConfiguration -BuildType 'NetStandard' |
| 32 | + } |
67 | 33 |
|
68 |
| -# Run Pester tests and store the results |
| 34 | +# Test scripts are not in a module function because the tests behave differently for unknown reasons in AppVeyor |
69 | 35 | test_script:
|
70 |
| - - SET PATH=c:\Program Files\WindowsPowerShell\Modules\;%PATH%; |
71 |
| - - ps: | |
72 |
| - copy-item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\WindowsPowerShell\Modules\" -Recurse -Force |
73 |
| - $testResultsFile = ".\TestResults.xml" |
74 |
| - $testScripts = "C:\projects\psscriptanalyzer\Tests\Engine","C:\projects\psscriptanalyzer\Tests\Rules" |
75 |
| - $testResults = Invoke-Pester -Script $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru |
76 |
| - (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile)) |
77 |
| - if ($testResults.FailedCount -gt 0) { |
78 |
| - throw "$($testResults.FailedCount) tests failed." |
79 |
| - } |
| 36 | + - ps: | |
| 37 | + if ($env:PowerShellEdition -eq 'WindowsPowerShell') { |
| 38 | + $modulePath = $env:PSModulePath.Split([System.IO.Path]::PathSeparator) | Where-Object { Test-Path $_} | Select-Object -First 1 |
| 39 | + Copy-Item "${env:APPVEYOR_BUILD_FOLDER}\out\PSScriptAnalyzer" "$modulePath\" -Recurse -Force |
| 40 | + $testResultsFile = ".\TestResults.xml" |
| 41 | + $testScripts = "${env:APPVEYOR_BUILD_FOLDER}\Tests\Engine","${env:APPVEYOR_BUILD_FOLDER}\Tests\Rules" |
| 42 | + $testResults = Invoke-Pester -Script $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru |
| 43 | + (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/${env:APPVEYOR_JOB_ID}", (Resolve-Path $testResultsFile)) |
| 44 | + if ($testResults.FailedCount -gt 0) { |
| 45 | + throw "$($testResults.FailedCount) tests failed." |
| 46 | + } |
| 47 | + } |
| 48 | + - pwsh: | |
| 49 | + if ($env:PowerShellEdition -eq 'PowerShellCore') { |
| 50 | + $modulePath = $env:PSModulePath.Split(';') | Where-Object { Test-Path $_} | Select-Object -First 1 |
| 51 | + Copy-Item "${env:APPVEYOR_BUILD_FOLDER}\out\PSScriptAnalyzer" "$modulePath\" -Recurse -Force |
| 52 | + $testResultsFile = ".\TestResults.xml" |
| 53 | + $testScripts = "${env:APPVEYOR_BUILD_FOLDER}\Tests\Engine","${env:APPVEYOR_BUILD_FOLDER}\Tests\Rules" |
| 54 | + $testResults = Invoke-Pester -Script $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru |
| 55 | + (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/${env:APPVEYOR_JOB_ID}", (Resolve-Path $testResultsFile)) |
| 56 | + if ($testResults.FailedCount -gt 0) { |
| 57 | + throw "$($testResults.FailedCount) tests failed." |
| 58 | + } |
| 59 | + } |
80 | 60 |
|
81 |
| -# Upload the project along with TestResults as a zip archive |
| 61 | +# Upload the project along with test results as a zip archive |
82 | 62 | on_finish:
|
83 |
| - - ps: | |
84 |
| - $stagingDirectory = (Resolve-Path ..).Path |
85 |
| - $zipFile = Join-Path $stagingDirectory "$(Split-Path $pwd -Leaf).zip" |
86 |
| - Add-Type -assemblyname System.IO.Compression.FileSystem |
87 |
| - [System.IO.Compression.ZipFile]::CreateFromDirectory($pwd, $zipFile) |
88 |
| - @( |
89 |
| - # You can add other artifacts here |
90 |
| - (ls $zipFile) |
91 |
| - ) | % { Push-AppveyorArtifact $_.FullName } |
| 63 | + - ps: Invoke-AppveyorFinish |
0 commit comments