fix(burn-in): add -SkipArtifact switch; restore production fail-on-missing-dist
PROBLEM: Invoke-RemoteBuild.ps1 was creating a placeholder artifact when the build
produced no dist/ directory. In production this hides build defects (build exits 0
but produces nothing = silent failure treated as success).
SOLUTION: Add explicit -SkipArtifact switch to the call chain:
Invoke-RemoteBuild.ps1:
- Add -SkipArtifact switch. When set: skips packaging entirely (no zip created).
- When absent (production default): missing GuestArtifactSource is a hard error
with a clear message pointing to -SkipArtifact as the opt-in for no-output builds.
Invoke-CIJob.ps1:
- Add -SkipArtifact switch. Passes it to Invoke-RemoteBuild.ps1.
- Phase 6 (Get-BuildArtifacts) is entirely skipped when set; logs 'skipped' event.
Test-CapacityBurnIn.ps1:
- Add -SkipArtifact switch. Adds '-SkipArtifact' flag to each child job argList.
Start-BurnInTest.ps1:
- Always passes -SkipArtifact by default (burn-in uses delay commands, no output).
- Add -NoSkipArtifact override switch for runs that do produce real artifacts.
- Remove -NoSkipArtifact escape from wrapper: default burn-in never needs artifacts.
This commit is contained in:
@@ -105,6 +105,11 @@ param(
|
|||||||
# Requires Set-TemplateSharedFolders.ps1 to have been run on the template.
|
# Requires Set-TemplateSharedFolders.ps1 to have been run on the template.
|
||||||
[switch] $UseSharedCache,
|
[switch] $UseSharedCache,
|
||||||
|
|
||||||
|
# Skip artifact packaging and collection (Phase 5 packaging + Phase 6).
|
||||||
|
# Use for burn-in / smoke builds that intentionally produce no output.
|
||||||
|
# In production (absent) the build must produce artifacts or the job fails.
|
||||||
|
[switch] $SkipArtifact,
|
||||||
|
|
||||||
# Credential Manager target for Gitea PAT used by -UseGitClone (private repos).
|
# Credential Manager target for Gitea PAT used by -UseGitClone (private repos).
|
||||||
# Store with: New-StoredCredential -Target 'GiteaPAT' -UserName '<user>' -Password '<pat>' -Persist LocalMachine
|
# Store with: New-StoredCredential -Target 'GiteaPAT' -UserName '<user>' -Password '<pat>' -Persist LocalMachine
|
||||||
# Ignored when -UseGitClone is not set.
|
# Ignored when -UseGitClone is not set.
|
||||||
@@ -494,12 +499,17 @@ try {
|
|||||||
if ($GuestArtifactSource -ne '') { $remoteBuildParams['GuestArtifactSource'] = $GuestArtifactSource }
|
if ($GuestArtifactSource -ne '') { $remoteBuildParams['GuestArtifactSource'] = $GuestArtifactSource }
|
||||||
if ($ExtraGuestEnv.Count -gt 0) { $remoteBuildParams['ExtraGuestEnv'] = $ExtraGuestEnv }
|
if ($ExtraGuestEnv.Count -gt 0) { $remoteBuildParams['ExtraGuestEnv'] = $ExtraGuestEnv }
|
||||||
if ($UseSharedCache) { $remoteBuildParams['UseSharedCache'] = $true }
|
if ($UseSharedCache) { $remoteBuildParams['UseSharedCache'] = $true }
|
||||||
|
if ($SkipArtifact) { $remoteBuildParams['SkipArtifact'] = $true }
|
||||||
& "$scriptDir\Invoke-RemoteBuild.ps1" @remoteBuildParams
|
& "$scriptDir\Invoke-RemoteBuild.ps1" @remoteBuildParams
|
||||||
Write-JobEvent -Phase 'phase5.build' -Status 'success'
|
Write-JobEvent -Phase 'phase5.build' -Status 'success'
|
||||||
$phaseTimings.Add([PSCustomObject]@{ Phase = 'Phase 5 - Remote build'; Sec = [int]((Get-Date) - $phaseStart).TotalSeconds })
|
$phaseTimings.Add([PSCustomObject]@{ Phase = 'Phase 5 - Remote build'; Sec = [int]((Get-Date) - $phaseStart).TotalSeconds })
|
||||||
$phaseStart = Get-Date
|
$phaseStart = Get-Date
|
||||||
|
|
||||||
# ── Phase 6: Collect artifacts ────────────────────────────────────────
|
# ── Phase 6: Collect artifacts ────────────────────────────────────────
|
||||||
|
if ($SkipArtifact) {
|
||||||
|
Write-Host "`n[Phase 6/6] Artifact collection skipped (-SkipArtifact)."
|
||||||
|
Write-JobEvent -Phase 'phase6.artifacts' -Status 'skipped'
|
||||||
|
} else {
|
||||||
Write-Host "`n[Phase 6/6] Collecting artifacts..."
|
Write-Host "`n[Phase 6/6] Collecting artifacts..."
|
||||||
Write-JobEvent -Phase 'phase6.artifacts' -Status 'start'
|
Write-JobEvent -Phase 'phase6.artifacts' -Status 'start'
|
||||||
if ($GuestOS -eq 'Linux') {
|
if ($GuestOS -eq 'Linux') {
|
||||||
@@ -520,9 +530,9 @@ try {
|
|||||||
-HostArtifactDir $jobArtifactDir `
|
-HostArtifactDir $jobArtifactDir `
|
||||||
-IncludeLogs
|
-IncludeLogs
|
||||||
}
|
}
|
||||||
|
|
||||||
$elapsed = (Get-Date) - $startTime
|
|
||||||
Write-JobEvent -Phase 'phase6.artifacts' -Status 'success' -Data @{ dir = $jobArtifactDir }
|
Write-JobEvent -Phase 'phase6.artifacts' -Status 'success' -Data @{ dir = $jobArtifactDir }
|
||||||
|
}
|
||||||
|
$elapsed = (Get-Date) - $startTime
|
||||||
Write-JobEvent -Phase 'job' -Status 'success' -Data @{ elapsedSec = [int]$elapsed.TotalSeconds }
|
Write-JobEvent -Phase 'job' -Status 'success' -Data @{ elapsedSec = [int]$elapsed.TotalSeconds }
|
||||||
$phaseTimings.Add([PSCustomObject]@{ Phase = 'Phase 6 - Artifacts'; Sec = [int]((Get-Date) - $phaseStart).TotalSeconds })
|
$phaseTimings.Add([PSCustomObject]@{ Phase = 'Phase 6 - Artifacts'; Sec = [int]((Get-Date) - $phaseStart).TotalSeconds })
|
||||||
Write-Host "`n============================================================"
|
Write-Host "`n============================================================"
|
||||||
|
|||||||
@@ -126,6 +126,12 @@ param(
|
|||||||
# and VMware Tools HGFS driver present in the guest.
|
# and VMware Tools HGFS driver present in the guest.
|
||||||
[switch] $UseSharedCache,
|
[switch] $UseSharedCache,
|
||||||
|
|
||||||
|
# When set, skip artifact packaging and do NOT write artifacts.zip in the guest.
|
||||||
|
# Use for burn-in / smoke builds that intentionally produce no output.
|
||||||
|
# In production (default: absent) the build MUST produce GuestArtifactSource or the
|
||||||
|
# job fails — a silently-empty build is treated as an error.
|
||||||
|
[switch] $SkipArtifact,
|
||||||
|
|
||||||
# Guest OS type — Linux uses SSH instead of WinRM.
|
# Guest OS type — Linux uses SSH instead of WinRM.
|
||||||
[ValidateSet('Windows', 'Linux')]
|
[ValidateSet('Windows', 'Linux')]
|
||||||
[string] $GuestOS = 'Windows',
|
[string] $GuestOS = 'Windows',
|
||||||
@@ -427,7 +433,7 @@ try {
|
|||||||
# ── Custom build command (e.g. python, msbuild, cmake…) ──────────
|
# ── Custom build command (e.g. python, msbuild, cmake…) ──────────
|
||||||
Write-Host "[Invoke-RemoteBuild] Running build command: $BuildCommand"
|
Write-Host "[Invoke-RemoteBuild] Running build command: $BuildCommand"
|
||||||
$buildExit = Invoke-Command -Session $session -ScriptBlock {
|
$buildExit = Invoke-Command -Session $session -ScriptBlock {
|
||||||
param($workDir, $cmd, $artifactZip, $artifactSrc, $useCache, $extraEnv)
|
param($workDir, $cmd, $artifactZip, $artifactSrc, $useCache, $extraEnv, $skipArt)
|
||||||
# Unbuffered Python output — lines appear in real-time instead of being held in buffer
|
# Unbuffered Python output — lines appear in real-time instead of being held in buffer
|
||||||
$env:PYTHONUNBUFFERED = '1'
|
$env:PYTHONUNBUFFERED = '1'
|
||||||
if ($useCache) {
|
if ($useCache) {
|
||||||
@@ -442,21 +448,14 @@ try {
|
|||||||
& cmd /c "$cmd 2>&1" | ForEach-Object { Write-Host $_ }
|
& cmd /c "$cmd 2>&1" | ForEach-Object { Write-Host $_ }
|
||||||
$exit = $LASTEXITCODE
|
$exit = $LASTEXITCODE
|
||||||
|
|
||||||
if ($exit -eq 0) {
|
if ($exit -eq 0 -and -not $skipArt) {
|
||||||
$archiveDir = Split-Path $artifactZip -Parent
|
$archiveDir = Split-Path $artifactZip -Parent
|
||||||
if (-not (Test-Path $archiveDir)) {
|
if (-not (Test-Path $archiveDir)) {
|
||||||
New-Item -ItemType Directory -Path $archiveDir -Force | Out-Null
|
New-Item -ItemType Directory -Path $archiveDir -Force | Out-Null
|
||||||
}
|
}
|
||||||
$srcPath = Join-Path $workDir $artifactSrc
|
$srcPath = Join-Path $workDir $artifactSrc
|
||||||
if (-not (Test-Path $srcPath)) {
|
if (-not (Test-Path $srcPath)) {
|
||||||
# No artifact source — create a placeholder zip so that
|
throw "Artifact source directory not found: $srcPath. Build succeeded (exit 0) but produced no output. Check GuestArtifactSource or use -SkipArtifact for builds that intentionally produce no files."
|
||||||
# Get-BuildArtifacts succeeds and the full pipeline is exercised.
|
|
||||||
# This is expected for burn-in / smoke builds that produce no output.
|
|
||||||
Write-Host "[Build] Artifact source '$srcPath' not found — creating placeholder artifact."
|
|
||||||
$placeholder = Join-Path $archiveDir 'build-ok.txt'
|
|
||||||
'No artifact source directory. Build command completed successfully.' |
|
|
||||||
Out-File -FilePath $placeholder -Encoding UTF8
|
|
||||||
Compress-Archive -Path $placeholder -DestinationPath $artifactZip -Force
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$7zip = 'C:\Program Files\7-Zip\7z.exe'
|
$7zip = 'C:\Program Files\7-Zip\7z.exe'
|
||||||
@@ -472,7 +471,7 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $exit
|
return $exit
|
||||||
} -ArgumentList $GuestWorkDir, $BuildCommand, $GuestArtifactZip, $GuestArtifactSource, $UseSharedCache.IsPresent, $ExtraGuestEnv
|
} -ArgumentList $GuestWorkDir, $BuildCommand, $GuestArtifactZip, $GuestArtifactSource, $UseSharedCache.IsPresent, $ExtraGuestEnv, $SkipArtifact.IsPresent
|
||||||
|
|
||||||
if ($buildExit -ne 0) {
|
if ($buildExit -ne 0) {
|
||||||
throw "Build command failed (exit $buildExit)"
|
throw "Build command failed (exit $buildExit)"
|
||||||
@@ -535,8 +534,12 @@ try {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($SkipArtifact) {
|
||||||
|
Write-Host '[Invoke-RemoteBuild] Build succeeded. Artifact packaging skipped (-SkipArtifact).'
|
||||||
|
} else {
|
||||||
Write-Host "[Invoke-RemoteBuild] Build succeeded. Artifact at $GuestArtifactZip"
|
Write-Host "[Invoke-RemoteBuild] Build succeeded. Artifact at $GuestArtifactZip"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
finally {
|
finally {
|
||||||
Remove-PSSession $session -ErrorAction SilentlyContinue
|
Remove-PSSession $session -ErrorAction SilentlyContinue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ param(
|
|||||||
[int] $Rounds = 3,
|
[int] $Rounds = 3,
|
||||||
[int] $Parallelism = 4,
|
[int] $Parallelism = 4,
|
||||||
[string] $BuildCommand = 'ping 127.0.0.1 -n 31 > nul',
|
[string] $BuildCommand = 'ping 127.0.0.1 -n 31 > nul',
|
||||||
|
[switch] $NoSkipArtifact,
|
||||||
[int] $RoundTimeoutMinutes = 60
|
[int] $RoundTimeoutMinutes = 60
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -71,6 +72,7 @@ $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|||||||
-BuildCommand $BuildCommand `
|
-BuildCommand $BuildCommand `
|
||||||
-Parallelism $Parallelism `
|
-Parallelism $Parallelism `
|
||||||
-Rounds $Rounds `
|
-Rounds $Rounds `
|
||||||
-RoundTimeoutMinutes $RoundTimeoutMinutes
|
-RoundTimeoutMinutes $RoundTimeoutMinutes `
|
||||||
|
$(if (-not $NoSkipArtifact) { '-SkipArtifact' })
|
||||||
|
|
||||||
exit $LASTEXITCODE
|
exit $LASTEXITCODE
|
||||||
|
|||||||
@@ -124,6 +124,10 @@ param(
|
|||||||
|
|
||||||
[string] $BuildCommand = '',
|
[string] $BuildCommand = '',
|
||||||
|
|
||||||
|
# Skip artifact packaging and collection in every child job.
|
||||||
|
# Set this for burn-in and smoke runs that use delay-only build commands.
|
||||||
|
[switch] $SkipArtifact,
|
||||||
|
|
||||||
[ValidateRange(1, 10)]
|
[ValidateRange(1, 10)]
|
||||||
[int] $Parallelism = 4,
|
[int] $Parallelism = 4,
|
||||||
|
|
||||||
@@ -211,6 +215,9 @@ for ($r = 1; $r -le $Rounds; $r++) {
|
|||||||
if ($BuildCommand -ne '') {
|
if ($BuildCommand -ne '') {
|
||||||
$argList.Add('-BuildCommand'); $argList.Add($BuildCommand)
|
$argList.Add('-BuildCommand'); $argList.Add($BuildCommand)
|
||||||
}
|
}
|
||||||
|
if ($SkipArtifact) {
|
||||||
|
$argList.Add('-SkipArtifact')
|
||||||
|
}
|
||||||
|
|
||||||
$argArray = $argList.ToArray()
|
$argArray = $argList.ToArray()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user