ci(dagger): give the mounted tree a git index

The dagger job mounts the checkout without `.git` (excluded from the synced
directory), and eleven tests need it. The detection-core final gate and
ten tests in the migration files list tracked Python files with
`git ls-files` under check=True, so in run 45352669096 each failed for
want of that index soon after it started, while the job's 52 performance
tests passed.

The container now trusts the worktree, which can be owned by another user
than the container's, and builds an index of the mounted tree before uv
runs. In python:3.11-bookworm the final gate then passes (1 passed in
358 s) and the index holds the same 1031 Python files as on the host;
without the index the final gate fails in 12 s.
This commit is contained in:
Marius Ciepluch
2026-11-24 20:40:48 +01:00
parent 53a68907ea
commit 75233fdf14
+6
View File
@@ -44,6 +44,12 @@ async def _run_checks() -> None:
.from_("python:3.11-bookworm")
.with_directory("/src", source)
.with_workdir("/src")
# The mounted tree carries no `.git` (excluded above), and tests that enumerate tracked
# files, such as the detection-core migration gate, need an index: give them this tree's.
# The tree can be owned by another user than the container's, so git must trust it first.
.with_exec(["git", "config", "--system", "--add", "safe.directory", "/src"])
.with_exec(["git", "init", "-q"])
.with_exec(["git", "add", "-A"])
.with_exec(["python", "-m", "pip", "install", "uv"])
# uv run re-syncs the environment to the lockfile's default extras unless told not to, which silently
# removed the extras below before pytest ran.