feat: expose skip-artifact as workflow input in action.yml
action.yml: - Add skip-artifact input (default: 'false'). - Forward as INPUT_SKIP_ARTIFACT env var to the PS run step. - Pass SkipArtifact=true to Invoke-CIJob.ps1 when set. - Gate 'Upload artifacts' step on inputs.skip-artifact != 'true'. Invoke-CIJob.ps1: - Restore -SkipArtifact switch; skips Phase 6 and logs 'skipped' event. Invoke-RemoteBuild.ps1: - Restore -SkipArtifact switch; skips packaging inside the guest. - Error message updated to mention skip-artifact workflow input.
This commit is contained in:
@@ -139,6 +139,15 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
|
|
||||||
|
skip-artifact:
|
||||||
|
description: >
|
||||||
|
Set to "true" to skip artifact packaging and collection entirely.
|
||||||
|
Use for jobs that intentionally produce no output (lint, static analysis,
|
||||||
|
test-only). When absent (default), the build MUST produce artifact-source
|
||||||
|
or the job fails.
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
artifact-path:
|
artifact-path:
|
||||||
description: >
|
description: >
|
||||||
@@ -174,6 +183,7 @@ runs:
|
|||||||
INPUT_REPO_URL: ${{ inputs.repo-url }}
|
INPUT_REPO_URL: ${{ inputs.repo-url }}
|
||||||
INPUT_EXTRA_GUEST_ENV_JSON: ${{ inputs.extra-guest-env-json }}
|
INPUT_EXTRA_GUEST_ENV_JSON: ${{ inputs.extra-guest-env-json }}
|
||||||
INPUT_USE_SHARED_CACHE: ${{ inputs.use-shared-cache }}
|
INPUT_USE_SHARED_CACHE: ${{ inputs.use-shared-cache }}
|
||||||
|
INPUT_SKIP_ARTIFACT: ${{ inputs.skip-artifact }}
|
||||||
run: |
|
run: |
|
||||||
#Requires -Version 5.1
|
#Requires -Version 5.1
|
||||||
Set-StrictMode -Version Latest
|
Set-StrictMode -Version Latest
|
||||||
@@ -257,6 +267,7 @@ runs:
|
|||||||
if ($env:INPUT_SUBMODULES -eq 'true') { $params['Submodules'] = $true }
|
if ($env:INPUT_SUBMODULES -eq 'true') { $params['Submodules'] = $true }
|
||||||
if ($env:INPUT_USE_GIT_CLONE -eq 'true') { $params['UseGitClone'] = $true }
|
if ($env:INPUT_USE_GIT_CLONE -eq 'true') { $params['UseGitClone'] = $true }
|
||||||
if ($env:INPUT_USE_SHARED_CACHE -eq 'true') { $params['UseSharedCache'] = $true }
|
if ($env:INPUT_USE_SHARED_CACHE -eq 'true') { $params['UseSharedCache'] = $true }
|
||||||
|
if ($env:INPUT_SKIP_ARTIFACT -eq 'true') { $params['SkipArtifact'] = $true }
|
||||||
if ($resolvedTemplatePath) { $params['TemplatePath'] = $resolvedTemplatePath }
|
if ($resolvedTemplatePath) { $params['TemplatePath'] = $resolvedTemplatePath }
|
||||||
if ($resolvedSnapshotName) { $params['SnapshotName'] = $resolvedSnapshotName }
|
if ($resolvedSnapshotName) { $params['SnapshotName'] = $resolvedSnapshotName }
|
||||||
if ($extraGuestEnv.Count -gt 0) { $params['ExtraGuestEnv'] = $extraGuestEnv }
|
if ($extraGuestEnv.Count -gt 0) { $params['ExtraGuestEnv'] = $extraGuestEnv }
|
||||||
@@ -270,7 +281,7 @@ runs:
|
|||||||
|
|
||||||
# ── Upload build artifacts on success ─────────────────────────────────────
|
# ── Upload build artifacts on success ─────────────────────────────────────
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
if: success()
|
if: success() && inputs.skip-artifact != 'true'
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ steps.invoke-ci.outputs.artifact-name }}
|
name: ${{ steps.invoke-ci.outputs.artifact-name }}
|
||||||
|
|||||||
@@ -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 (Invoke-RemoteBuild) and collection (Phase 6).
|
||||||
|
# Use for jobs that intentionally produce no output (lint, test-only, etc.).
|
||||||
|
# When absent, the build must produce GuestArtifactSource 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') {
|
||||||
@@ -521,6 +531,7 @@ try {
|
|||||||
-IncludeLogs
|
-IncludeLogs
|
||||||
}
|
}
|
||||||
Write-JobEvent -Phase 'phase6.artifacts' -Status 'success' -Data @{ dir = $jobArtifactDir }
|
Write-JobEvent -Phase 'phase6.artifacts' -Status 'success' -Data @{ dir = $jobArtifactDir }
|
||||||
|
}
|
||||||
$elapsed = (Get-Date) - $startTime
|
$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 })
|
||||||
|
|||||||
@@ -126,6 +126,10 @@ param(
|
|||||||
# and VMware Tools HGFS driver present in the guest.
|
# and VMware Tools HGFS driver present in the guest.
|
||||||
[switch] $UseSharedCache,
|
[switch] $UseSharedCache,
|
||||||
|
|
||||||
|
# Skip artifact packaging entirely. Use for jobs that produce no output.
|
||||||
|
# When absent, missing GuestArtifactSource after a successful build is 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 +431,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,14 +446,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)) {
|
||||||
throw "Artifact source directory not found: $srcPath. Build succeeded (exit 0) but produced no output. Check GuestArtifactSource."
|
throw "Artifact source directory not found: $srcPath. Build succeeded (exit 0) but produced no output. Check GuestArtifactSource or set skip-artifact: 'true' in the workflow."
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$7zip = 'C:\Program Files\7-Zip\7z.exe'
|
$7zip = 'C:\Program Files\7-Zip\7z.exe'
|
||||||
@@ -465,7 +469,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)"
|
||||||
@@ -528,8 +532,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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user