Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions qualification/php-linux-bootstrap.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@
370
]
},
"mirror": null
"mirror": {
"repository": "durable-workflow/php-archives",
"release_tag": "php-sha256-115f855a722d95ce",
"id": 768749741,
"name": "php_8.3-nts+ubuntu24.04.tar.zst",
"size": 42620774,
"digest": "sha256:115f855a722d95ce592032a58bf25d8d622d4b266ab476bf7e6f2f2f75b6aac4"
}
},
{
"os": "ubuntu",
Expand All @@ -67,7 +74,14 @@
390
]
},
"mirror": null
"mirror": {
"repository": "durable-workflow/php-archives",
"release_tag": "php-sha256-07e4b1bf60b6ddf0",
"id": 768751028,
"name": "php_8.3-nts+ubuntu26.04.tar.zst",
"size": 42104271,
"digest": "sha256:07e4b1bf60b6ddf01db7801266dc1a59ac79c774abb65d976c37e0188da5c32a"
}
}
]
}
17 changes: 16 additions & 1 deletion tests/test_php_archive_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,22 @@ def test_mirror_with_different_bytes_or_a_foreign_redirect_refuses(self):
def test_unmirrored_rows_keep_the_exact_upstream_fetch(self):
catalog = bootstrap.load_catalog()
row = catalog["archives"][0]
self.assertIsNone(row["mirror"])
row["mirror"] = None
catalog = bootstrap.validate_catalog(catalog)
self.assertEqual((bootstrap.REPOSITORY, row["asset"]), bootstrap.fetch_location(row["asset"], catalog))

def test_committed_setup_rows_fetch_only_their_immutable_mirror_release(self):
catalog = bootstrap.load_catalog()
for release, row in bootstrap.setup_rows(catalog).items():
mirrored = row["mirror"]
with self.subTest(release=release):
self.assertEqual(mirror.release_tag(row), mirrored["release_tag"])
self.assertEqual({key: row["asset"][key] for key in ("name", "size", "digest")},
{key: mirrored[key] for key in ("name", "size", "digest")})
self.assertNotEqual(row["asset"]["id"], mirrored["id"])
self.assertEqual((bootstrap.MIRROR_REPOSITORY, {key: mirrored[key] for key in ("id", "name", "size", "digest")}),
bootstrap.fetch_location(row["asset"], catalog))

