Skip to content

fix(test): skip .git in placeholder scans to dodge background repack - #1816

Merged
c-vigo merged 2 commits into
devfrom
bugfix/1815-placeholder-scan-git-race
Oct 5, 2026
Merged

c-vigo merged 2 commits into
devfrom
bugfix/1815-placeholder-scan-git-race

Conversation

@c-vigo

@c-vigo c-vigo commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes the intermittent FileNotFoundError on a .git/objects/ path in the placeholder-scan integration tests. Seen on PR #1812, run 37247340361.

Root cause (full RCA in #1815 comment):

  • The install.sh scaffold commit spawns a detached git maintenance run --auto.
  • Under the git ≥2.54 default geometric strategy, that job sometimes repacks and deletes every loose object ~200–400 ms after the commit, depending on content.
  • That window overlaps the first tests of the class, whose lazy rglob("*") walks into .git/objects/.

Type of Change

  • feat -- New feature
  • fix -- Bug fix
  • docs -- Documentation only
  • chore -- Maintenance task (deps, config, etc.)
  • refactor -- Code restructuring (no behavior change)
  • test -- Adding or updating tests
  • ci -- CI/CD pipeline changes
  • build -- Build system or dependency changes
  • revert -- Reverts a previous commit
  • style -- Code style (formatting, whitespace)

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

  • tests/conftest.py: new scaffold_files(root, excluded_dirs=()) returns a sorted list of the workspace's regular files and skips .git/. Git internals never hold a placeholder, and the materialized list means no caller iterates a live walk.
  • tests/test_install_script.py: test_install_replaces_placeholder now uses the helper. test_install_replaces_org_name_placeholder is deleted; it duplicated the parametrized {{ORG_NAME}} case, and it was the test that failed.
  • tests/test_integration.py: test_placeholders_replaced now uses the helper (keeping its .pre-commit-cache / .ruff_cache exclusions). Its workspace also gets commits, so it was exposed to the same race.
  • tests/test_scaffold_files.py: unit tests for the helper. They run in Project Tests, so the guard does not depend on the image-backed jobs.
  • install.sh is unchanged. The background repack is correct for real consumer repos.

Changelog Entry

No changelog needed: test-only change with no user-visible impact.

Testing

  • Tests pass locally (just test)
  • Manual testing performed (describe below)

Manual Testing Details

  • TDD: tests/test_scaffold_files.py committed RED first (ImportError), then GREEN (2 passed).
  • uv run pytest tests/test_install_script.py tests/test_integration.py::TestPlaceholders against the local :dev image: 19 passed.
  • Race reproduced locally with git 2.55.0. The scaffold commit plus one extra blob in objects/17/ goes from 162 loose / 0 packs to 0 loose / 1 pack within 400 ms. The race itself is nondeterministic, so it has no deterministic red test; the helper's .git exclusion is the regression guard.
  • just precommit (full suite): green.

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 (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Not done: disabling maintenance in the fixtures (-c maintenance.auto=false). Skipping .git already removes the race, and the fixtures keep real-install behaviour.

Refs: #1815

@c-vigo
c-vigo enabled auto-merge October 5, 2026 06:55
@c-vigo
c-vigo merged commit 3aa23c6 into dev Oct 5, 2026
16 checks passed
@c-vigo
c-vigo deleted the bugfix/1815-placeholder-scan-git-race branch October 5, 2026 06:59
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