Reputation: 674
I have a PowerShell module on github which has automation on AppVeyor including testing and publishing.
One of the recent changes broke the new version with Windows PowerShell. Some groups still run on Windows PowerShell and they informed me about this (former colleagues).
My question is if and how can a given module be tested for both versions with Pester. Obviously on a windows system you can run the test with pwsh
or powershell
but I wonder if there is a cleaner setup powered by Pester
v5.
On top of that, I wonder how would this be possible with AppVeyor because from the doc there is no image with both v5 and v7 of powershell? As an alternative, the doc mentions that multiple images can be used but I don't understand what will happen. The goal is to test on windows and core and publish once.
Upvotes: 2
Views: 89
Reputation: 23395
I used to do this via AppVeyor for some of my PowerShell modules. My use case was actually to test under Linux as well as Windows, but in doing so I was effectively testing on PS Core and Windows PowerShell. The module is no longer using AppVeyor, but I went back in the commit history and pulled the below from its appveyor.yml.
As Mathias said, you want to use multiple images and you can have also have different images run different build scripts if needed:
image:
- WMF 5
- Ubuntu
- Visual Studio 2017
# Skip on updates to the readme.
# We can force this by adding [skip ci] or [ci skip] anywhere in commit message
skip_commits:
message: /updated README.*|update README.*s/
build: false
#Kick off the CI/CD pipeline
test_script:
- pwsh: .\build.ps1
for:
-
matrix:
only:
- image: WMF 5
test_script:
- ps: .\build.ps1
This uses 3 images I think because it was testing on Windows PowerShell, PS Core on Ubuntu and PS Core on Windows.
Upvotes: 1