Skip to content

fix(tia): persist state on detached HEAD- #1844 - #1891

Open
calebdw wants to merge 2 commits into
pestphp:5.xfrom
calebdw:tia_detached_head
Open

fix(tia): persist state on detached HEAD- #1844#1891
calebdw wants to merge 2 commits into
pestphp:5.xfrom
calebdw:tia_detached_head

Conversation

@calebdw

@calebdw calebdw commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Supercedes: #1844

What:

  • Bug Fix
  • New Feature

Description:

This allows TIA to persist its dependency graph and related state when Git HEAD is detached.

Detached HEAD is a normal checkout state for GitLab CI and for local workflows that use jj with a colocated Git repository. TIA previously suppressed graph writes, state deletion, structural rebuilds, and --fresh purges in this state. A run could therefore pass without producing the graph required by a baseline artifact or a later local run.

TIA now permits the same state operations for attached and detached checkouts. It resolves the writable baseline identity in this order:

  1. Use the current Git branch when Git reports one.
  2. Use the current branch reported by the GitLab or GitHub CI provider.
  3. Use a stable @workspace:<hash> key for jj and other detached workspaces.

The default branch remains the read fallback. A local detached workspace can download a baseline recorded on the default branch, calculate changes from that baseline, and store its own SHA, tree, and test results under its workspace key. This prevents an unknown detached checkout from changing the published default-branch baseline.

The TIA CI abstraction now resolves both current and default branches, so each provider owns its environment-variable handling. Workspace baselines survive Git branch reclamation and do not participate in default-branch inference.

The tests cover sequential and parallel detached runs, structural rebuilds, --fresh, unreadable graph replacement, branch reclamation, default-baseline isolation, and detached GitLab and GitHub branch detection. The fixture process also removes inherited CI variables so local-behavior tests remain local when the Pest suite itself runs in CI.

Thanks!

Consolidate duplicated CI environment detection logic from
Snapshot and BaselineSync into a shared Pest\Support\Ci class.

This reduces duplication and provides a single source of truth
for CI detection, including comprehensive environment variable
checks for all major CI providers.
Allow detached checkouts to write, delete, and rebuild TIA state so
baseline publishers and local detached workflows produce a usable graph.

Resolve the writable baseline from the Git branch, CI branch metadata, or
a stable workspace key. Keep the default branch as the read fallback so
local workspaces can use a published baseline without changing it.
@calebdw

calebdw commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

@MrPunyapal, looks like ci needs to be approved

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