Skip to content

Emit custom runs-on label arrays for self-hosted runners (#387) - #418

Merged
ChrisonSimtian merged 1 commit into
Fallout-build:mainfrom
avidenic:features/387-github-actions-runs-on-labels
Jun 29, 2026
Merged

Emit custom runs-on label arrays for self-hosted runners (#387)#418
ChrisonSimtian merged 1 commit into
Fallout-build:mainfrom
avidenic:features/387-github-actions-runs-on-labels

Conversation

@avidenic

@avidenic avidenic commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Closes #387.

What

Adds a public RunsOnLabels (string[]) to GitHubActionsAttribute so a generated workflow can target a self-hosted runner pool by label array — runs-on: [self-hosted, linux, x64] — instead of only the fixed GitHubActionsImage enum scalar.

[GitHubActions(
    "deploy",
    GitHubActionsImage.UbuntuLatest, // mandatory; ignored for runs-on when RunsOnLabels is set
    On = [GitHubActionsTrigger.WorkflowDispatch],
    InvokedTargets = [nameof(Deploy)],
    RunsOnLabels = ["self-hosted", "linux", "x64"])]
public partial class Build : NukeBuild { /* ... */ }
deploy:
  name: ubuntu-latest
  runs-on: [self-hosted, linux, x64]
  steps:
    - uses: actions/checkout@v6
    # ...

How

  1. GitHubActionsAttribute.RunsOnLabels (string[], defaults empty) → carried through GetJobs onto a matching GitHubActionsJob.RunsOnLabels.
  2. GitHubActionsJob.Write branches: non-empty → runs-on: [a, b, c] via JoinCommaSpace(); otherwise the existing scalar runs-on: {Image.GetValue()} path is untouched.
  3. Validated at configuration-generation time:
    • requires exactly one image — a multi-image matrix can't be disambiguated by a single label set, so it fails the build with a clear message rather than silently emitting N identical-runner jobs. (The constructor mandates an image regardless; when RunsOnLabels is set the image is ignored for runs-on: and only names the job.)
    • rejects null/empty/whitespace entries, which would otherwise emit malformed YAML such as runs-on: [a, ].

Per the issue, the property is named RunsOnLabels (not the fork's earlier RunsOnOptionalInputs). Job- and step-level runs-on and any GitHubActionsImage enum changes are out of scope.

Backwards compatibility

Purely additive. RunsOnLabels defaults to empty, so existing [GitHubActions(...)] usages generate byte-for-byte identical YAML (no runs-on: change). Non-breaking → target/2026, no breaking-change.

Testing

  • runs-on-labels Verify snapshot in ConfigurationGenerationTest — locks the runs-on: [self-hosted, linux, x64] array form; the existing scalar snapshots are unchanged, guarding the fallback path.
  • GitHubActionsRunsOnLabelsValidationTest: matrix+labels throws; single-image+labels and matrix-without-labels don't; single label is valid; null/empty/whitespace element throws.
  • Full solution ./build.sh Test Pack is green locally, including the Nuke.* transition-shim test projects that consume this public API.

@avidenic
avidenic marked this pull request as ready for review June 21, 2026 13:15
@avidenic
avidenic requested a review from a team as a code owner June 21, 2026 13:15
@ChrisonSimtian ChrisonSimtian added the Can Merge These PRs are just waiting to be merged, nothing more to do and maintainer has approved label Jun 22, 2026
@avidenic

avidenic commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

@ChrisonSimtian build is finally green =)

@ChrisonSimtian

Copy link
Copy Markdown
Collaborator

@ChrisonSimtian build is finally green =)

yeah i merged dennis' fix this morning 😬 happy merging

@avidenic
avidenic force-pushed the features/387-github-actions-runs-on-labels branch from 0b7c7b8 to de885f2 Compare June 29, 2026 07:27
@avidenic

Copy link
Copy Markdown
Contributor Author

@ChrisonSimtian build is finally green =)

yeah i merged dennis' fix this morning 😬 happy merging

Tnx! I do not seem to have an option to merge though.

…ld#387)

GitHubActionsJob.Write emitted runs-on: {Image.GetValue()} unconditionally,
so a workflow could only target the fixed GitHubActionsImage enum. Self-hosted
runner pools are selected by a label array (runs-on: [self-hosted, linux, x64])
which was impossible to produce.

Add an additive string[] RunsOnLabels to GitHubActionsAttribute, plumb it
through GetJobs onto GitHubActionsJob, and branch in Write: non-empty emits the
array form via JoinCommaSpace(), otherwise the existing scalar path is unchanged.
RunsOnLabels defaults empty, so existing usages generate byte-for-byte identical
YAML. Validated at configuration-generation time: it requires exactly one image
(a multi-image matrix is ambiguous) and rejects null/empty/whitespace entries
that would emit malformed YAML.

Covered by a runs-on-labels Verify snapshot and GitHubActionsRunsOnLabelsValidationTest.
@avidenic
avidenic force-pushed the features/387-github-actions-runs-on-labels branch from de885f2 to 2318fda Compare June 29, 2026 08:10
@ChrisonSimtian
ChrisonSimtian merged commit a50adbb into Fallout-build:main Jun 29, 2026
1 check passed
@ChrisonSimtian

Copy link
Copy Markdown
Collaborator

@ChrisonSimtian build is finally green =)

yeah i merged dennis' fix this morning 😬 happy merging

Tnx! I do not seem to have an option to merge though.

did you rebase? Should show you the merge option once you got everything green ticked. If your other PRs are blocked, just ping me and I'll have another look @avidenic

@avidenic
avidenic deleted the features/387-github-actions-runs-on-labels branch June 30, 2026 08:00
@ChrisonSimtian ChrisonSimtian added the enhancement New feature or request label Jul 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Can Merge These PRs are just waiting to be merged, nothing more to do and maintainer has approved enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GitHubActions] generator: custom runs-on label arrays for self-hosted runners

2 participants