Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions .github/workflows/reusable-ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# file: .github/workflows/reusable-ci.yml
# version: 1.21.0
# version: 1.22.0
# guid: reusable-ci-2025-09-24-core-workflow
# last-edited: 2026-11-07
# last-edited: 2026-11-17

name: Reusable CI Workflow

Expand Down Expand Up @@ -69,6 +69,17 @@ on:
required: false
type: boolean
default: true
fetch-base-branch-tip:
description: >-
Before the Go tests run, fetch the tip of the repository's default
branch at depth 1 so `origin/<default branch>` resolves in the
otherwise shallow, single-ref checkout. Set true when a Go test diffs
a file against the default branch (for example a test that only lets
a list shrink) and fails without that ref. Only the Go CI job is
affected. Default false leaves the checkout unchanged.
required: false
type: boolean
default: false
skip-linting:
description: 'Skip linting'
required: false
Expand Down Expand Up @@ -634,6 +645,20 @@ jobs:
with:
submodules: recursive

# Opt-in (fetch-base-branch-tip). The checkout above is depth 1 with no
# base ref, so a test that diffs a file against the default branch has
# nothing to diff against. Fetch the default branch's tip alone, not its
# history. The branch name goes through env, never into the script text.
- name: Fetch default branch tip
if: inputs.fetch-base-branch-tip
shell: bash
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
run: |
set -euo pipefail
git fetch --no-tags --depth=1 origin "${DEFAULT_BRANCH}"
git rev-parse --verify "origin/${DEFAULT_BRANCH}"

- name: Get ghcommon workflow ref
id: ghcommon-ref
run: |
Expand Down
16 changes: 16 additions & 0 deletions changelog.d/20261117-reusable-ci-fetch-base-branch-tip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### Added

#### `reusable-ci.yml` gains an opt-in `fetch-base-branch-tip` input for Go CI

The `go-ci` job checks the repository out at depth 1 with no base ref, so a Go
test that diffs a file against the default branch (for example a test that only
lets a list shrink) cannot resolve `origin/<default branch>` and fails. A caller
cannot add a step to a reusable workflow's job, so the fetch has to live here.

`fetch-base-branch-tip` (boolean, default `false`) adds a step right after
"Checkout repository" in `go-ci` that runs
`git fetch --no-tags --depth=1 origin "${DEFAULT_BRANCH}"` and then verifies
`origin/<default branch>` resolves. `DEFAULT_BRANCH` comes from
`github.event.repository.default_branch` through `env:`, not through script
interpolation. Only the default branch's tip is fetched, never its history. The
default keeps every existing caller's behaviour unchanged.
Loading