Fix custom job runs-on array and object forms silently dropped#19407
Fix custom job runs-on array and object forms silently dropped#19407
runs-on array and object forms silently dropped#19407Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
runs-on array and object forms silently dropped
There was a problem hiding this comment.
Pull request overview
Fixes buildCustomJobs() so custom job runs-on is no longer silently dropped when specified in YAML array/object form, preventing invalid compiled workflows.
Changes:
- Extend custom job
runs-onextraction to support string, array, and object YAML forms (marshaling non-string forms to YAML and emitting an error on marshal failure). - Add a unit test covering string/array/object
runs-onforms for custom jobs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/workflow/compiler_jobs.go | Updates custom job runs-on handling to marshal array/object forms into an indented YAML snippet instead of dropping the field. |
| pkg/workflow/compiler_jobs_test.go | Adds TestBuildCustomJobsRunsOnForms to verify string/array/object runs-on forms are preserved in job.RunsOn. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| tests := []struct { | ||
| name string | ||
| runsOn any | ||
| expectedRunsOn string | ||
| expectedContains []string | ||
| shouldErr bool | ||
| }{ | ||
| { | ||
| name: "string form", | ||
| runsOn: "ubuntu-latest", | ||
| expectedRunsOn: "runs-on: ubuntu-latest", | ||
| }, | ||
| { | ||
| name: "array form", | ||
| runsOn: []any{"self-hosted", "linux", "large"}, | ||
| expectedContains: []string{"runs-on:", "- self-hosted", "- linux", "- large"}, | ||
| }, | ||
| { | ||
| name: "object form", | ||
| runsOn: map[string]any{"group": "my-runners"}, | ||
| expectedContains: []string{"runs-on:", "group: my-runners"}, | ||
| }, | ||
| } |
There was a problem hiding this comment.
The new runs-on handling returns an error when YAML marshaling fails, but this test suite never exercises that path (and shouldErr is unused). Add a test case with an unmarshalable runs-on value (e.g., a function or channel) and assert that buildCustomJobs returns an error mentioning the job name; or remove shouldErr if the error-path test is intentionally out of scope.
|
@copilot Apply comments |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
runs-onhandling inbuildCustomJobs()to support array and object formsruns-onformsmake fmt,make lint,make buildto validateOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.