Skip to content

fix(ci): pin API file commits to checkout revisions - #2031

Merged
gerchowl merged 7 commits into
devfrom
bugfix/2028-commit-action-base-sha
Nov 4, 2026
Merged

gerchowl merged 7 commits into
devfrom
bugfix/2028-commit-action-base-sha

Conversation

@gerchowl

@gerchowl gerchowl commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

Pin all API file commits to the revision used to compute their files. Concurrent updates now cause a non-fast-forward failure instead of silently replacing newer changelog entries or generated files. Both devkit and consumer workflows use fail-closed SHA capture immediately after the relevant checkout.

Type of Change

  • fix -- Bug fix
  • test -- Adding or updating tests
  • ci -- CI/CD pipeline changes

Modifiers

  • Breaking change (!)

Changes Made

  • Add an adjacent runtime guard before all 18 API file commits, checking the exact BASE_SHA input with the same condition as the commit.
  • Export the consumer freeze action’s commit-sha directly; the visibility wait accepts only that confirmed SHA. Add complete rollback diagnostics and manual-release-review guidance.
  • Export the root freeze action’s exact commit SHA before branch creation; skip rollback restoration when it is empty or dev has advanced.
  • Verify each capture matches its target (or documented new-branch source), and that capture gates cannot be narrower than commit gates. Keep the extension fallback gate; make sync captures unconditional.
  • Merge the duplicate Unreleased Fixed headings in the root changelog and generated mirror.
  • Wire checkout outputs into BASE_SHA for all 16 previously unprotected calls; retain the two protected abandon-release calls.
  • Use the checkout SHA for prepare's rollback baseline, rather than a later moving-head API read.
  • Explicitly check out dev for consumer rollback. Capture the extension fallback's second checkout separately; capture the sync branch after its creation/checkout.
  • Document the concurrency guarantee and recovery behavior in RELEASE_CYCLE.

Every vig-os/commit-action call under both workflow trees was audited. No moving-head exemptions are needed. D means .github/workflows/; C means assets/workspace/.github/workflows/.

Copy Workflow / job / call Decision
D abandon-release / unfreeze / restore changelog Already pinned; retain checkout base
C abandon-release / unfreeze / restore changelog Already pinned; retain checkout base
D prepare-release / prepare / freeze changelog Pin dev checkout; changelog computed locally
C prepare-release / prepare / freeze changelog and optional bundle Pin source checkout; target starts from that SHA
D prepare-release / rollback / restore changelog Pin dev checkout; close race after rollback guard
C prepare-release / rollback / restore changelog Pin explicit dev checkout; close race after rollback guard
D prepare-hotfix / prepare / seed changelog Pin main checkout; release branch starts from validated main SHA
C prepare-hotfix / prepare / seed changelog Pin main checkout; release branch starts from validated main SHA
D prepare-release-extension / sync-manifest / release mirror Pin release checkout; mirror depends on its changelog
D prepare-release-extension / sync-manifest / dev mirror Pin second dev checkout; mirror depends on current dev content
D release / finalize / finalization changes Pin release checkout; dates, docs, manifest and version computed locally
C release-core / finalize / finalization changes Pin release checkout; changelog and optional bundle computed locally
D sync-issues / sync / issue and PR snapshots Pin target checkout; incremental updates depend on existing snapshots
C sync-issues / sync / issue and PR snapshots Pin target checkout; incremental updates depend on existing snapshots
D sync-main-to-dev / sync / doc conflict resolution Pin newly checked-out sync branch; reject concurrent target changes
C sync-main-to-dev / sync / doc conflict resolution Pin newly checked-out sync branch; reject concurrent target changes
D update-nixpkgs / bump / lock bump Pin dev checkout; chore branch is reset/created at that SHA
D update-nixpkgs-unstable / bump / lock bump Pin dev checkout; chore branch is reset/created at that SHA

Changelog Entry

