Pin the website publication toolchain
This commit is contained in:
@@ -22,13 +22,64 @@ from govoplan_release.publisher import ( # noqa: E402
|
||||
publication_mutation_trust_issues,
|
||||
publish_catalog_candidate,
|
||||
remote_publication_identity,
|
||||
run_checked,
|
||||
verify_committed_publication,
|
||||
verify_remote_branch_head,
|
||||
verify_remote_publication,
|
||||
_trusted_npm_command,
|
||||
)
|
||||
|
||||
|
||||
class ReleaseCatalogPublicationTests(unittest.TestCase):
|
||||
def test_build_command_uses_its_pinned_node_directory(self) -> None:
|
||||
completed = subprocess.CompletedProcess(
|
||||
["/trusted/node/bin/npm"],
|
||||
0,
|
||||
stdout=b"",
|
||||
stderr=b"",
|
||||
)
|
||||
with patch(
|
||||
"govoplan_release.publisher.subprocess.run",
|
||||
return_value=completed,
|
||||
) as runner:
|
||||
run_checked(
|
||||
["/trusted/node/bin/npm", "run", "build"],
|
||||
cwd=Path("/trusted/website"),
|
||||
)
|
||||
|
||||
environment = runner.call_args.kwargs["env"]
|
||||
self.assertEqual(
|
||||
"/trusted/node/bin:/usr/bin:/bin",
|
||||
environment["PATH"],
|
||||
)
|
||||
|
||||
def test_npm_command_requires_trusted_npm_and_sibling_node(self) -> None:
|
||||
with (
|
||||
patch(
|
||||
"govoplan_release.publisher.shutil.which",
|
||||
return_value="/trusted/node/bin/npm",
|
||||
),
|
||||
patch(
|
||||
"govoplan_release.publisher._trusted_runtime_executable_issue",
|
||||
side_effect=(None, None),
|
||||
) as trust_check,
|
||||
):
|
||||
self.assertEqual(
|
||||
"/trusted/node/bin/npm",
|
||||
_trusted_npm_command("npm"),
|
||||
)
|
||||
|
||||
self.assertEqual(Path("/trusted/node/bin/npm"), trust_check.call_args_list[0].args[0])
|
||||
self.assertEqual(Path("/trusted/node/bin/node"), trust_check.call_args_list[1].args[0])
|
||||
|
||||
def test_npm_command_rejects_caller_relative_path(self) -> None:
|
||||
with (
|
||||
patch("govoplan_release.publisher.shutil.which") as which,
|
||||
self.assertRaisesRegex(RuntimeError, "absolute path or the bare name"),
|
||||
):
|
||||
_trusted_npm_command("./npm")
|
||||
which.assert_not_called()
|
||||
|
||||
def test_committed_publication_must_match_validated_blobs_exactly(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
web_root = Path(tmp) / "website"
|
||||
|
||||
Reference in New Issue
Block a user