Skip to content

Commit 042f31e

Browse files
fix: address copilot review - path normalization, fixture manifests, cleanup exit
1 parent 932e828 commit 042f31e

4 files changed

Lines changed: 29 additions & 57 deletions

File tree

.github/workflows/Action-Test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- name: Validate module version is stamped
4646
shell: pwsh
4747
run: |
48-
$manifestPath = 'tests/outputs/module/PSModuleTest/PSModuleTest.psd1'
48+
$manifestPath = Join-Path $env:GITHUB_WORKSPACE 'outputs' 'module' 'PSModuleTest' 'PSModuleTest.psd1'
4949
$manifest = Import-PowerShellDataFile -Path $manifestPath
5050
$version = $manifest.ModuleVersion
5151
$releaseTag = $env:PSMODULE_PUBLISH_PSMODULE_CONTEXT_ReleaseTag
@@ -100,7 +100,7 @@ jobs:
100100
- name: Validate prerelease version
101101
shell: pwsh
102102
run: |
103-
$manifestPath = 'tests/outputs/module-prerelease/PSModuleTest/PSModuleTest.psd1'
103+
$manifestPath = Join-Path $env:GITHUB_WORKSPACE 'outputs' 'module-prerelease' 'PSModuleTest' 'PSModuleTest.psd1'
104104
$manifest = Import-PowerShellDataFile -Path $manifestPath
105105
$version = $manifest.ModuleVersion
106106
$prerelease = $manifest.PrivateData.PSData.Prerelease
@@ -163,7 +163,7 @@ jobs:
163163
env:
164164
PUBLISH_OUTCOME: ${{ steps.publish.outcome }}
165165
run: |
166-
$manifestPath = 'tests/outputs/module-unstamped/PSModuleTest/PSModuleTest.psd1'
166+
$manifestPath = Join-Path $env:GITHUB_WORKSPACE 'outputs' 'module-unstamped' 'PSModuleTest' 'PSModuleTest.psd1'
167167
$manifest = Import-PowerShellDataFile -Path $manifestPath
168168
$version = $manifest.ModuleVersion
169169
$releaseTag = $env:PSMODULE_PUBLISH_PSMODULE_CONTEXT_ReleaseTag
@@ -172,8 +172,8 @@ jobs:
172172
Write-Host "Release tag from action: [$releaseTag]"
173173
Write-Host "Publish step outcome: [$env:PUBLISH_OUTCOME]"
174174
175-
if (-not [string]::IsNullOrEmpty($version) -and $version -ne '999.0.0') {
176-
Write-Error "Expected missing or placeholder version but got [$version]."
175+
if ($version -ne '999.0.0') {
176+
Write-Error "Expected placeholder version [999.0.0] but got [$version]."
177177
exit 1
178178
}
179179
if ($env:PUBLISH_OUTCOME -eq 'success') {

src/cleanup.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ LogGroup 'Load inputs' {
2020

2121
if ([string]::IsNullOrWhiteSpace($prereleaseName)) {
2222
Write-Host "No prerelease tag derivable from PR head ref [$prHeadRef]. Nothing to cleanup."
23-
return
23+
exit 0
2424
}
2525

2626
Write-Host "PR head ref: [$prHeadRef]"

src/publish.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@ LogGroup 'Load inputs' {
3838
} else {
3939
$env:PSMODULE_PUBLISH_PSMODULE_INPUT_Name
4040
}
41-
$modulePathCandidate = "$env:PSMODULE_PUBLISH_PSMODULE_INPUT_ModulePath/$name"
41+
# Normalize to an absolute path anchored at the workspace root so that
42+
# the resolved location agrees with where actions/download-artifact writes
43+
# the artifact (workspace-root-relative), regardless of WorkingDirectory.
44+
$modulePathInput = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_ModulePath
45+
$modulePathCandidate = if ([System.IO.Path]::IsPathRooted($modulePathInput)) {
46+
Join-Path $modulePathInput $name
47+
} else {
48+
Join-Path $env:GITHUB_WORKSPACE $modulePathInput $name
49+
}
4250
if (-not (Test-Path -Path $modulePathCandidate)) {
4351
Write-Error ("Module directory not found at [$modulePathCandidate]. " +
4452
'Ensure the artifact contains a <ModulePath>/<Name>/ subdirectory layout.')

tests/outputs/module-unstamped/PSModuleTest/PSModuleTest.psd1

Lines changed: 14 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,26 @@
11
@{
2-
RootModule = 'PSModuleTest.psm1'
3-
CompatiblePSEditions = @(
2+
RootModule = 'PSModuleTest.psm1'
3+
ModuleVersion = '999.0.0'
4+
CompatiblePSEditions = @(
45
'Core'
56
'Desktop'
67
)
7-
GUID = '20b37221-db1c-43db-9cca-f22b33123548'
8-
Author = 'PSModule'
9-
CompanyName = 'PSModule'
10-
Copyright = '(c) 2024 PSModule. All rights reserved.'
11-
Description = 'Process a module from source code to published module.'
12-
PowerShellVersion = '5.1'
13-
ProcessorArchitecture = 'None'
14-
RequiredModules = @(
15-
@{
16-
ModuleVersion = '1.0'
17-
ModuleName = 'PSSemVer'
18-
}
19-
'Utilities'
20-
)
21-
RequiredAssemblies = 'assemblies/LsonLib.dll'
22-
ScriptsToProcess = 'scripts/loader.ps1'
23-
TypesToProcess = @(
24-
'types/DirectoryInfo.Types.ps1xml'
25-
'types/FileInfo.Types.ps1xml'
26-
)
27-
FormatsToProcess = @(
28-
'formats/CultureInfo.Format.ps1xml'
29-
'formats/Mygciview.Format.ps1xml'
30-
)
31-
NestedModules = @(
32-
'modules/OtherPSModule.psm1'
33-
)
34-
FunctionsToExport = @(
8+
GUID = '20b37221-db1c-43db-9cca-f22b33123548'
9+
Author = 'PSModule'
10+
CompanyName = 'PSModule'
11+
Copyright = '(c) 2024 PSModule. All rights reserved.'
12+
Description = 'Process a module from source code to published module.'
13+
PowerShellVersion = '5.1'
14+
FunctionsToExport = @(
3515
'Get-PSModuleTest'
3616
'New-PSModuleTest'
3717
'Set-PSModuleTest'
3818
'Test-PSModuleTest'
3919
)
40-
CmdletsToExport = @()
41-
VariablesToExport = @()
42-
AliasesToExport = '*'
43-
ModuleList = @(
44-
'modules/OtherPSModule.psm1'
45-
)
46-
FileList = @(
47-
'PSModuleTest.psd1'
48-
'PSModuleTest.psm1'
49-
'assemblies/LsonLib.dll'
50-
'data/Config.psd1'
51-
'data/Settings.psd1'
52-
'formats/CultureInfo.Format.ps1xml'
53-
'formats/Mygciview.Format.ps1xml'
54-
'modules/OtherPSModule.psm1'
55-
'scripts/loader.ps1'
56-
'types/DirectoryInfo.Types.ps1xml'
57-
'types/FileInfo.Types.ps1xml'
58-
)
59-
PrivateData = @{
20+
CmdletsToExport = @()
21+
VariablesToExport = @()
22+
AliasesToExport = @()
23+
PrivateData = @{
6024
PSData = @{
6125
Tags = @(
6226
'workflow'

0 commit comments

Comments
 (0)