Skip to content

Commit 3ca6a40

Browse files
svelderrainruizGitHub Copilot
andauthored
Fix stable CompareVI.Tools outputs (#938)
Fix stable CompareVI.Tools outputs (#930 #936) Co-authored-by: GitHub Copilot <copilot@users.noreply.github.com>
1 parent 373e8e7 commit 3ca6a40

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

tests/CompareVITools.Artifact.Tests.ps1

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,39 @@ Describe 'CompareVI.Tools artifact publishing' {
143143
@($archiveMetadata.bundle.files.path) | Should -Contain 'tools/Compare-ExitCodeClassifier.ps1'
144144
}
145145

146+
It 'emits an empty prerelease GitHub output for stable CompareVI.Tools bundles' {
147+
$outDir = Join-Path $TestDrive 'artifacts-github-output'
148+
$metadataPath = Join-Path $TestDrive 'comparevi-tools-artifact-github-output.json'
149+
$githubOutputPath = Join-Path $TestDrive 'github-output.txt'
150+
151+
$originalGitHubOutput = $env:GITHUB_OUTPUT
152+
try {
153+
$env:GITHUB_OUTPUT = $githubOutputPath
154+
155+
& $publishScript `
156+
-OutputRoot $outDir `
157+
-MetadataReportPath $metadataPath `
158+
-Repository 'owner/repo' `
159+
-SourceRef 'refs/tags/v9.9.9' `
160+
-SourceSha '0123456789abcdef0123456789abcdef01234567' `
161+
-ReleaseTag 'v9.9.9' `
162+
-EmitGitHubOutputs
163+
} finally {
164+
if ($null -ne $originalGitHubOutput) {
165+
$env:GITHUB_OUTPUT = $originalGitHubOutput
166+
} else {
167+
Remove-Item Env:GITHUB_OUTPUT -ErrorAction SilentlyContinue
168+
}
169+
}
170+
171+
Test-Path -LiteralPath $githubOutputPath | Should -BeTrue
172+
$outputLines = Get-Content -LiteralPath $githubOutputPath
173+
$outputLines | Should -Contain "comparevi_tools_module_version=$moduleVersion"
174+
$outputLines | Should -Contain "comparevi_tools_release_version=$moduleReleaseVersion"
175+
$outputLines | Should -Contain 'comparevi_tools_module_prerelease='
176+
($outputLines | Where-Object { $_ -like 'comparevi_tools_module_prerelease=*' }).Count | Should -Be 1
177+
}
178+
146179
It 'exports the bundle root through COMPAREVI_SCRIPTS_ROOT when invoking the module wrapper' {
147180
$bundleRoot = Join-Path $TestDrive 'bundle'
148181
$moduleRoot = Join-Path $bundleRoot 'tools' 'CompareVI.Tools'

tools/Publish-CompareVIToolsArtifact.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function Resolve-SourceRef {
100100
function Write-GitHubOutputValue {
101101
param(
102102
[Parameter(Mandatory = $true)][string]$Key,
103-
[Parameter(Mandatory = $true)][string]$Value
103+
[Parameter(Mandatory = $true)][AllowEmptyString()][string]$Value
104104
)
105105

106106
if ([string]::IsNullOrWhiteSpace($env:GITHUB_OUTPUT)) {

0 commit comments

Comments
 (0)