def test_catalog_refuses_a_mirror_that_differs_from_its_upstream_bytes(self):
catalog, row = mirrored_catalog(b"bytes")
for field, value in (("digest", "sha256:" + "0" * 64), ("size", 6), ("name", "other.tar.zst"),
Expand Down Expand Up @@ -130,6 +143,8 @@ def test_plan_is_a_dry_run_that_inspects_exact_local_bytes(self):

def test_adopt_binds_only_a_published_immutable_release_with_identical_assets(self):
catalog = bootstrap.load_catalog()
for unbound in catalog["archives"]:
unbound["mirror"] = None
row = catalog["archives"][1]
tag = mirror.release_tag(row)
release = {"tag_name": tag, "draft": False, "immutable": True, "assets": [
Expand Down
6 changes: 5 additions & 1 deletion tests/test_php_linux_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def test_effect_uses_the_sealed_original_after_its_path_is_replaced(self):
row = next(value for value in catalog['archives'] if value == self.row)
payload = b'inert archive, never extracted'
row['asset'] = self.identity(row['asset']['name'], payload, row['asset']['id'])
row['mirror'] = None
derived = bootstrap.no_apt_installer_source(self.original, catalog)
script_id = self.identity('bound-install.sh', derived, catalog['installer']['id'])
environment = bootstrap.clean_environment({}, '/tmp/inert-source-home')
Expand Down Expand Up @@ -358,6 +359,7 @@ def test_effect_primitive_uses_exact_sealed_inputs_and_already_closed_parent(sel
catalog = copy.deepcopy(self.catalog)
row = next(row for row in catalog["archives"] if row == self.row)
row["asset"] = self.identity(row["asset"]["name"], data, row["asset"]["id"])
row["mirror"] = None
derived = bootstrap.installer_source(self.original, catalog)
script_id = self.identity("bound-install.sh", derived, catalog["installer"]["id"])
environment = bootstrap.clean_environment({}, "/tmp/private-home")
Expand Down Expand Up @@ -390,6 +392,7 @@ def test_normalized_effect_handoff_passes_only_the_sealed_derived_fd_to_an_inert
catalog = copy.deepcopy(self.catalog)
row = next(row for row in catalog['archives'] if row == self.row)
row['asset'] = identity
row['mirror'] = None
derived = bootstrap.no_apt_installer_source(self.original, catalog)
script_id = self.identity('bound-install.sh', derived, catalog['installer']['id'])
environment = bootstrap.clean_environment({}, '/tmp/inert-no-apt-home')
Expand Down Expand Up @@ -424,6 +427,7 @@ def test_initial_effect_primitive_requires_the_exact_no_apt_derived_bytes(self):
catalog = copy.deepcopy(self.catalog)
row = next(row for row in catalog['archives'] if row == self.row)
row['asset'] = self.identity(row['asset']['name'], data, row['asset']['id'])
row['mirror'] = None
derived = bootstrap.no_apt_installer_source(self.original, catalog)
script_id = self.identity('bound-install.sh', derived, catalog['installer']['id'])
environment = bootstrap.clean_environment({}, '/tmp/inert-no-apt-home')
Expand Down Expand Up @@ -494,7 +498,7 @@ def test_replaced_archive_fails_with_its_candidate_and_profile_flag(self):
"digest": "sha256:" + "2" * 64, "updated_at": "2026-11-13T05:00:00Z"}, row["candidate"])
self.assertTrue(all(row["setup_profile"] for row in report["affected"]))
unprofiled = dict(self.catalog, archives=self.catalog["archives"] + [dict(
self.catalog["archives"][0], release="22.04",
self.catalog["archives"][0], release="22.04", mirror=None,
asset=dict(self.catalog["archives"][0]["asset"], id=5, name="php_8.3-nts+ubuntu22.04.tar.zst"))])
(row,) = self.pins.check(unprofiled, self.published())["affected"]
self.assertFalse(row["setup_profile"])
Expand Down
10 changes: 9 additions & 1 deletion tests/test_protected_policy_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ def mirrored(files: dict[str, bytes], github: FakeGitHub) -> dict[str, bytes]:
return {**files, data.CATALOG_PATH: (json.dumps(catalog, indent=2) + "\n").encode()}


def unmirrored(files: dict[str, bytes]) -> dict[str, bytes]:
"""A catalog whose setup rows have no mirror record (main before the mirror adoption)."""
catalog = json.loads(files[data.CATALOG_PATH])
for row in catalog["archives"]:
row["mirror"] = None
return {**files, data.CATALOG_PATH: (json.dumps(catalog, indent=2) + "\n").encode()}


def with_reviewed_setup_code(files: dict[str, bytes], github: FakeGitHub) -> dict[str, bytes]:
"""Main whose data reviews this checkout's setup code (as the seed entry does after merge)."""
probe = git_sha("setup code probe")
Expand Down Expand Up @@ -420,7 +428,7 @@ def test_new_bound_pin_must_already_be_on_main_and_bind_only_mirrored_archives(s
self.files = {**self.files, data.DATA_PATH: (json.dumps(document, indent=2) + "\n").encode()}
self.base = self.start(self.files, "b0" * 20)
unmerged = git_sha("unmerged")
self.github.commit(unmerged, self.files)
self.github.commit(unmerged, unmirrored(self.files))
with self.assertRaisesRegex(InputRefused, "already be a commit on protected main"):
self.gate(approve_pin(self.files, unmerged), "b1" * 20)
self.github.merged(unmerged, self.base)
Expand Down
4 changes: 3 additions & 1 deletion tests/test_setup_php_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ def fixture(self, root):
"INPUT_TOOLS": "composer:2.10.3,phpunit:11.5.57", "INPUT_COVERAGE": "none"})
catalog = json.loads(bootstrap.CATALOG.read_text())
host = dict(operating_system="ubuntu", release="26.04", architecture="x86_64")
archive = bootstrap.select(catalog, **host, php="8.3")["asset"]
selected = bootstrap.select(catalog, **host, php="8.3")
archive = selected["asset"]
archive_bytes, _identity, selected_profile, _raw = normalize_tests.PhpLinuxNormalizeTest().fixture()
archive.update(size=len(archive_bytes), digest="sha256:" + bootstrap.sha256(archive_bytes))
selected["mirror"] = None # the synthetic archive has no mirror release
catalog_path = root / "catalog.json"
catalog_path.write_text(json.dumps(catalog))
calls = []
Expand Down
Loading