@@ -32,10 +32,13 @@ jobs:
32
32
NUGET_API_KEY : ${{ secrets.NUGET_API_KEY }}
33
33
PSGALLERY_API_KEY : ${{ secrets.PSGALLERY_API_KEY }}
34
34
35
- - uses : actions/upload-artifact@v4
35
+ - name : Upload Built Modules
36
+ uses : actions/upload-artifact@v4
36
37
with :
37
- name : ModuleBuilder
38
- path : Modules/ModuleBuilder
38
+ name : Modules
39
+ path : |
40
+ Modules/*
41
+ !Modules/*-TestResults
39
42
40
43
- uses : actions/upload-artifact@v4
41
44
with :
@@ -62,47 +65,62 @@ jobs:
62
65
matrix :
63
66
os : [windows-latest, ubuntu-latest, macos-latest]
64
67
steps :
65
- - name : Download Build Output
68
+ - name : Download build.requires.psd1
66
69
uses : actions/download-artifact@v4
67
70
with :
68
- name : ModuleBuilder
69
- path : Modules/ModuleBuilder # /home/runner/work/ModuleBuilder/ModuleBuilder/Modules/ModuleBuilder
71
+ name : build.requires.psd1
70
72
- name : Download Pester Tests
71
73
uses : actions/download-artifact@v4
72
74
with :
73
75
name : PesterTests
74
76
path : PesterTests
75
- - name : Download build.requires.psd1
77
+ - name : Download Build Output
76
78
uses : actions/download-artifact@v4
77
79
with :
78
- name : build.requires.psd1
79
- - name : ⚡ Install PowerShell Modules
80
- uses :
JustinGrote/[email protected]
81
- - name : Put Build output in PATH
82
- shell : pwsh
83
- run : | # PowerShell
84
- Convert-Path Modules -OutVariable BuiltModules
85
- Add-Content -Path $env:GITHUB_PATH -Value $BuiltModules -Encoding utf8
86
- # Uninstall the "installed" copy of ModuleBuilder
87
- Get-Module -Name ModuleBuilder -List | Where ModuleBase -notmatch ([regex]::escape($pwd)) | Split-Path | Remove-Item -Recurse -Force
88
- - name : Put Build output in PATH
80
+ name : Modules
81
+ path : Modules # /home/runner/work/ModuleBuilder/ModuleBuilder/Modules
82
+ - name : Install Output Modules
89
83
shell : pwsh
90
84
run : | # PowerShell
91
- $Env:PATH -split ([IO.Path]::PathSeparator) | Out-Host
85
+ # https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-powershell#powershell-module-locations
86
+ $ModuleDestination = if ($IsWindows) {
87
+ Join-Path ([Environment]::GetFolderPath('MyDocuments')) 'PowerShell/Modules'
88
+ } else {
89
+ Join-Path $HOME '.local/share/powershell/Modules'
90
+ }
91
+
92
+ Get-ChildItem -Directory Modules -OutVariable Modules
93
+ | Move-Item -Destination { Join-Path $ModuleDestination $_.Name } -Force
94
+
95
+ Write-Host "Installing $($Modules -join ', ') to $ModuleDestination"
96
+ Get-ChildItem -Directory $ModuleDestination
97
+ Write-Host "PSModulePath:"
98
+ $Env:PSModulePath -split ([IO.Path]::PathSeparator) | Out-Host
99
+
100
+ @(Get-Content build.requires.psd1)
101
+ | Where { $_ -notmatch "ModuleBuilder"}
102
+ | Set-Content build.requires.psd1
103
+ - name : ⚡ Install Required Modules
104
+ uses :
JustinGrote/[email protected]
92
105
- name : Invoke Pester Tests
93
106
id : pester
94
107
uses : zyborg/pester-tests-report@v1
95
108
with :
96
109
# include_paths: tests
97
110
# exclude_paths: tests/powershell1,tests/powershell2
98
111
# exclude_tags: skip_ci
99
- report_name : module_tests
112
+ report_name : ${{ matrix.os }}_validation
100
113
report_title : My Module Tests
101
114
github_token : ${{ secrets.GITHUB_TOKEN }}
102
- - name : dump test results
115
+ tests_fail_step : true
116
+ skip_check_run : true # Our test results are too large
117
+ - name : Summarize test results
103
118
shell : pwsh
104
119
run : | # PowerShell
105
- Write-Host 'Total Tests Executed...: ${{ steps.pester.outputs.total_count }}'
106
- Write-Host 'Total Tests PASSED.....: ${{ steps.pester.outputs.passed_count }}'
107
- Write-Host 'Total Tests FAILED.....: ${{ steps.pester.outputs.failed_count }}'
108
-
120
+ Write-ActionInfo 'Total Tests Executed...: ${{ steps.pester.outputs.total_count }}'
121
+ Write-ActionInfo 'Total Tests Passed.....: ${{ steps.pester.outputs.passed_count }}'
122
+ if (${{ steps.pester.outputs.failed_count }} -gt 0) {
123
+ Set-ActionFailed 'Total Tests Failed.....: ${{ steps.pester.outputs.failed_count }}'
124
+ } else {
125
+ Write-ActionInfo 'Total Tests Failed.....: ${{ steps.pester.outputs.failed_count }}'
126
+ }
0 commit comments