Skip to content

Allow runs-on-slim to use runner label arrays#38965

Merged
pelikhan merged 6 commits into
mainfrom
copilot/fix-runs-on-slim-label-selection
Jun 13, 2026
Merged

Allow runs-on-slim to use runner label arrays#38965
pelikhan merged 6 commits into
mainfrom
copilot/fix-runs-on-slim-label-selection

Conversation

Copilot AI commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

runs-on-slim was schema-validated and parsed as a string only, so workflows using the same runner selection forms supported by runs-on failed to compile.

  • Schema and parsing

    • Reuse the shared GitHub Actions runs-on schema for runs-on-slim.
    • Parse and validate runs-on-slim as string, label array, or { group, labels } object.
  • Compiler output

    • Render complex runs-on-slim values correctly for framework-generated jobs.
    • Preserve safe-outputs.runs-on precedence.
  • Docs and editor metadata

    • Update reference docs, workflow guidance, and autocomplete data to reflect the expanded syntax.

Example now accepted:

runs-on: [self-hosted, ubuntu2404, x64, host]
runs-on-slim: [self-hosted, ubuntu2404, x64, host]

Generated by 👨‍🍳 PR Sous Chef · 71.5 AIC · ⌖ 0.957 AIC · ⊞ 17.3K ·

Co-authored-by: zarenner <13670625+zarenner@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix runs-on-slim to allow multiple label selection Allow runs-on-slim to use runner label arrays Jun 12, 2026
Copilot AI requested a review from zarenner June 12, 2026 23:31
@pelikhan pelikhan marked this pull request as ready for review June 13, 2026 04:36
Copilot AI review requested due to automatic review settings June 13, 2026 04:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands runs-on-slim to accept the same runner-selection shapes as GitHub Actions runs-on (string, label array, or { group, labels } object), and updates compilation output so framework-generated jobs render those forms correctly. It also updates schema validation, docs, and editor autocomplete metadata to match the new syntax.

Changes:

  • Reuse the shared runs-on schema/validation for runs-on-slim and parse it as string/array/object.
  • Render complex runs-on-slim YAML correctly for framework/generated jobs while preserving safe-outputs.runs-on precedence.
  • Update tests, reference docs, workflow guidance, and editor autocomplete data for the expanded forms.
Show a summary per file
File Description
pkg/workflow/workflow_builder.go Extracts runs-on-slim via shared YAML extraction so arrays/objects compile.
pkg/workflow/safe_outputs_runtime.go Renders runs-on-slim as a multi-line YAML snippet suitable for job insertion.
pkg/workflow/safe_outputs_runs_on_test.go Adds coverage for runs-on-slim array/object forms and updated snippet expectations.
pkg/workflow/frontmatter_types.go Changes RunsOnSlim type to any to support string/array/object forms.
pkg/workflow/frontmatter_serialization.go Serializes runs-on-slim from FrontmatterConfig when present.
pkg/workflow/frontmatter_parsing.go Validates runs-on-slim using the shared runs-on shape validator.
pkg/workflow/compiler_types.go Clarifies WorkflowData.RunsOnSlim now holds a rendered runs-on snippet.
pkg/workflow/central_slash_command_workflow.go Ensures centralized workflow runs-on: rendering works with runs-on snippets.
pkg/workflow/central_slash_command_workflow_test.go Adds unit tests for formatting runs-on snippets for inline YAML usage.
pkg/parser/schemas/main_workflow_schema.json Switches runs-on-slim schema to $defs/github_actions_runs_on and updates examples.
pkg/parser/schema_location_test.go Adds schema-location tests to accept runs-on-slim array/object forms.
docs/src/content/docs/reference/self-hosted-runners.md Documents that runs-on-slim supports string/array/object forms.
docs/src/content/docs/reference/frontmatter.md Updates frontmatter reference to describe expanded runs-on-slim syntax.
docs/public/editor/autocomplete-data.json Updates autocomplete type metadata for runs-on-slim.
.github/aw/workflow-constraints.md Updates constraints guidance to reflect new runs-on-slim shapes.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 15/15 changed files
  • Comments generated: 2