Fixed

  • Protect workflow file commits from concurrent branch updates (#2028)
    • Pin API commits to the checkout SHA in devkit and consumer workflows; fail closed when capture fails or the target advances.
    • Restore failed prepare freezes only when dev still matches the freeze action’s confirmed commit; preserve concurrent changes when the freeze was rejected.
    • Export the exact consumer freeze commit and reject empty commit bases at runtime before every API file commit.

Testing

  • Targeted tests pass locally (357 passed; exit 0); final focused replay/contract run: 124 passed, exit 0.
  • All 16 PR checks pass on 09e7ef49745e02438937aa45c732e8e84b5cd884, including Test Summary; gh pr checks 2031 --watch exited 0.
  • Manual testing performed (details below).

Manual Testing Details

RED first (round 1): new replay tests produced 32 failures and 4 passes (exit 1); baseline tests produced 2 failures (exit 1). Round 2: rollback and capture-contract tests produced 6 failures and 56 passes (exit 1), including the rejected-freeze overwrite. Round 3: consumer rollback, exact freeze output/visibility and runtime guard tests produced 45 failures and 79 passes (exit 1). Tests were committed before implementation.

GREEN: uv run --with pytest-xdist pytest tests/test_commit_action_base_sha.py tests/test_prepare_rollback_concurrency.py tests/test_abandon_release.py tests/test_workflow_prepare_extension.py tests/test_workflow_prepare_hotfix.py tests/test_workflow_prepare_sync_guard.py tests/test_workflow_sync_checkout.py tests/test_workflow_sync_autoresolve.py tests/test_workflow_sync_watermark.py tests/test_workflow_model.py tests/test_release_core.py tests/test_release_rollback_guard.py tests/test_release_prepare_bundle.py tests/test_release_time_changelog.py -n 4 --basetemp="$HOME/.cache/devkit-pytest/2028-r3-targeted2" — 357 passed, exit 0.

Replay tests execute every capture, advance the local Git head, and verify the API base still resolves to the original SHA. A failing Git stub returns 17: every capture fails with that code, emits no output, and prevents the following sentinel step from executing. Tests reject the extension’s wrong-checkout mutant and a narrowed capture condition for all 18 callers, demonstrating skipped captures resolve to an empty base. Prepare rollback replays cover rejected freeze with concurrent changes, landed freeze with unchanged dev, and landed freeze followed by another change in both copies; the consumer also covers failure before the freeze. Removing the consumer empty-freeze guard produced 2 failures and 2 passes (exit 1); the original workflow was restored. Every runtime guard is replayed with empty and nonempty input. The sync-issues future-output capture mutant skips capture, then fails at the real runtime guard when sync later produces changed files, in both copies. Workflow model tests cover gitflow and trunk rendering. Required commit hooks run inside nix develop.

The checkout rollback baseline remains safe: any failure before a confirmed freeze skips restoration, a confirmed freeze identifies the run’s own write, a later dev update fails the exact-SHA guard, and BASE_SHA rejects races after that guard. A missing freeze output after an ambiguous API failure deliberately leaves restoration to manual recovery.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly
  • I have updated CHANGELOG.md in the [Unreleased] section
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective
  • New and existing targeted tests pass locally
  • Any dependent changes have been merged and published

Additional Notes

A moved target fails the API update; it does not automatically recompute generated files. Rerun from a fresh checkout after reviewing the failed phase and partial release state. No workflows were dispatched. No changes to assets/workspace/CHANGELOG.md.

Refs: #2028

@gerchowl
gerchowl requested a review from c-vigo as a code owner November 4, 2026 05:35
@gerchowl
gerchowl force-pushed the bugfix/2028-commit-action-base-sha branch from d1c6ab8 to 05217f5 Compare November 4, 2026 05:43
@gerchowl
gerchowl merged commit 025fc6a into dev Nov 4, 2026
16 checks passed
@gerchowl
gerchowl deleted the bugfix/2028-commit-action-base-sha branch November 4, 2026 06:48
gerchowl added a commit that referenced this pull request Nov 6, 2026
## Description

#2031 added a `Record checkout SHA` step (`CHECKOUT_SHA=$(git rev-parse
HEAD)`) right after `actions/checkout` and before `Set up devkit
toolchain`. In a `container:` job, git refuses the workspace as "dubious
ownership" (exit 128) until `setup-devkit-toolchain` marks it a
`safe.directory`. That broke the 1.19.0-rc4 smoke test (Prepare Release
run 42151390302). This PR takes the SHA from `actions/checkout`'s
documented `commit` output, so no git call is needed. Release blocker
for 1.19.0 (#2033).

## Type of Change

- [x] `fix` -- Bug fix
- [x] `test` -- Adding or updating tests

### Modifiers

- [ ] Breaking change (`!`) -- This change breaks backward compatibility

## Changes Made

- **15 captures that directly follow `actions/checkout`** (devkit
`.github/workflows`: prepare-release ×2, prepare-release-extension,
prepare-hotfix, release, abandon-release, sync-issues, update-nixpkgs,
update-nixpkgs-unstable; consumer `assets/workspace/.github/workflows`:
prepare-release ×2, prepare-hotfix, release-core, abandon-release,
sync-issues):
  - The checkout step gets `id: checkout`.
- The capture reads `CHECKOUT_SHA: ${{ steps.checkout.outputs.commit }}`
through `env:`. Nothing is interpolated into `run:`.
  - It fails closed (`::error::`, exit 1) when the output is empty.
- The step id `checkout-state`, the output `sha`, every `BASE_SHA`
consumer and the `Require pinned commit base` guards are unchanged.
- `actions/checkout@3d3c42e5` (v7.0.1) declares `outputs.commit` in its
`action.yml`. `src/git-source-provider.ts` sets it from `git log -1
--format=%H` after checkout.
- **3 captures left on `git rev-parse` on purpose**: the extension's dev
fallback (`dev-checkout-state`) and sync-main-to-dev in both trees.
- Each follows a later manual `git checkout` step, so HEAD is no longer
the commit `actions/checkout` reported, and that output would be the
wrong base.
- They run after the toolchain/safe-directory setup. The new ordering
scan proves this for the container job.
- **New guard `tests/test_workflow_checkout_sha.py`** scans every
workflow in both trees:
- In every job with a `container:` key, no `run:` step may invoke git
before the step that sets `safe.directory`. That step is
`./.github/actions/setup-devkit-toolchain`, whose "Configure
in-container toolchain env" step runs `git config --global --add
safe.directory "$GITHUB_WORKSPACE"`; the test asserts that line exists.
- Every `Record checkout SHA` after `actions/checkout` must read that
step's `commit` output, use no git and fail closed when it is empty.
  - Anything else must follow a manual git checkout.
- It checks that the scan is not vacuous: at least 20 container jobs and
exactly 18 captures.
- **#2031/#2028 replay tests** (`test_commit_action_base_sha.py`,
`test_abandon_release.py`) now seed the checkout `commit` output. The
fail-closed tests check that an empty output stops the job with exit 1
(git-based captures still surface git's exit code).
- `docs/RELEASE_CYCLE.md` documents the capture rule and the reason for
the exception.

## Changelog Entry

Under `## [1.19.0] - TBD` → `### Fixed` (release branch):

