Skip to content

Fix the test matrix #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 43 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ jobs:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }}

- uses: actions/upload-artifact@v4
- name: Upload Built Modules
uses: actions/upload-artifact@v4
with:
name: ModuleBuilder
path: Modules/ModuleBuilder
name: Modules
path: |
Modules/*
!Modules/*-TestResults

- uses: actions/upload-artifact@v4
with:
Expand All @@ -62,47 +65,62 @@ jobs:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- name: Download Build Output
- name: Download build.requires.psd1
uses: actions/download-artifact@v4
with:
name: ModuleBuilder
path: Modules/ModuleBuilder # /home/runner/work/ModuleBuilder/ModuleBuilder/Modules/ModuleBuilder
name: build.requires.psd1
- name: Download Pester Tests
uses: actions/download-artifact@v4
with:
name: PesterTests
path: PesterTests
- name: Download build.requires.psd1
- name: Download Build Output
uses: actions/download-artifact@v4
with:
name: build.requires.psd1
- name: ⚡ Install PowerShell Modules
uses: JustinGrote/[email protected]
- name: Put Build output in PATH
shell: pwsh
run: | # PowerShell
Convert-Path Modules -OutVariable BuiltModules
Add-Content -Path $env:GITHUB_PATH -Value $BuiltModules -Encoding utf8
# Uninstall the "installed" copy of ModuleBuilder
Get-Module -Name ModuleBuilder -List | Where ModuleBase -notmatch ([regex]::escape($pwd)) | Split-Path | Remove-Item -Recurse -Force
- name: Put Build output in PATH
name: Modules
path: Modules # /home/runner/work/ModuleBuilder/ModuleBuilder/Modules
- name: Install Output Modules
shell: pwsh
run: | # PowerShell
$Env:PATH -split ([IO.Path]::PathSeparator) | Out-Host
# https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-powershell#powershell-module-locations
$ModuleDestination = if ($IsWindows) {
Join-Path ([Environment]::GetFolderPath('MyDocuments')) 'PowerShell/Modules'
} else {
Join-Path $HOME '.local/share/powershell/Modules'
}

Get-ChildItem -Directory Modules -OutVariable Modules
| Move-Item -Destination { Join-Path $ModuleDestination $_.Name } -Force

Write-Host "Installing $($Modules -join ', ') to $ModuleDestination"
Get-ChildItem -Directory $ModuleDestination
Write-Host "PSModulePath:"
$Env:PSModulePath -split ([IO.Path]::PathSeparator) | Out-Host

@(Get-Content build.requires.psd1)
| Where { $_ -notmatch "ModuleBuilder"}
| Set-Content build.requires.psd1
- name: ⚡ Install Required Modules
uses: JustinGrote/[email protected]
- name: Invoke Pester Tests
id: pester
uses: zyborg/pester-tests-report@v1
with:
# include_paths: tests
# exclude_paths: tests/powershell1,tests/powershell2
# exclude_tags: skip_ci
report_name: module_tests
report_name: ${{ matrix.os }}_validation
report_title: My Module Tests
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: dump test results
tests_fail_step: true
skip_check_run: true # Our test results are too large
- name: Summarize test results
shell: pwsh
run: | # PowerShell
Write-Host 'Total Tests Executed...: ${{ steps.pester.outputs.total_count }}'
Write-Host 'Total Tests PASSED.....: ${{ steps.pester.outputs.passed_count }}'
Write-Host 'Total Tests FAILED.....: ${{ steps.pester.outputs.failed_count }}'

Write-ActionInfo 'Total Tests Executed...: ${{ steps.pester.outputs.total_count }}'
Write-ActionInfo 'Total Tests Passed.....: ${{ steps.pester.outputs.passed_count }}'
if (${{ steps.pester.outputs.failed_count }} -gt 0) {
Set-ActionFailed 'Total Tests Failed.....: ${{ steps.pester.outputs.failed_count }}'
} else {
Write-ActionInfo 'Total Tests Failed.....: ${{ steps.pester.outputs.failed_count }}'
}
15 changes: 0 additions & 15 deletions Install-RequiredModule.ps1

This file was deleted.

4 changes: 3 additions & 1 deletion build.requires.psd1
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# https://github.com/marketplace/actions/modulefast
# Run Install-ModuleFast to install the latest version of the required modules
# https://github.com/JustinGrote/ModuleFast
@{
Configuration = ":[1.5.0, 2.0)"
Metadata = ":[1.5.1, 2.0)"
Pester = ":[5.0, 6.0)"
ModuleBuilder = ":[3.0.0, 4.0)"
PSScriptAnalyzer = ":[1.21.0, 2.0)"
InvokeBuild = ":[5.10.4, 6.0)"
GitHubActions = ":[1.1.0, 2.0)"
}