Skip to content

[GitHubActions] generator: control the shell for run steps via DefaultShell#430

Open
avidenic wants to merge 1 commit into
Fallout-build:mainfrom
avidenic:features/388-github-actions-default-shell
Open

[GitHubActions] generator: control the shell for run steps via DefaultShell#430
avidenic wants to merge 1 commit into
Fallout-build:mainfrom
avidenic:features/388-github-actions-default-shell

Conversation

@avidenic

Copy link
Copy Markdown
Contributor

Closes #388.

Adds DefaultShell to GitHubActionsAttribute. When set, the workflow emits a top-level defaults.run.shell block so cross-platform matrix jobs pin one shell instead of the per-OS default (bash on Linux/macOS, pwsh on Windows).

[GitHubActions("build",
    GitHubActionsImage.WindowsLatest, GitHubActionsImage.UbuntuLatest,
    InvokedTargets = [nameof(Compile)],
    DefaultShell = "pwsh")]
defaults:
  run:
    shell: pwsh
  • Block is emitted after concurrency:, before jobs:; unset or whitespace-only emits nothing.
  • Free-string value (built-in or custom command {0} template) — raw-interpolated, consistent with the sibling Env/ConcurrencyGroup values.
  • Covers both generator run: lines (tool restore + dotnet fallout) across every matrix job.

Scoped out — per-step shell:. The issue proposed it as a secondary escape hatch; analysis dropped it. GetSteps is private and emits exactly one run step per job, so a per-step Shell field has no granularity advantage over the workflow default and no reachable setter. Clean additive follow-up if a real extension scenario needs it.

Tests — two Verify snapshot cases: default-shell (emission) and default-shell-with-permissions (placement guard vs permissions:/concurrency:). No dedicated whitespace test: the guard delegates to the BCL primitive, and the repo reserves *ValidationTest.cs for features that throw.


⚠️ CI note: Test is green. Pack currently fails on main because CHANGELOG.md was deleted (c2cdf60) while IPack/IHasChangelog still requires it — unrelated to this PR, fixed separately.

Cross-platform matrix jobs silently use a different default shell per OS
(bash on Linux/macOS, pwsh on Windows), which changes script semantics.
The generator had no way to emit an explicit shell.

Add a public string DefaultShell to GitHubActionsAttribute. When set, the
workflow emits a top-level defaults.run.shell block (after concurrency,
before jobs), pinning one shell for every run: step across all matrix jobs.
Free-string value; unset or whitespace-only emits no block. Per-step shell
was deliberately scoped out (one run step per job; no granularity gain).

Covered by two Verify snapshot cases (default-shell, and a
default-shell-with-permissions ordering guard).
@avidenic avidenic marked this pull request as ready for review June 25, 2026 12:00
@avidenic avidenic requested a review from a team as a code owner June 25, 2026 12:00
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.

[GitHubActions] generator: control the shell for run steps (defaults.run.shell + per-step shell:)

1 participant