Skip to content

Try forcing the Matrix tests to be in "Windows PowerShell" #168

Try forcing the Matrix tests to be in "Windows PowerShell"

Try forcing the Matrix tests to be in "Windows PowerShell" #168

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: write # to tag the repository
checks: write # to create the check runs results
jobs:
build:
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
steps:
- name: Install EarthBuild
uses: EarthBuild/actions-setup@v2.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: 'latest' # or pin to an specific version, e.g. "0.8.1"
- uses: actions/checkout@v6
with:
submodules: true
fetch-depth: 0
- name: earth +test
if: github.ref != 'refs/heads/main'
run: earth --strict +test
- name: earth +push
if: github.ref == 'refs/heads/main'
run: earth --push --secret NUGET_API_KEY --secret IB_PS_PUBLISH_KEY --strict +all
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
IB_PS_PUBLISH_KEY: ${{ secrets.PSGALLERY_API_KEY }}
- name: Upload Built Modules
uses: actions/upload-artifact@v7
with:
name: ModuleBuilder
path: output/ModuleBuilder
- uses: actions/upload-artifact@v7
with:
name: TestResults
path: output/results
# These ones are just for the test matrix
- name: Upload Tests
uses: actions/upload-artifact@v7
with:
name: PesterTests
path: ${{github.workspace}}/Tests
- name: Upload build.requires.psd1
uses: actions/upload-artifact@v7
with:
name: build.requires.psd1
path: ${{github.workspace}}/build.requires.psd1
test:
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ windows-latest, ubuntu-latest, macos-latest ]
shell: [ pwsh ]
include:
- os: windows-latest
shell: powershell
steps:
- name: Download build.requires.psd1
uses: actions/download-artifact@v8
with:
name: build.requires.psd1
- name: Download Build Output
uses: actions/download-artifact@v8
with:
name: ModuleBuilder
path: Modules/ModuleBuilder # /home/runner/work/ModuleBuilder/ModuleBuilder/output/ModuleBuilder
- name: Download Pester Tests
uses: actions/download-artifact@v8
with:
name: PesterTests
path: PesterTests
# Avoid installing ModuleBuilder with ModuleFast, so there's only one copy
- name: Remove ModuleBuilder from build.requires
shell: pwsh
run: | # PowerShell
@(Get-Content build.requires.psd1).Where({ $_ -notmatch "ModuleBuilder"}) | Set-Content build.requires.psd1
- name: ⚡ Install Required Modules
uses: JustinGrote/ModuleFast-action@v0.0.1
env:
MODULEFAST_DESTINATION: ${{ github.workspace }}/Modules
- name: Invoke-Pester
if: matrix.shell == 'powershell'
shell: powershell
env:
MODULEFAST_DESTINATION: ${{ github.workspace }}/Modules
run: | # PowerShell
$Env:PSModulePath = $Env:MODULEFAST_DESTINATION + [IO.Path]::PathSeparator + $Env:PSModulePath
# For the cross-platform matrix we don't need to do coverage or anything complicated
$Result = Invoke-Pester . -PassThru
@(
"## Pester Tests for ${{ matrix.os }}"
""
$Result.Duration.ToString()
"| Total | Passed | Failed |"
"|------:|-------:|-------:|"
"| $($Result.TotalCount) | $($Result.PassedCount) | $($Result.FailedCount) |"
""
"| Duration | Total | Passed | Failed | Skipped | Name |"
"|---------:|------:|-------:|-------:|--------:|:-----|"
@($Result.Containers).ForEach{
"| $($_.Duration) | $($_.TotalCount) | $($_.PassedCount) | $($_.FailedCount) | $($_.SkippedCount) | $($_.Name) |"
}
) | Out-File -FilePath $env:GITHUB_STEP_SUMMARY
- name: Invoke-Pester
if: matrix.shell == 'pwsh'
shell: pwsh
env:
MODULEFAST_DESTINATION: ${{ github.workspace }}/Modules
run: | # PowerShell
$Env:PSModulePath = $Env:MODULEFAST_DESTINATION + [IO.Path]::PathSeparator + $Env:PSModulePath
# For the cross-platform matrix we don't need to do coverage or anything complicated
$Result = Invoke-Pester . -PassThru
@(
"## Pester Tests for ${{ matrix.os }}"
""
$Result.Duration.ToString()
"| Total | Passed | Failed |"
"|------:|-------:|-------:|"
"| $($Result.TotalCount) | $($Result.PassedCount) | $($Result.FailedCount) |"
""
"| Duration | Total | Passed | Failed | Skipped | Name |"
"|---------:|------:|-------:|-------:|--------:|:-----|"
@($Result.Containers).ForEach{
"| $($_.Duration) | $($_.TotalCount) | $($_.PassedCount) | $($_.FailedCount) | $($_.SkippedCount) | $($_.Name) |"
}
) | Out-File -FilePath $env:GITHUB_STEP_SUMMARY