Skip to content

Harden git test fixtures against auto-gc flakes - #135

Merged
fgilio merged 1 commit into
mainfrom
claude/project-handoff-prep-hdfvjt
Jul 7, 2026
Merged

Harden git test fixtures against auto-gc flakes#135
fgilio merged 1 commit into
mainfrom
claude/project-handoff-prep-hdfvjt

Conversation

@fgilio

@fgilio fgilio commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

Addresses the parallel-shard flake in #133, where CI failed mid-test with error: bad tree object HEAD — loose objects vanishing from a fixture repo's object store during rapid commit loops.

  • Rules out cross-worker deletion: every temp-dir cleanup glob in the suite was audited and is PID-scoped, leaving git auto-gc/auto-maintenance racing object writes as the remaining suspect.
  • Disables gc.auto/maintenance.auto twice over: via GIT_CONFIG_* env in phpunit.xml (covers every git invocation from test processes, including ad-hoc git init repos) and baked into the RepoTemplate .git/config (covers copied fixtures even when git runs in a child process with a sanitized environment).
  • Adds forensics on recurrence: runTestRepoCommand() now appends a git count-objects -v + git fsck snapshot to the exception, so any future failure shows what survived in the object store.

Gotcha documented along the way

PHPUnit coerces <env value="false"/> into an empty string, so the new env entries use "0". The pre-existing commit.gpgsign entry has been exporting an empty value all along — git parses empty as boolean false, so it works, but it silently shadows file-scope values for the same key. Noted in phpunit.xml and tests/CLAUDE.md.

Testing

  • New regression tests in tests/Unit/Helpers/InteractsWithTestRepositoriesTest.php (gc-off config on copied fixtures; forensics appended to failed repo commands)
  • Core suite green under --parallel: 1655 passed
  • Browser suite green: 199 passed, 1 skipped
  • PHPStan and Pint clean

Refs #133 — suggest closing it after a few more sharded CI runs pass, since a flake can't be proven dead in one run.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HVdCTd166nSKuhBsnKePM9


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability of test repository setup by disabling automatic Git maintenance during parallel runs.
    • Repository command failures now include extra Git object-store diagnostics, making issues easier to troubleshoot.
  • Documentation

    • Updated test guidance to reflect the new repository maintenance and failure-diagnostics behavior.
  • Tests

    • Added coverage for Git configuration defaults and enhanced failure reporting.

CI intermittently failed under parallel Core shards with "bad tree
object HEAD" mid-way through rapid commit loops — loose objects
vanishing from a fixture repo's object store (issue #133). The
temp-dir cleanup globs were audited and are all PID-scoped, leaving
git auto-gc/auto-maintenance racing object writes as the remaining
suspect.

Disable gc.auto and maintenance.auto twice over: via GIT_CONFIG_* env
in phpunit.xml (covers every git invocation from test processes,
including ad-hoc `git init` repos) and baked into the RepoTemplate's
.git/config (covers copied fixtures even when git runs in a child
process with a sanitized environment). Note: the env values use "0"
because PHPUnit coerces a literal value="false" into an empty string —
git happens to parse that as boolean false, which is why the existing
commit.gpgsign entry works, but it silently shadows file-scope values.

If the flake ever recurs, runTestRepoCommand() now appends a
`git count-objects -v` + `git fsck` snapshot to the exception so the
failure shows what survived in the object store.

Refs #133

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVdCTd166nSKuhBsnKePM9
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

An error occurred during the review process. Please try again later.

📝 Walkthrough

Walkthrough

This PR disables Git auto-gc and auto-maintenance in test fixture repositories via PHPUnit environment variables and RepoTemplate initialization, adds object-store diagnostics (git count-objects, git fsck) appended to exceptions from failed repo commands, and adds documentation and tests validating both behaviors.

Changes

Fixture Repo Maintenance and Diagnostics

Layer / File(s) Summary
Disable auto-gc via env and template init
phpunit.xml, tests/Helpers/RepoTemplate.php
Adds GIT_CONFIG_KEY_1/2 and GIT_CONFIG_VALUE_1/2 for gc.auto/maintenance.auto in phpunit.xml (GIT_CONFIG_COUNT raised to 3), and RepoTemplate::path() sets the same config values during git init.
Append object-store diagnostics on command failure
tests/Helpers/InteractsWithTestRepositories.php
runTestRepoCommand() catches RuntimeException and rethrows with appended object-store state from a new describeRepositoryObjectStore() helper running git count-objects -v and git fsck --no-progress.
Tests and docs for the above
tests/Unit/Helpers/InteractsWithTestRepositoriesTest.php, tests/CLAUDE.md
New Pest tests assert gc.auto/maintenance.auto are disabled in fixture repos and that failures include object-store forensics; CLAUDE.md documents both behaviors.

Estimated code review effort: 2 (Simple) | ~12 minutes

Sequence Diagram(s)

sequenceDiagram
    participant Test
    participant InteractsWithTestRepositories
    participant Git

    Test->>InteractsWithTestRepositories: runTestRepoCommand()
    InteractsWithTestRepositories->>Git: execOrThrow(command)
    Git-->>InteractsWithTestRepositories: RuntimeException
    InteractsWithTestRepositories->>Git: describeRepositoryObjectStore() (count-objects, fsck)
    Git-->>InteractsWithTestRepositories: object store output
    InteractsWithTestRepositories-->>Test: RuntimeException with appended diagnostics
Loading

Possibly related issues

Possibly related PRs

  • fgilio/rfa#56: Both PRs modify the same test git-repository helper logic in tests/Helpers/InteractsWithTestRepositories.php around fixture/template setup and command execution.

Poem

A rabbit tends the git repo's soil,
No auto-gc to spoil the toil,
When commands fail, forensics appear,
Count-objects and fsck, crystal clear,
Fixture repos, calm and coiled. 🐇

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@fgilio
fgilio merged commit 5bed294 into main Jul 7, 2026
15 checks passed
@fgilio
fgilio deleted the claude/project-handoff-prep-hdfvjt branch July 7, 2026 19:13
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