fix(release): complete publication evidence contract
This commit is contained in:
@@ -40,6 +40,8 @@ class RecordingRunner:
|
||||
self.commands.append((command, input_text, timeout))
|
||||
if self.fail_on and command[: len(self.fail_on)] == list(self.fail_on):
|
||||
raise subprocess.CalledProcessError(1, command)
|
||||
if command == ["git", "rev-parse", "HEAD"]:
|
||||
return image_release.Result(self.revision + "\n")
|
||||
if command[:2] == ["docker", "load"]:
|
||||
return image_release.Result(f"Loaded image: {self.loaded_image}\n")
|
||||
if command[:3] == ["docker", "image", "inspect"] and "{{.Id}}" in command:
|
||||
@@ -110,6 +112,21 @@ def test_invalid_source_commit_is_rejected(commit):
|
||||
image_release.release_tags(commit, "push", "refs/tags/v1.2.3")
|
||||
|
||||
|
||||
def test_verify_checkout_requires_exact_git_head_match():
|
||||
runner = RecordingRunner()
|
||||
|
||||
assert image_release.verify_checkout(COMMIT, runner) == COMMIT
|
||||
assert runner.commands == [(["git", "rev-parse", "HEAD"], None, None)]
|
||||
|
||||
|
||||
def test_verify_checkout_mismatch_fails_closed():
|
||||
runner = RecordingRunner(revision="c" * 40)
|
||||
|
||||
with pytest.raises(ValueError, match="checked out HEAD does not match source commit"):
|
||||
image_release.verify_checkout(COMMIT, runner)
|
||||
assert runner.commands == [(["git", "rev-parse", "HEAD"], None, None)]
|
||||
|
||||
|
||||
def test_smoke_uses_exact_isolated_probes_and_cleans_containers():
|
||||
runner = RecordingRunner()
|
||||
image_release.smoke_image("candidate", runner, timeout=17, migration_dir=MIGRATION_DIR)
|
||||
@@ -348,7 +365,7 @@ def test_record_image_id_writes_strict_inspected_id(tmp_path):
|
||||
]
|
||||
|
||||
|
||||
def test_valid_publish_records_digest_only_after_push(tmp_path):
|
||||
def test_valid_publish_records_exact_release_evidence_only_after_push(tmp_path):
|
||||
archive, checksum, image_id = _artifact(tmp_path)
|
||||
output = tmp_path / "output"
|
||||
summary = tmp_path / "summary"
|
||||
@@ -373,9 +390,19 @@ def test_valid_publish_records_digest_only_after_push(tmp_path):
|
||||
assert commands.index(["docker", "load"]) < commands.index(["docker", "login"])
|
||||
assert commands.count(["docker", "push"]) == 2
|
||||
assert digest == DIGEST
|
||||
assert f"digest={DIGEST}" in output.read_text()
|
||||
assert COMMIT in output.read_text()
|
||||
assert f"{image_release.IMAGE}@{DIGEST}" in summary.read_text()
|
||||
assert output.read_text() == (
|
||||
f"image={image_release.IMAGE}@{DIGEST}\n"
|
||||
f"digest={DIGEST}\n"
|
||||
f"source_commit={COMMIT}\n"
|
||||
"version_tag=v2.0.0\n"
|
||||
)
|
||||
assert summary.read_text() == (
|
||||
"## Published trex-core image\n\n"
|
||||
f"- Image: `{image_release.IMAGE}@{DIGEST}`\n"
|
||||
f"- Digest: `{DIGEST}`\n"
|
||||
f"- Source commit: `{COMMIT}`\n"
|
||||
"- Version tag: `v2.0.0`\n"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("bad_digest", ["", "sha256:" + "b" * 63, "sha512:" + "b" * 64])
|
||||
|
||||
Reference in New Issue
Block a user