Objective
Fix buildCustomJobs() in pkg/workflow/compiler_jobs.go to correctly handle runs-on values that are arrays or objects, not just strings.
Context
From discussion #19383 (HIGH-2): The current code does a string type assertion on runs-on:
if runsOnStr, ok := runsOn.(string); ok {
job.RunsOn = "runs-on: " + runsOnStr
}
// array/object: falls through silently, job.RunsOn stays ""
When runs-on is an array (e.g., [self-hosted, linux, large]), the assertion fails, job.RunsOn stays empty, and the compiled YAML is invalid — missing the required runs-on field. The top-level runs-on correctly uses extractTopLevelYAMLSection which handles all forms.
Approach
In pkg/workflow/compiler_jobs.go, in buildCustomJobs() around line 465, update the runs-on extraction:
- For the string case: keep existing behavior (
"runs-on: " + runsOnStr)
- For array and object cases: use
goccy/go-yaml to marshal the value back to a YAML snippet, then prepend "runs-on: "
- Add a validation error if
runs-on is present but cannot be marshaled
Example target output for array form:
runs-on:
- self-hosted
- linux
- large
Files to Modify
pkg/workflow/compiler_jobs.go — update runs-on handling in buildCustomJobs()
Acceptance Criteria
Generated by Plan Command for issue #discussion #19383 · ◷