Harden signed feeds and RelWithDebInfo releases
Modular container CI / release-build (push) Has been cancelled

This commit is contained in:
faumaray committed 2026-08-01 18:02:55 +03:00
1 parent 5b2d27a1e8
commit 8ac39621fd
21 files changed
+243 -40

No files matched your search

@@ -4,9 +4,11 @@
from __future__ import annotations
import base64
import importlib.util
import json
import os
from pathlib import Path
import shutil
import subprocess
import tempfile
import unittest
@@ -86,6 +88,36 @@ class IndependentComponentReleaseTests(unittest.TestCase):
def tearDown(self) -> None:
self.temporary.cleanup()
def test_component_elf_requires_debug_information(self) -> None:
compiler = shutil.which("cc")
if compiler is None:
self.skipTest("C compiler is unavailable")
specification = importlib.util.spec_from_file_location(
"echoion_package_component", PACKAGE
)
self.assertIsNotNone(specification)
self.assertIsNotNone(specification.loader)
module = importlib.util.module_from_spec(specification)
specification.loader.exec_module(module)
package_root = self.root / "elf-stage"
package_root.mkdir()
source = self.root / "fixture.c"
executable = package_root / "fixture"
source.write_text("int main(void) { return 0; }\n")
subprocess.run(
[compiler, "-O2", "-g0", str(source), "-o", str(executable)],
check=True,
)
with self.assertRaisesRegex(SystemExit, "has no debug information"):
module.require_debug_information(package_root)
subprocess.run(
[compiler, "-O2", "-g", str(source), "-o", str(executable)],
check=True,
)
module.require_debug_information(package_root)
def package(self, component: str, package_id: str, version: str) -> tuple[Path, Path]:
package_root = self.root / f"stage-{component}"
package_root.mkdir()
@@ -111,6 +143,8 @@ class IndependentComponentReleaseTests(unittest.TestCase):
"git-sha1:" + ("3" if component == "EchoionApi" else "4") * 40,
"--abi-hash",
"sha256:" + ("5" if component == "EchoionApi" else "6") * 64,
"--build-type",
"RelWithDebInfo",
],
check=False,
text=True,
@@ -169,9 +203,17 @@ class IndependentComponentReleaseTests(unittest.TestCase):
@staticmethod
def payload(path: Path) -> dict[str, object]:
envelope = json.loads(path.read_text())
encoded = envelope["payload"]
if envelope["schemaVersion"] == 3:
encoded = envelope["signedPayload"]
document = envelope["document"]
else:
encoded = envelope["payload"]
document = None
raw = base64.urlsafe_b64decode(encoded + "=" * (-len(encoded) % 4))
return json.loads(raw)
payload = json.loads(raw)
if document is not None and document != payload:
raise AssertionError("readable document differs from signed payload")
return payload
def test_single_component_publication_merges_catalog(self) -> None:
api_manifest, api_archive = self.package(
@@ -206,6 +248,7 @@ class IndependentComponentReleaseTests(unittest.TestCase):
):
self.assertNotIn(private_field, api)
self.assertEqual(api["productCompatibility"], ">=2.0.0 <3.0.0")
self.assertEqual(api["buildType"], "RelWithDebInfo")
self.assertEqual(
api["artifact"]["url"],
"https://downloads.example.test/components/"