- **Record checkout SHAs without git in container jobs**
([#2055](#2055))
- Take the API commit base from `actions/checkout`'s `commit` output, so
Prepare Release, Prepare Hotfix, Release and Sync Issues no longer fail
with "dubious ownership" (exit 128) in `devcontainer`/`both` mode.
- Fail closed when the checkout reports no commit; a static guard
rejects any container job that runs git before its `safe.directory`
setup.

## Testing

- [x] Tests pass locally (touched suites only; CI runs the rest)
- [ ] Manual testing performed (describe below)

### Manual Testing Details

- RED on base (commit `test(ci): ...`): `pytest
tests/test_workflow_checkout_sha.py` gave 20 failed and 23 passed, exit
1. The failures were 5 container jobs running git before safe.directory
(consumer prepare-hotfix:prepare, prepare-release:prepare and :rollback,
release-core:finalize, sync-issues:sync) and 15 captures.
- GREEN: the new guard plus `test_commit_action_base_sha.py` and
`test_abandon_release.py` gave 181 passed, exit 0.
- All 63 non-container, non-nix test files that read these workflows
(scaffold drift/pin and workflow shape suites included) gave 2365 passed
and 4 skipped, exit 0.

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have updated the documentation accordingly
- [x] I have updated `CHANGELOG.md` (release section, per release-branch
fix) and pasted the entry above
- [x] My changes generate no new warnings or errors
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published

## Additional Notes

Targets `release/1.19.0`, not `dev`: it fixes the 1.19.0 release
candidate. After merge, the next RC smoke run is the end-to-end proof.

Refs: #2055
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.

1 participant