fix(action): drop dead RUNNER_LABELS branch, fail fast on ambiguous guest-os
act_runner does not expose the job's runs-on label to the workflow: v1.0.4 provides only RUNNER_OS/ARCH/TEMP/TOOL_CACHE/DEBUG/VERSION, verified against the binary. The `$env:RUNNER_LABELS -match 'linux'` check was therefore always false, so guest-os: 'Auto' silently resolved to Windows and selected the Windows template for Linux jobs. It was masked only because every caller passes guest-os explicitly or overrides template-path. 'Auto' cannot pick a template on its own -- the VMX guestOS field is only readable after the clone -- so it now requires template-path and snapshot-name and errors otherwise, instead of falling back to the wrong template. Add GITEA_CI_LINUX_SNAPSHOT_NAME so a runner instance dedicated to a Linux variant can declare its own snapshot instead of every workflow repeating it; the Linux snapshot was hardcoded to BaseClean-Linux. BREAKING: a workflow using the composite with neither guest-os nor template-path now fails instead of silently using the Windows template.
This commit is contained in:
@@ -22,9 +22,18 @@
|
|||||||
# submodules: 'true'
|
# submodules: 'true'
|
||||||
# # xvfb: 'true' # Linux: run the build under a headless X server
|
# # xvfb: 'true' # Linux: run the build under a headless X server
|
||||||
#
|
#
|
||||||
# Runner label determines the guest OS template:
|
# The template comes from the `guest-os` input, NOT from the runs-on label:
|
||||||
# windows-build -> WinBuild2025 (WinRM/HTTPS transport)
|
# act_runner does not expose the job's label to the action, so this action
|
||||||
# linux-build -> LinuxBuild2404 (SSH transport)
|
# cannot see which runner picked the job.
|
||||||
|
#
|
||||||
|
# guest-os: 'Windows' -> GITEA_CI_TEMPLATE_PATH (WinRM/HTTPS)
|
||||||
|
# guest-os: 'Linux' -> GITEA_CI_LINUX_TEMPLATE_PATH (SSH)
|
||||||
|
# guest-os: 'Auto' -> requires template-path + snapshot-name; the guest
|
||||||
|
# OS is then sniffed from the cloned VMX
|
||||||
|
#
|
||||||
|
# Routing a label to a different template is therefore a *runner-side* concern:
|
||||||
|
# register a second runner instance whose envs point at that template (this is
|
||||||
|
# how rust-build:host -> LinuxRust2404 works), or pass template-path per job.
|
||||||
|
|
||||||
name: Local CI Build
|
name: Local CI Build
|
||||||
description: >
|
description: >
|
||||||
@@ -57,7 +66,10 @@ inputs:
|
|||||||
guest-os:
|
guest-os:
|
||||||
description: >
|
description: >
|
||||||
Guest OS type: Windows, Linux, or Auto.
|
Guest OS type: Windows, Linux, or Auto.
|
||||||
Auto (default) detects the OS from the VMX guestOS field after cloning.
|
Windows/Linux select the template and snapshot from the runner env vars.
|
||||||
|
Auto defers OS detection to the VMX guestOS field after cloning, which
|
||||||
|
means it cannot pick the template itself — with Auto you must also pass
|
||||||
|
template-path and snapshot-name, or the action fails fast.
|
||||||
required: false
|
required: false
|
||||||
default: 'Auto'
|
default: 'Auto'
|
||||||
|
|
||||||
@@ -300,14 +312,24 @@ runs:
|
|||||||
$repoCommit = '${{ github.sha }}'
|
$repoCommit = '${{ github.sha }}'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Resolve guest OS: honor explicit input; for Auto, infer from RUNNER_LABELS
|
# Resolve guest OS.
|
||||||
|
#
|
||||||
|
# 'Auto' is NOT resolved here: act_runner exposes no RUNNER_LABELS
|
||||||
|
# variable (v1.0.4 provides only RUNNER_OS/ARCH/TEMP/TOOL_CACHE/DEBUG/
|
||||||
|
# VERSION), so the job's runs-on label is invisible to this action.
|
||||||
|
# The previous label sniff always fell through to 'Windows', which
|
||||||
|
# silently selected the Windows template for Linux jobs.
|
||||||
|
#
|
||||||
|
# 'Auto' is instead forwarded to the Python CLI, which reads the
|
||||||
|
# guestOS field from the cloned VMX — but that happens *after* the
|
||||||
|
# clone, so the template and snapshot must already be known. Hence:
|
||||||
|
# Auto requires both template-path and snapshot-name.
|
||||||
$resolvedGuestOS = $env:INPUT_GUEST_OS
|
$resolvedGuestOS = $env:INPUT_GUEST_OS
|
||||||
if ($resolvedGuestOS -eq 'Auto') {
|
if ($resolvedGuestOS -eq 'Auto' -and (-not $env:INPUT_TEMPLATE_PATH -or -not $env:INPUT_SNAPSHOT_NAME)) {
|
||||||
if ($env:RUNNER_LABELS -match 'linux') {
|
throw ("guest-os: 'Auto' cannot select a template or snapshot on its own — " +
|
||||||
$resolvedGuestOS = 'Linux'
|
"act_runner does not expose the job's runs-on label to the action. " +
|
||||||
} else {
|
"Either set guest-os to 'Windows'/'Linux' (uses the runner env defaults), " +
|
||||||
$resolvedGuestOS = 'Windows'
|
"or pass both template-path and snapshot-name explicitly.")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Select template path: explicit input overrides OS-based runner env var
|
# Select template path: explicit input overrides OS-based runner env var
|
||||||
@@ -320,16 +342,23 @@ runs:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Select snapshot name: explicit input > OS-based default
|
# Select snapshot name: explicit input > OS-based default.
|
||||||
# GITEA_CI_SNAPSHOT_NAME applies to Windows (template-refresh override)
|
# GITEA_CI_SNAPSHOT_NAME applies to Windows (template-refresh override);
|
||||||
|
# GITEA_CI_LINUX_SNAPSHOT_NAME is the Linux equivalent, which lets a
|
||||||
|
# runner instance dedicated to a Linux variant (e.g. the rust-build
|
||||||
|
# runner pointing at LinuxRust2404) declare its own snapshot instead of
|
||||||
|
# every workflow repeating it.
|
||||||
$resolvedSnapshotName = $env:INPUT_SNAPSHOT_NAME
|
$resolvedSnapshotName = $env:INPUT_SNAPSHOT_NAME
|
||||||
if (-not $resolvedSnapshotName) {
|
if (-not $resolvedSnapshotName) {
|
||||||
if ($resolvedGuestOS -eq 'Linux') {
|
if ($resolvedGuestOS -eq 'Linux') {
|
||||||
$resolvedSnapshotName = 'BaseClean-Linux'
|
$resolvedSnapshotName = if ($env:GITEA_CI_LINUX_SNAPSHOT_NAME) { $env:GITEA_CI_LINUX_SNAPSHOT_NAME } else { 'BaseClean-Linux' }
|
||||||
} else {
|
} else {
|
||||||
$resolvedSnapshotName = if ($env:GITEA_CI_SNAPSHOT_NAME) { $env:GITEA_CI_SNAPSHOT_NAME } else { 'BaseClean' }
|
$resolvedSnapshotName = if ($env:GITEA_CI_SNAPSHOT_NAME) { $env:GITEA_CI_SNAPSHOT_NAME } else { 'BaseClean' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Write-Host "[local-ci-build] template: $resolvedTemplatePath"
|
||||||
|
Write-Host "[local-ci-build] snapshot: $resolvedSnapshotName"
|
||||||
|
Write-Host "[local-ci-build] guest-os: $resolvedGuestOS"
|
||||||
|
|
||||||
# Build argument list for the Python CLI. Long-form kebab-case flags only.
|
# Build argument list for the Python CLI. Long-form kebab-case flags only.
|
||||||
# NOTE: never put an empty string in the splatted array — PowerShell
|
# NOTE: never put an empty string in the splatted array — PowerShell
|
||||||
|
|||||||
Reference in New Issue
Block a user