Harden git test fixtures against auto-gc flakes - #135
Conversation
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
|
Caution Review failedAn error occurred during the review process. Please try again later. 📝 WalkthroughWalkthroughThis 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. ChangesFixture Repo Maintenance and Diagnostics
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
Possibly related issues
Possibly related PRs
Poem A rabbit tends the git repo's soil, 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. Comment |
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.gc.auto/maintenance.autotwice over: viaGIT_CONFIG_*env inphpunit.xml(covers every git invocation from test processes, including ad-hocgit initrepos) and baked into theRepoTemplate.git/config(covers copied fixtures even when git runs in a child process with a sanitized environment).runTestRepoCommand()now appends agit count-objects -v+git fscksnapshot 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-existingcommit.gpgsignentry 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 inphpunit.xmlandtests/CLAUDE.md.Testing
tests/Unit/Helpers/InteractsWithTestRepositoriesTest.php(gc-off config on copied fixtures; forensics appended to failed repo commands)--parallel: 1655 passedRefs #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
Documentation
Tests