Comment on lines 279 to 282
workflowData.RunsOn = c.extractTopLevelYAMLSection(frontmatter, "runs-on")
// Extract runs-on-slim as a plain string (no YAML formatting needed)
if v, ok := frontmatter["runs-on-slim"]; ok {
if s, ok := v.(string); ok {
workflowData.RunsOnSlim = s
}
workflowData.RunsOnSlim = c.extractTopLevelYAMLSection(map[string]any{"runs-on": v}, "runs-on")
}
Comment on lines 182 to 187
if !isNilValue(fc.RunsOn) {
result["runs-on"] = fc.RunsOn
}
if fc.RunsOnSlim != "" {
if !isNilValue(fc.RunsOnSlim) {
result["runs-on-slim"] = fc.RunsOnSlim
}
@github-actions

Copy link
Copy Markdown
Contributor

@copilot review all comments and address the unresolved review feedback on this PR. Then re-run checks and summarize any remaining blockers.

Generated by 👨‍🍳 PR Sous Chef · 51.8 AIC · ⌖ 1.01 AIC · ⊞ 17.3K ·

@github-actions

github-actions Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

⚠️ PR Code Quality Reviewer failed during code quality review.

@github-actions

github-actions Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel failed during test quality analysis.

@github-actions

github-actions Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (>100 new lines in pkg/) but does not have a linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/38965-reuse-runs-on-schema-for-runs-on-slim.md — review and complete it before merging.

🔒 This PR cannot merge until an ADR is linked in the PR body.

📋 What to do next
  1. Review the draft ADR committed to your branch — it was generated from the PR diff.
  2. Complete the missing sections — add context the AI could not infer, refine the decision rationale, and confirm the alternatives you actually considered.
  3. Commit the finalized ADR to docs/adr/ on your branch.
  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-38965: Reuse the runs-on schema and rendering pipeline for runs-on-slim

Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision.

❓ Why ADRs Matter

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you for capturing the decision to reuse the shared runs-on schema rather than duplicating runner-selection logic.

📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What did you decide? Why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number (e.g., 38965-reuse-runs-on-schema-for-runs-on-slim.md for PR #38965).

🔒 This gate is blocking: link the ADR in the PR body to proceed.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · 73.6 AIC · ⌖ 9.74 AIC · ⊞ 13.8K ·

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: runs-on-slim multi-form support

No correctness bugs or data-loss risks found. Two non-blocking comments were posted inline; one additional observation below.

🔍 Findings detail

1. formatRunsOnSnippetForInlineValue — undocumented indentation coupling (inline, medium)

The 2-space TrimPrefix and 6-space re-indent are hard-wired to two invariants that live elsewhere: DefaultMarshalOptions using 2-space map indentation, and the central slash command template placing runs-on: at 4-space indent. Neither is stated in the function. See inline comment.

2. TestGenerateCentralSlashCommandWorkflow_UsesCentralizedRunsOnResolution — stale test fixture (medium)

pkg/workflow/central_slash_command_workflow_test.go line 302 still sets RunsOnSlim: "ubuntu-latest" using the old raw-string format. After this PR the production path always stores a rendered snippet ("runs-on: ubuntu-latest"). The test continues to pass only because formatRunsOnSnippetForInlineValue has a defensive fallback for values without a "runs-on:" prefix. This means the test exercises the fallback, not the production path — a future removal of that defensive branch would break the test unexpectedly.

Suggested fix: update the fixture to RunsOnSlim: "runs-on: ubuntu-latest" to match the semantics documented on the field.

3. TestFormatFrameworkJobRunsOn — misleading test name (inline, low)

See inline comment.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

🔎 Code quality review by PR Code Quality Reviewer · 957.7 AIC · ⌖ 13.4 AIC · ⊞ 17.3K

Comment on lines +519 to +521
for i, line := range lines {
line = strings.TrimPrefix(line, " ")
lines[i] = " " + line

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fragile magic-number indentation coupling: the " " strip and " " re-indent are silently coupled to two external invariants — DefaultMarshalOptions producing 2-space map-field indent, and runs-on: sitting at exactly 4-space indent in the central slash command template. No comment explains these assumptions, so a future indent-style or template change would corrupt the generated YAML silently.

💡 Suggested fix

Document the coupling explicitly:

// The 2-space strip matches DefaultMarshalOptions map indentation.
// The 6-space re-indent aligns with the central slash command template,
// where runs-on: lives at 4-space job-level indent (4 + 2 = 6).
line = strings.TrimPrefix(line, "  ")
lines[i] = "      " + line

Alternatively, pass the target indent as a parameter so the function is not implicitly tied to one specific template.

expectedRunsOn: "runs-on: " + constants.DefaultActivationJobRunnerImage,
},
{
name: "runs-on-slim array snippet returned as-is",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misleading test name: "runs-on-slim array snippet returned as-is" implies the value is passed through unchanged, but formatFrameworkJobRunsOn calls c.indentYAMLLines(data.RunsOnSlim, " ") which explicitly adds 4-space indentation to every continuation line. A reader relying on this name to understand the contract will be misled.

💡 Suggested fix

Rename to something that describes the actual transformation, for example:

name: "runs-on-slim array snippet has continuation lines indented",

or more precisely:

name: "runs-on-slim array snippet indents continuation lines by 4 spaces",

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher review

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot run pr-finisher review

Completed a PR-finisher pass in 277b0d8.

  • Fixed runs-on-slim empty string/array/object handling so empty values stay unset and fall back to defaults.
  • Added regression coverage for empty runs-on-slim values, updated the centralized RunsOnSlim fixture, and clarified the indentation contract/test naming.
  • Local validation passed: make fmt, make lint, make test-unit, make test, make agent-report-progress, and parallel_validation.

Remaining blocker: the ADR gate still needs the ADR linked in the PR body; I can’t update the PR body from this environment.

Copilot AI requested a review from pelikhan June 13, 2026 11:03
@pelikhan pelikhan merged commit f22d53c into main Jun 13, 2026
29 checks passed
@pelikhan pelikhan deleted the copilot/fix-runs-on-slim-label-selection branch June 13, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runs-on-slim does not allow multiple label selection

4 participants