Skip to content

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

Closed
calebdw wants to merge 2 commits into
pestphp:5.xfrom
calebdw:calebdw/push-owkpumrmwusw
Closed

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

Conversation

@calebdw

@calebdw calebdw commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

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!

@calebdw
calebdw force-pushed the calebdw/push-owkpumrmwusw branch 3 times, most recently from b794a6b to 63427c7 Compare August 17, 2026 22:26
@calebdw calebdw changed the title fix(tia): allow graph persistence on detached HEAD locally fix(tia): persist graph on detached HEAD Aug 17, 2026
@calebdw

calebdw commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

@nunomaduro, I came across this while testing the GitLab tia work---this is needed to support recording tia in gitlab ci

@calebdw
calebdw force-pushed the calebdw/push-owkpumrmwusw branch 2 times, most recently from d8bd0f8 to b373978 Compare August 25, 2026 20:34
@calebdw

calebdw commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

@MrPunyapal, can you please take a look at this? This is a blocker to be able to properly support Gitlab (#1841)

@calebdw

calebdw commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

Nice, let me fix the tests

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 force-pushed the calebdw/push-owkpumrmwusw branch from b373978 to 0760b4e Compare August 26, 2026 15:55
@calebdw calebdw changed the title fix(tia): persist graph on detached HEAD fix(tia): persist state on detached HEAD Aug 26, 2026
@calebdw

calebdw commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

@MrPunyapal, can you run ci again please?

@MrPunyapal

Copy link
Copy Markdown
Collaborator

@MrPunyapal, can you run ci again please?

Refreshed my page multiple times already, but no luck yet.
image

@MrPunyapal MrPunyapal closed this Aug 26, 2026
@MrPunyapal MrPunyapal reopened this Aug 26, 2026
@calebdw

calebdw commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

I guess ci is down again lol

@MrPunyapal MrPunyapal left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ci

@MrPunyapal

Copy link
Copy Markdown
Collaborator

Can you try doing a new PR?

@calebdw calebdw closed this Aug 26, 2026
@calebdw
calebdw deleted the calebdw/push-owkpumrmwusw branch August 26, 2026 16:41
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.

2 participants