feat(ci): teach [GitHubActions] about CheckoutRef so regen preserves the ref pin#175
Merged
Merged
Conversation
…the ref pin The ubuntu-latest workflow YAML carried a manual ref:github.head_ref patch that keeps HEAD attached on PR-triggered builds. Without it, GitHubTasksTest.GitHubRepositoryFromLocalDirectoryTest fails because GitRepository.FromLocalDirectory can't resolve a branch from a detached merge SHA (seen on PR #172 when GenerateTools clobbered the patch and CI went red). Fix: surface the actions/checkout 'ref' input as first-class config on GitHubActionsCheckoutStep + a CheckoutRef setter on [GitHubActions]. The ubuntu-latest attribute in Build.CI.GitHubActions.cs now sets CheckoutRef = "${{ github.head_ref }}", so subsequent GenerateTools runs re-emit the patch automatically instead of dropping it. macos-latest and windows-latest are unchanged — they run on push-to-main where HEAD is already attached on the requested commit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 25, 2026
ChrisonSimtian
added a commit
that referenced
this pull request
May 27, 2026
Regression introduced by #175. The generated workflow emitted: - uses: actions/checkout@v6 with: ref: ${{ github.head_ref }} …but didn't set `repository:`. Checkout defaulted to `${{ github.repository }}` (this repo) and tried to resolve `fix/whatever` as a local branch — which fails for fork PRs because the source branch only exists on the contributor's fork. Symptom: cross-repo PRs (e.g. Dennis Doomen's #222 from his fork) fail at the `Run actions/checkout@v6` step with: fatal: A branch or tag with the name 'fix/...' could not be found #175's `CheckoutRef = "${{ github.head_ref }}"` was added so GitVersion / GitRepository.FromLocalDirectory see the source branch in `.git/HEAD` (otherwise checkout puts you on the merge ref in detached-HEAD state). Goal correct; cross-repo coverage missed. Fix: - GitHubActionsCheckoutStep.Write now emits a `repository:` line whenever `Ref` is non-empty: repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} The `||` fallback covers push events (no pull_request context). - Doc comments on CheckoutRef + Ref updated. - New regression test case `checkout-ref` in ConfigurationGenerationTest locks the YAML shape. Verified snapshot committed alongside. - .github/workflows/ubuntu-latest.yml regenerated by the build. macos-latest / windows-latest / release.yml unchanged (none set CheckoutRef). - CHANGELOG.md entry under [Unreleased] — 11.0. After this lands, Dennis's PR #222 will pick up the fix on the next workflow run (any rerun, or a push to his branch). Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the annoying GenerateTools whack-a-mole on
ubuntu-latest.yml: the manualref: \${{ github.head_ref }}patch that keeps HEAD attached on PR builds is now first-class config on the[GitHubActions]attribute, so every subsequent regen re-emits it automatically.Background
The
ubuntu-latestPR workflow needsactions/checkoutconfigured withref: \${{ github.head_ref }}because:GitHubTasksTest.GitHubRepositoryFromLocalDirectoryTestreads.git/HEADviaGitRepository.FromLocalDirectory.ref:pin,actions/checkoutlands on a detached merge SHA, so HEAD has no branch →repository.Branchis null → test fails.PR #172's
GenerateToolsrun dropped the manual patch and CI went red. This PR makes the patch survive regenerations.Changes
Fallout.Common/CI/GitHubActions/Configuration/GitHubActionsCheckoutStep.csRefproperty + emitsref: <value>in the YAML when set.Fallout.Common/CI/GitHubActions/GitHubActionsAttribute.csCheckoutRefsetter forwards to the step.build/Build.CI.GitHubActions.cs[GitHubActions(\"ubuntu-latest\", ..., CheckoutRef = \"\${{ github.head_ref }}\")]. macOS and Windows stay unchanged (they run on push-to-main, HEAD already attached)..github/workflows/ubuntu-latest.ymlref:line, no hand-written comment needed.Test plan
dotnet run --project build/_build.csproj -- GenerateBuildServerConfigurationsproduces the expectedref:line.dotnet test fallout.slnx— 425/425 pass.🤖 Generated with Claude Code