Skip to content

Commit e8feb47

Browse files
author
Sergey
committed
fix(test): let the Dockerfile scan read the index inside CI's container
- the unit-test job runs in a container with the workspace bind-mounted, so the checkout is owned by another uid and git refused with exit 128 - scope safe.directory to the one invocation; no git config is written - carry git's stderr into the assertion so the next failure explains itself
1 parent cadc2c5 commit e8feb47

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

tests/src/unit/test_supply_chain_workflow_shape.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,34 @@ def _tracked_dockerfiles() -> set[Path]:
220220
nothing would let this guard pass while asserting about an empty set.
221221
"""
222222
listing = subprocess.run(
223-
["git", "-C", str(_REPO_ROOT), "ls-files", "-z", "Dockerfile", "*/Dockerfile"],
223+
[
224+
"git",
225+
# The unit-test job runs inside a container with the workspace
226+
# bind-mounted from the host, so the checkout is owned by a
227+
# different uid than the process and Git's dubious-ownership
228+
# check refuses to read the index at all. Scoped to this one
229+
# invocation; no Git config is written anywhere.
230+
"-c",
231+
"safe.directory=*",
232+
"-C",
233+
str(_REPO_ROOT),
234+
"ls-files",
235+
"-z",
236+
"Dockerfile",
237+
"*/Dockerfile",
238+
],
224239
capture_output=True,
225240
text=True,
226-
check=True,
227-
).stdout
228-
return {_REPO_ROOT / rel for rel in listing.split("\0") if rel}
241+
check=False,
242+
)
243+
# Carry Git's own stderr into the failure. ``check=True`` would raise
244+
# ``CalledProcessError`` naming only the exit status, which says nothing
245+
# about why Git refused.
246+
assert listing.returncode == 0, (
247+
"cannot enumerate tracked Dockerfiles, so this guard cannot run: "
248+
f"git exited {listing.returncode}: {listing.stderr.strip()}"
249+
)
250+
return {_REPO_ROOT / rel for rel in listing.stdout.split("\0") if rel}
229251

230252

231253
def test_python_runtime_automation_is_digest_only() -> None:

0 commit comments

Comments
 (0)