summaryrefslogtreecommitdiff
path: root/.github/scripts/tests
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-09-26 23:24:03 +0200
committerChristoph Berg <myon@debian.org>2026-09-26 23:24:03 +0200
commit059831534c7e884f0a607ed86b582fd00d821731 (patch)
tree76bcb67a78f8aa2654fd34c2ad801a62136b0170 /.github/scripts/tests
parentd83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff)
New upstream version 3.2.0~rc1+dfsgupstream/3.2.0_rc1+dfsg
Diffstat (limited to '.github/scripts/tests')
-rw-r--r--.github/scripts/tests/test_armhf_ci_manifest.py90
-rw-r--r--.github/scripts/tests/test_armhf_cross_configuration.py176
-rw-r--r--.github/scripts/tests/test_armhf_static_ldd.py123
-rw-r--r--.github/scripts/tests/test_armhf_sysroot_symlinks.py42
-rw-r--r--.github/scripts/tests/test_check_candidate_tag.py81
-rwxr-xr-x.github/scripts/tests/test_ghcr_retention.py143
-rw-r--r--.github/scripts/tests/test_linux_artifact_validation.py230
-rw-r--r--.github/scripts/tests/test_linux_ccache_policy.py99
-rw-r--r--.github/scripts/tests/test_linux_image_publication_policy.py181
-rw-r--r--.github/scripts/tests/test_release_policy.py383
-rwxr-xr-x.github/scripts/tests/test_resolve_linux_ci_image_tag.py125
-rw-r--r--.github/scripts/tests/test_should_refresh_linux_ci_images.py63
12 files changed, 1736 insertions, 0 deletions
diff --git a/.github/scripts/tests/test_armhf_ci_manifest.py b/.github/scripts/tests/test_armhf_ci_manifest.py
new file mode 100644
index 00000000..c438d62d
--- /dev/null
+++ b/.github/scripts/tests/test_armhf_ci_manifest.py
@@ -0,0 +1,90 @@
+import hashlib
+import os
+import pathlib
+import subprocess
+import tempfile
+import unittest
+
+
+ROOT = pathlib.Path(__file__).resolve().parents[3]
+WRITER = ROOT / ".github/scripts/write-armhf-ci-manifest.sh"
+
+
+class ArmhfCiManifestTests(unittest.TestCase):
+ def test_runtime_manifest_preserves_requested_image_identity(self):
+ with tempfile.TemporaryDirectory() as temporary:
+ fixture = pathlib.Path(temporary)
+ config = fixture / "config"
+ output = fixture / "output"
+ runtime = fixture / "runtime"
+ fixture_bin = fixture / "bin"
+ config.mkdir()
+ output.mkdir()
+ runtime.mkdir()
+ fixture_bin.mkdir()
+
+ dpkg_query = fixture_bin / "dpkg-query"
+ dpkg_query.write_text(
+ "#!/bin/sh\nprintf '%s\\n' fixture-package=1.0\n",
+ encoding="utf-8",
+ )
+ dpkg_query.chmod(0o755)
+
+ library = runtime / "libgcc_s.so.1"
+ library.write_bytes(b"fixture GCC runtime\n")
+ library_sha = hashlib.sha256(library.read_bytes()).hexdigest()
+ runtime_records = f"libgcc_s.so.1={library_sha}\n".encode()
+ runtime_sha = hashlib.sha256(runtime_records).hexdigest()
+
+ (config / "armhf-ci-image-config.sh").write_text(
+ "ARMHF_CI_IMAGE_SCHEMA=1\n"
+ f"ARMHF_RUNTIME_PREFIX={runtime}\n"
+ "ARMHF_GCC_RUNTIME_LIBRARIES=(libgcc_s.so.1)\n"
+ "ARMHF_GLIBC_VERSION=2.36\n",
+ encoding="utf-8",
+ )
+ (config / "cross-builder.env").write_text(
+ "role=cross-builder\n"
+ "generation=build-20260901-10-1\n"
+ f"recipe_sha256={'1' * 64}\n"
+ "toolchain_id=gcc13.4.0-armhf-fixture\n"
+ f"runtime_sha256={runtime_sha}\n"
+ "hamlib_ref=4.7.2\n"
+ f"hamlib_commit={'2' * 40}\n",
+ encoding="utf-8",
+ )
+
+ environment = os.environ.copy()
+ environment.update(
+ PATH=f"{fixture_bin}:{environment['PATH']}",
+ WSJTX_ARMHF_CONFIG_DIR=str(config),
+ WSJTX_CI_MANIFEST_DIR=str(output),
+ )
+ subprocess.run(
+ [
+ str(WRITER),
+ "runtime",
+ "armhf",
+ "build-20260901-20-1",
+ "3" * 64,
+ ],
+ cwd=ROOT,
+ env=environment,
+ check=True,
+ )
+
+ fields = dict(
+ line.split("=", 1)
+ for line in (output / "image.env").read_text().splitlines()
+ )
+ self.assertEqual(fields["role"], "runtime")
+ self.assertEqual(fields["architecture"], "armhf")
+ self.assertEqual(fields["generation"], "build-20260901-20-1")
+ self.assertEqual(fields["recipe_sha256"], "3" * 64)
+ self.assertEqual(fields["cross_generation"], "build-20260901-10-1")
+ self.assertEqual(fields["cross_recipe_sha256"], "1" * 64)
+ self.assertEqual(fields["runtime_sha256"], runtime_sha)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/.github/scripts/tests/test_armhf_cross_configuration.py b/.github/scripts/tests/test_armhf_cross_configuration.py
new file mode 100644
index 00000000..0893e99a
--- /dev/null
+++ b/.github/scripts/tests/test_armhf_cross_configuration.py
@@ -0,0 +1,176 @@
+import pathlib
+import unittest
+
+
+ROOT = pathlib.Path(__file__).resolve().parents[3]
+
+
+class ArmhfCrossConfigurationTests(unittest.TestCase):
+ def read(self, relative_path):
+ return (ROOT / relative_path).read_text(encoding="utf-8")
+
+ def test_cross_toolchain_pins_armv7_hard_float_and_bookworm_abi(self):
+ config = self.read(".github/images/linux-ci/armhf-cross-toolchain.config")
+ for setting in (
+ "CT_ARCH_ARM=y",
+ "CT_ARCH_ARM_MODE_THUMB=y",
+ 'CT_ARCH_ARCH="armv7-a+fp"',
+ "CT_ARCH_FLOAT_HW=y",
+ "CT_LINUX_V_6_1=y",
+ "CT_BINUTILS_V_2_40=y",
+ "CT_GLIBC_V_2_36=y",
+ 'CT_GLIBC_MIN_KERNEL_VERSION="3.2.0"',
+ "CT_GCC_V_13=y",
+ "CT_CC_GCC_LIBGOMP=y",
+ "CT_CC_LANG_CXX=y",
+ "CT_CC_LANG_FORTRAN=y",
+ "CT_PARALLEL_JOBS=1",
+ 'CT_TARGET_CFLAGS="-g0"',
+ ):
+ self.assertIn(setting, config)
+ self.assertNotIn("CT_CC_GCC_LIBQUADMATH=y", config)
+
+ image_config = self.read(".github/scripts/armhf-ci-image-config.sh")
+ self.assertIn("ARMHF_GCC_VERSION=13.4.0", image_config)
+ self.assertIn("ARMHF_GLIBC_VERSION=2.36", image_config)
+ self.assertIn("ARMHF_TARGET_TRIPLET=arm-linux-gnueabihf", image_config)
+
+ verifier = self.read(".github/scripts/verify-armhf-ci-image.sh")
+ audit = self.read(".github/scripts/audit-armhf-cross-build.sh")
+ self.assertIn("reject_quadmath_dependency", verifier)
+ self.assertIn("unexpectedly depends on libquadmath", audit)
+ self.assertIn("reject_private_glibc_dependency", verifier)
+ self.assertIn("private glibc symbol", audit)
+
+ def test_armhf_cache_identity_parsing_fails_closed(self):
+ workflow = self.read(".github/workflows/build-linux.yml")
+ self.assertIn(
+ '''ccache_compatibility_id=$(awk -F= '$1 == "cross_ccache_compatibility_id" { print $2 }' "$output_file")''',
+ workflow,
+ )
+ self.assertIn(
+ 'if [ -z "$ccache_compatibility_id" ] || '
+ '[ -z "$ccache_compiler_check" ]; then',
+ workflow,
+ )
+ self.assertNotIn('\\"cross_ccache_compatibility_id\\"', workflow)
+
+ def test_armhf_qemu_registration_uses_one_immutable_release(self):
+ expected = (
+ "image: tonistiigi/binfmt:qemu-v10.2.3-68@sha256:"
+ "400a4873b838d1b89194d982c45e5fb3cda4593fbfd7e08a02e76b03b21166f0"
+ )
+ for path in (
+ ".github/workflows/build-linux.yml",
+ ".github/workflows/publish-linux-ci-images.yml",
+ ):
+ self.assertIn(expected, self.read(path))
+
+ def test_cmake_separates_host_programs_from_target_dependencies(self):
+ toolchain = self.read(".github/cmake/armhf-toolchain.cmake")
+ self.assertIn("set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)", toolchain)
+ self.assertIn("set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)", toolchain)
+ self.assertIn("set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)", toolchain)
+ self.assertIn("set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)", toolchain)
+ self.assertIn("set(_wsjt_armhf_triplet arm-linux-gnueabihf)", toolchain)
+ self.assertIn("${_wsjt_armhf_triplet}-gfortran", toolchain)
+ self.assertIn("set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE armhf", toolchain)
+ self.assertIn("set(CPACK_RPM_PACKAGE_ARCHITECTURE armv7l", toolchain)
+
+ dependencies = self.read("CMake/Dependencies.cmake")
+ self.assertIn("WSJT_QT_HOST_PATH", dependencies)
+ self.assertIn("IMPORTED_LOCATION", dependencies)
+
+ def test_builder_and_runtime_keep_distinct_native_architectures(self):
+ builder = self.read(".github/images/linux-ci/Dockerfile.armhf-cross")
+ runtime = self.read(".github/images/linux-ci/Dockerfile.armhf-runtime")
+ self.assertTrue(builder.startswith("FROM debian:bookworm\n"))
+ self.assertIn("--architectures=armhf", builder)
+ self.assertIn("qemu-user-static", builder)
+ self.assertIn("normalize-armhf-sysroot-symlinks.sh", builder)
+ self.assertIn("tail -n 300 build.log", builder)
+ self.assertIn("ARG CROSS_BUILDER_PLATFORM=linux/amd64", runtime)
+ self.assertIn(
+ "FROM --platform=${CROSS_BUILDER_PLATFORM} ${CROSS_BUILDER_IMAGE}",
+ runtime,
+ )
+ self.assertIn("FROM arm32v7/debian:bookworm", runtime)
+ self.assertIn("install-armhf-runtime-packages", runtime)
+ self.assertIn(
+ "COPY --from=cross_builder /usr/bin/qemu-arm-static", runtime
+ )
+
+ cross_build = self.read(".github/scripts/build-linux-armhf-cross.sh")
+ runtime_package = self.read(".github/scripts/package-linux-armhf.sh")
+ self.assertNotIn("qemu", cross_build.lower())
+ self.assertIn("cmake --install wsjtx-build", cross_build)
+ self.assertIn("cpack -G DEB", runtime_package)
+ self.assertIn("cpack -G RPM", runtime_package)
+ self.assertIn("CPACK_INSTALL_CMAKE_PROJECTS=", runtime_package)
+ self.assertIn("CPACK_INSTALLED_DIRECTORIES=/work/AppDir;/", runtime_package)
+ self.assertIn('"$ARMHF_QEMU_EXECUTABLE"', runtime_package)
+ self.assertIn(
+ 'LINUX_APPIMAGE_RUNNER="$ARMHF_QEMU_EXECUTABLE"', runtime_package
+ )
+ self.assertIn("armhf-static-ldd.sh", runtime_package)
+ self.assertIn('PATH="/work/wsjtx-build/appimage-tools:$PATH"', runtime_package)
+
+ def test_hybrid_is_the_only_armhf_build_implementation(self):
+ workflow = self.read(".github/workflows/build-linux.yml")
+ native_action = self.read(
+ ".github/actions/build-linux-payload/action.yml"
+ )
+ self.assertFalse(
+ (ROOT / ".github/scripts/build-linux-payload.sh").exists()
+ )
+ self.assertNotIn("build-linux-payload.sh", workflow)
+ self.assertEqual(workflow.count("build-linux-armhf-cross.sh"), 1)
+ self.assertIn("docker run --rm --platform linux/amd64", workflow)
+ self.assertNotIn("inputs.arch != 'armhf'", native_action)
+ self.assertNotIn("linuxdeploy-armhf", native_action)
+
+ def test_armhf_joins_only_the_opt_in_full_ci_matrix(self):
+ workflow = self.read(".github/workflows/ci.yml")
+ prepare = workflow.split(" prepare:\n", 1)[1].split("\n macos:\n", 1)[0]
+ armhf_job = workflow.split(" linux-armhf:\n", 1)[1].split(
+ "\n windows:\n", 1
+ )[0]
+
+ self.assertIn("RESOLVE_ARMHF=true", prepare)
+ self.assertIn("inputs.armhf_image_tag", prepare)
+ self.assertIn(
+ "contains(github.event.pull_request.labels.*.name, 'full-ci')",
+ armhf_job,
+ )
+ self.assertIn("github.event_name == 'workflow_dispatch'", armhf_job)
+ self.assertIn('arch: \"armhf\"', armhf_job)
+ self.assertIn(
+ "image_tag: ${{ needs.prepare.outputs.armhf_image_tag }}",
+ armhf_job,
+ )
+
+ def test_slow_decoder_timeouts_are_at_most_four_minutes(self):
+ jtty = self.read("tests/unit/jtty/CMakeLists.txt")
+ for test_name, timeout in (
+ ("test_jtty_adjacent_decode", 180),
+ ("test_jtty_structured_decode", 240),
+ ("test_jtty_overlap_decode", 180),
+ ("test_jtty_overlap_decode_480", 240),
+ ("test_jtty_windowed_decode", 180),
+ ("test_jtty_gap_merge", 180),
+ ("test_jtty_surface_ranges", 180),
+ ):
+ properties = jtty.split(
+ f"set_tests_properties ({test_name}", 1
+ )[1].split(")", 1)[0]
+ self.assertIn(f"TIMEOUT {timeout}", properties)
+
+ q65 = self.read("tests/unit/q65/CMakeLists.txt")
+ properties = q65.split(
+ "set_tests_properties (test_q65_decode_pipeline", 1
+ )[1].split(")", 1)[0]
+ self.assertIn("TIMEOUT 180", properties)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/.github/scripts/tests/test_armhf_static_ldd.py b/.github/scripts/tests/test_armhf_static_ldd.py
new file mode 100644
index 00000000..a1db1618
--- /dev/null
+++ b/.github/scripts/tests/test_armhf_static_ldd.py
@@ -0,0 +1,123 @@
+import os
+import pathlib
+import subprocess
+import tempfile
+import unittest
+
+
+ROOT = pathlib.Path(__file__).resolve().parents[3]
+VALIDATOR = ROOT / ".github/scripts/armhf-static-ldd.sh"
+
+
+class ArmhfStaticLddTests(unittest.TestCase):
+ def run_validator(self, needed, libraries, runpath=None, transitive=None):
+ with tempfile.TemporaryDirectory() as temporary:
+ fixture = pathlib.Path(temporary)
+ fixture_bin = fixture / "bin"
+ fixture_lib = fixture / "lib"
+ fixture_bin.mkdir()
+ fixture_lib.mkdir()
+ target = fixture / "program"
+ target.write_text("target\n", encoding="utf-8")
+
+ transitive = transitive or {}
+ dynamic_output = "".join(
+ f"printf '%s\\n' ' 0x00000001 (NEEDED) Shared library: [{library}]'\n"
+ for library in needed
+ )
+ if runpath is not None:
+ dynamic_output += (
+ "printf '%s\\n' ' 0x0000001d (RUNPATH) "
+ f"Library runpath: [{runpath}]'\n"
+ )
+ transitive_cases = "".join(
+ " *" + parent + "*)\n"
+ + "".join(
+ f" printf '%s\\n' ' 0x00000001 (NEEDED) Shared library: [{library}]'\n"
+ for library in dependencies
+ )
+ + " ;;\n"
+ for parent, dependencies in transitive.items()
+ )
+ (fixture_bin / "readelf").write_text(
+ "#!/bin/sh\n"
+ "case \"$*\" in\n"
+ + transitive_cases
+ + " *)\n"
+ + "".join(f" {line}\n" for line in dynamic_output.splitlines())
+ + " ;;\n"
+ "esac\n",
+ encoding="utf-8",
+ )
+ (fixture_bin / "file").write_text(
+ "#!/bin/sh\n"
+ "case \"$*\" in\n"
+ " *libhost.so*) echo \"$*: ELF 64-bit LSB shared object, x86-64\" ;;\n"
+ " *) echo \"$*: ELF 32-bit LSB shared object, ARM, EABI5\" ;;\n"
+ "esac\n",
+ encoding="utf-8",
+ )
+ for tool in (fixture_bin / "readelf", fixture_bin / "file"):
+ tool.chmod(0o755)
+ for library in libraries:
+ library_path = fixture_lib / library
+ library_path.parent.mkdir(parents=True, exist_ok=True)
+ library_path.write_text("fixture\n", encoding="utf-8")
+
+ environment = os.environ.copy()
+ environment.update(
+ PATH=f"{fixture_bin}:{environment['PATH']}",
+ WSJT_ARMHF_RUNTIME_PREFIX=str(fixture / "empty-runtime"),
+ ARMHF_STATIC_LDD_LIBRARY_PATH=str(fixture_lib),
+ )
+ return subprocess.run(
+ ["bash", str(VALIDATOR), str(target)],
+ cwd=ROOT,
+ env=environment,
+ text=True,
+ capture_output=True,
+ check=False,
+ )
+
+ def test_resolves_armhf_dependency_without_executing_target(self):
+ result = self.run_validator(["libfixture.so.1"], ["libfixture.so.1"])
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertIn("libfixture.so.1 => ", result.stdout)
+
+ def test_rejects_missing_dependency(self):
+ result = self.run_validator(["libmissing.so.1"], [])
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn("libmissing.so.1 => not found", result.stdout)
+
+ def test_rejects_quadmath_dependency(self):
+ result = self.run_validator(["libquadmath.so.0"], ["libquadmath.so.0"])
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn("unavailable ARMHF runtime", result.stderr)
+
+ def test_rejects_host_library(self):
+ result = self.run_validator(["libhost.so.1"], ["libhost.so.1"])
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn("non-ARMHF ELF", result.stderr)
+
+ def test_resolves_origin_relative_runpath(self):
+ result = self.run_validator(
+ ["libpulsecommon-fixture.so"],
+ ["pulseaudio/libpulsecommon-fixture.so"],
+ runpath="$ORIGIN/lib/pulseaudio",
+ )
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertIn("pulseaudio/libpulsecommon-fixture.so", result.stdout)
+
+ def test_resolves_transitive_dependency_closure(self):
+ result = self.run_validator(
+ ["libparent.so.1"],
+ ["libparent.so.1", "libchild.so.1"],
+ transitive={"libparent.so.1": ["libchild.so.1"]},
+ )
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertIn("libparent.so.1 => ", result.stdout)
+ self.assertIn("libchild.so.1 => ", result.stdout)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/.github/scripts/tests/test_armhf_sysroot_symlinks.py b/.github/scripts/tests/test_armhf_sysroot_symlinks.py
new file mode 100644
index 00000000..991971f6
--- /dev/null
+++ b/.github/scripts/tests/test_armhf_sysroot_symlinks.py
@@ -0,0 +1,42 @@
+import os
+import pathlib
+import subprocess
+import tempfile
+import unittest
+
+
+ROOT = pathlib.Path(__file__).resolve().parents[3]
+NORMALIZER = ROOT / ".github/scripts/normalize-armhf-sysroot-symlinks.sh"
+
+
+class ArmhfSysrootSymlinkTests(unittest.TestCase):
+ def test_absolute_links_are_rebased_inside_sysroot(self):
+ with tempfile.TemporaryDirectory() as temporary:
+ sysroot = pathlib.Path(temporary)
+ target = sysroot / "lib/arm-linux-gnueabihf/libm.so.6"
+ target.parent.mkdir(parents=True)
+ target.write_text("fixture\n", encoding="utf-8")
+ link = sysroot / "usr/lib/arm-linux-gnueabihf/libm.so"
+ link.parent.mkdir(parents=True)
+ link.symlink_to("/lib/arm-linux-gnueabihf/libm.so.6")
+
+ subprocess.run(["bash", str(NORMALIZER), str(sysroot)], check=True)
+
+ self.assertFalse(os.readlink(link).startswith("/"))
+ self.assertEqual(link.resolve(), target)
+
+ def test_relative_links_remain_unchanged(self):
+ with tempfile.TemporaryDirectory() as temporary:
+ sysroot = pathlib.Path(temporary)
+ directory = sysroot / "usr/lib"
+ directory.mkdir(parents=True)
+ link = directory / "libfixture.so"
+ link.symlink_to("libfixture.so.1")
+
+ subprocess.run(["bash", str(NORMALIZER), str(sysroot)], check=True)
+
+ self.assertEqual(os.readlink(link), "libfixture.so.1")
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/.github/scripts/tests/test_check_candidate_tag.py b/.github/scripts/tests/test_check_candidate_tag.py
new file mode 100644
index 00000000..cf44ccf4
--- /dev/null
+++ b/.github/scripts/tests/test_check_candidate_tag.py
@@ -0,0 +1,81 @@
+import subprocess
+import tempfile
+import unittest
+from pathlib import Path
+
+
+SCRIPT = Path(__file__).resolve().parents[1] / "check-candidate-tag.sh"
+TAG = "build/v3.2.0-rc1"
+
+
+class CheckCandidateTagTest(unittest.TestCase):
+ def setUp(self):
+ self.directory = tempfile.TemporaryDirectory()
+ self.addCleanup(self.directory.cleanup)
+ self.repo = Path(self.directory.name)
+ self.git("init", "-q")
+ self.git(
+ "-c", "user.name=Test", "-c", "user.email=test@example.com",
+ "commit", "--allow-empty", "-qm", "first",
+ )
+ self.first = self.git("rev-parse", "HEAD").stdout.strip()
+ self.git(
+ "-c", "user.name=Test", "-c", "user.email=test@example.com",
+ "commit", "--allow-empty", "-qm", "second",
+ )
+ self.second = self.git("rev-parse", "HEAD").stdout.strip()
+
+ def git(self, *args, input=None):
+ return subprocess.run(
+ ["git", *args], cwd=self.repo, input=input, text=True,
+ capture_output=True, check=True,
+ )
+
+ def check_tag(self, expected_sha=None, cwd=None):
+ return subprocess.run(
+ ["bash", SCRIPT, TAG, expected_sha or self.second],
+ cwd=cwd or self.repo, text=True, capture_output=True,
+ )
+
+ def test_missing_tag_allows_creation(self):
+ result = self.check_tag()
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertEqual(result.stdout, "exists=false\n")
+
+ def test_matching_lightweight_tag_is_idempotent(self):
+ self.git("tag", TAG, self.second)
+ result = self.check_tag()
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertEqual(result.stdout, "exists=true\n")
+
+ def test_matching_annotated_tag_is_idempotent(self):
+ self.git(
+ "-c", "user.name=Test", "-c", "user.email=test@example.com",
+ "tag", "-am", "candidate", TAG, self.second,
+ )
+ result = self.check_tag()
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertEqual(result.stdout, "exists=true\n")
+
+ def test_different_commit_is_rejected(self):
+ self.git("tag", TAG, self.first)
+ result = self.check_tag()
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn("release tags are never moved", result.stderr)
+
+ def test_noncommit_tag_is_rejected(self):
+ blob = self.git("hash-object", "-w", "--stdin", input="not a commit").stdout.strip()
+ self.git("update-ref", f"refs/tags/{TAG}", blob)
+ result = self.check_tag()
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn("does not identify a commit", result.stderr)
+
+ def test_git_failure_is_not_treated_as_missing_tag(self):
+ with tempfile.TemporaryDirectory() as directory:
+ result = self.check_tag(cwd=directory)
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn("Could not inspect", result.stderr)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/.github/scripts/tests/test_ghcr_retention.py b/.github/scripts/tests/test_ghcr_retention.py
new file mode 100755
index 00000000..9bffad2d
--- /dev/null
+++ b/.github/scripts/tests/test_ghcr_retention.py
@@ -0,0 +1,143 @@
+#!/usr/bin/env python3
+
+import importlib.util
+import sys
+import unittest
+from datetime import datetime, timedelta, timezone
+from pathlib import Path
+
+
+SCRIPT = Path(__file__).parents[1] / "ghcr_retention.py"
+SPEC = importlib.util.spec_from_file_location("ghcr_retention", SCRIPT)
+MODULE = importlib.util.module_from_spec(SPEC)
+sys.modules[SPEC.name] = MODULE
+SPEC.loader.exec_module(MODULE)
+
+
+def version(version_id, age_days, tags, now):
+ return MODULE.Version(
+ id=version_id,
+ digest=f"sha256:{version_id:064x}",
+ created_at=now - timedelta(days=age_days),
+ tags=tuple(tags),
+ )
+
+
+class RetentionPlanTests(unittest.TestCase):
+ def setUp(self):
+ self.now = datetime(2026, 8, 18, tzinfo=timezone.utc)
+
+ def plan(self, versions, keep=3):
+ return {
+ item.version.id: item
+ for item in MODULE.plan_retention(versions, self.now, 60, keep)
+ }
+
+ def test_deletes_only_expired_recognized_versions_outside_keep_set(self):
+ versions = [
+ version(1, 90, ("build-20260101-1-1",), self.now),
+ version(2, 10, ("build-20260808-2-1",), self.now),
+ version(3, 20, ("build-20260729-3-1",), self.now),
+ version(4, 30, ("build-20260719-4-1",), self.now),
+ ]
+ plan = self.plan(versions)
+ self.assertTrue(plan[1].delete)
+ self.assertFalse(plan[2].delete)
+ self.assertFalse(plan[3].delete)
+ self.assertFalse(plan[4].delete)
+
+ def test_stable_unknown_and_untagged_versions_are_protected(self):
+ versions = [
+ version(1, 100, ("stable", "build-20260101-1-1"), self.now),
+ version(2, 100, ("debug",), self.now),
+ version(3, 100, (), self.now),
+ ]
+ plan = self.plan(versions, keep=1)
+ self.assertEqual(plan[1].reason, "stable")
+ self.assertEqual(plan[2].reason, "unknown-or-untagged")
+ self.assertEqual(plan[3].reason, "unknown-or-untagged")
+
+ def test_exact_sixty_day_boundary_is_kept(self):
+ plan = self.plan([version(1, 60, ("candidate-1-1",), self.now)], keep=1)
+ self.assertFalse(plan[1].delete)
+
+ def test_equal_timestamps_use_id_as_tiebreaker(self):
+ versions = [
+ version(1, 90, ("candidate-1-1",), self.now),
+ version(2, 90, ("candidate-2-1",), self.now),
+ ]
+ plan = self.plan(versions, keep=1)
+ self.assertTrue(plan[1].delete)
+ self.assertFalse(plan[2].delete)
+
+ def test_nested_package_name_is_encoded(self):
+ path = MODULE.GitHubPackagesClient.package_path(
+ "WSJTX", "wsjtx-internal/linux-noble"
+ )
+ self.assertEqual(
+ path,
+ "/orgs/WSJTX/packages/container/wsjtx-internal%2Flinux-noble",
+ )
+
+ def test_malformed_version_fails_closed(self):
+ with self.assertRaises(ValueError):
+ MODULE.parse_version({"id": 1, "name": "sha256:x", "metadata": {}})
+
+
+class FakeClient:
+ def __init__(self, versions, refreshed=None):
+ self.versions = versions
+ self.refreshed = refreshed or {}
+ self.deleted = []
+
+ def list_versions(self, owner, package):
+ return list(self.versions)
+
+ def get_version(self, owner, package, version_id):
+ return self.refreshed.get(
+ version_id,
+ next(item for item in self.versions if item.id == version_id),
+ )
+
+ def delete_version(self, owner, package, version_id):
+ self.deleted.append(version_id)
+
+
+class RetentionApplicationTests(unittest.TestCase):
+ def setUp(self):
+ self.now = datetime(2026, 8, 18, tzinfo=timezone.utc)
+ self.versions = [
+ version(1, 100, ("candidate-1-1",), self.now),
+ version(2, 30, ("candidate-2-1",), self.now),
+ ]
+
+ def run_process(self, client, apply):
+ return MODULE.process_package(
+ client,
+ "WSJTX",
+ "wsjtx-internal/linux-noble",
+ self.now,
+ 60,
+ 1,
+ apply,
+ )
+
+ def test_dry_run_never_deletes(self):
+ client = FakeClient(self.versions)
+ self.assertEqual(self.run_process(client, False), 0)
+ self.assertEqual(client.deleted, [])
+
+ def test_apply_deletes_planned_version(self):
+ client = FakeClient(self.versions)
+ self.assertEqual(self.run_process(client, True), 1)
+ self.assertEqual(client.deleted, [1])
+
+ def test_refetch_protects_new_stable_tag(self):
+ stable = version(1, 100, ("stable", "candidate-1-1"), self.now)
+ client = FakeClient(self.versions, {1: stable})
+ self.assertEqual(self.run_process(client, True), 0)
+ self.assertEqual(client.deleted, [])
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/.github/scripts/tests/test_linux_artifact_validation.py b/.github/scripts/tests/test_linux_artifact_validation.py
new file mode 100644
index 00000000..655d0d24
--- /dev/null
+++ b/.github/scripts/tests/test_linux_artifact_validation.py
@@ -0,0 +1,230 @@
+import os
+import subprocess
+import tempfile
+import unittest
+from pathlib import Path
+
+
+REPO_ROOT = Path(__file__).resolve().parents[3]
+HELPER = REPO_ROOT / ".github/scripts/linux-artifact-validation.sh"
+
+
+class LinuxArtifactValidationTests(unittest.TestCase):
+ def run_helper(self, command, **environment):
+ env = os.environ.copy()
+ env["VALIDATION_HELPER"] = str(HELPER)
+ env.update({name: str(value) for name, value in environment.items()})
+ return subprocess.run(
+ ["bash", "-c", f'source "$VALIDATION_HELPER"; {command}'],
+ check=False,
+ capture_output=True,
+ env=env,
+ text=True,
+ )
+
+ def make_application_tree(self, kind="appimage"):
+ temporary = tempfile.TemporaryDirectory()
+ root = Path(temporary.name)
+ executables = ["wsjtx", "jt9", "qmap", "map65", "ft8code"]
+ if kind == "appimage":
+ executables.append("wsprd")
+ for executable in executables:
+ path = root / "usr/bin" / executable
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.touch(mode=0o755)
+ for relative in (
+ "usr/share/wsjtx/ALLCALL7.TXT",
+ "usr/share/wsjtx/CALL3.TXT",
+ "usr/share/wsjtx/sounds/Message.wav",
+ "usr/share/wsjtx/sounds/Testing123.wav",
+ ):
+ path = root / relative
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.touch()
+
+ if kind == "appdir":
+ for relative in (
+ "usr/share/applications/wsjtx.desktop",
+ "usr/share/pixmaps/wsjtx_icon.png",
+ ):
+ path = root / relative
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.touch()
+ else:
+ qt_conf = root / "usr/bin/qt.conf"
+ qt_conf.write_text("[Paths]\nPlugins = plugins\n", encoding="utf-8")
+ for relative in (
+ "usr/plugins/platforms/libqxcb.so",
+ "usr/plugins/sqldrivers/libqsqlite.so",
+ "usr/plugins/audio/libqtaudio_alsa.so",
+ "usr/lib/libQt5Core.so.5",
+ "usr/lib/libQt5Widgets.so.5",
+ "usr/lib/libQt5Multimedia.so.5",
+ ):
+ path = root / relative
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.touch()
+ return temporary, root
+
+ def test_package_manifest_accepts_expected_payload(self):
+ manifest = "\n".join(
+ (
+ "/usr/bin/wsjtx",
+ "/usr/bin/jt9",
+ "/usr/bin/qmap",
+ "/usr/bin/map65",
+ "/usr/share/wsjtx/ALLCALL7.TXT",
+ "/usr/share/wsjtx/CALL3.TXT",
+ "/usr/share/wsjtx/sounds/Message.wav",
+ "/usr/share/wsjtx/sounds/Testing123.wav",
+ )
+ )
+ result = self.run_helper(
+ 'validate_linux_package_manifest "$MANIFEST" fixture', MANIFEST=manifest
+ )
+ self.assertEqual(result.returncode, 0, result.stderr)
+
+ def test_package_manifest_rejects_missing_executable_data_or_sound(self):
+ required = [
+ "/usr/bin/wsjtx",
+ "/usr/bin/jt9",
+ "/usr/bin/qmap",
+ "/usr/bin/map65",
+ "/usr/share/wsjtx/ALLCALL7.TXT",
+ "/usr/share/wsjtx/CALL3.TXT",
+ "/usr/share/wsjtx/sounds/Message.wav",
+ "/usr/share/wsjtx/sounds/Testing123.wav",
+ ]
+ for missing in (
+ "/usr/bin/map65",
+ "/usr/share/wsjtx/ALLCALL7.TXT",
+ "/usr/share/wsjtx/sounds/Message.wav",
+ ):
+ with self.subTest(missing=missing):
+ manifest = "\n".join(path for path in required if path != missing)
+ result = self.run_helper(
+ 'validate_linux_package_manifest "$MANIFEST" fixture',
+ MANIFEST=manifest,
+ )
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn(missing, result.stderr)
+
+ def test_package_manifest_rejects_executable_adjacent_sounds(self):
+ manifest = "\n".join(
+ (
+ "/usr/bin/wsjtx",
+ "/usr/bin/jt9",
+ "/usr/bin/qmap",
+ "/usr/bin/map65",
+ "/usr/bin/sounds/Message.wav",
+ "/usr/share/wsjtx/ALLCALL7.TXT",
+ "/usr/share/wsjtx/CALL3.TXT",
+ "/usr/share/wsjtx/sounds/Message.wav",
+ "/usr/share/wsjtx/sounds/Testing123.wav",
+ )
+ )
+ result = self.run_helper(
+ 'validate_linux_package_manifest "$MANIFEST" fixture', MANIFEST=manifest
+ )
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn("/usr/bin/sounds", result.stderr)
+
+ def test_application_layout_rejects_missing_executable_data_or_sound(self):
+ for relative in (
+ "usr/bin/map65",
+ "usr/share/wsjtx/ALLCALL7.TXT",
+ "usr/share/wsjtx/sounds/Message.wav",
+ ):
+ with self.subTest(relative=relative):
+ temporary, root = self.make_application_tree("appdir")
+ self.addCleanup(temporary.cleanup)
+ (root / relative).unlink()
+ result = self.run_helper(
+ 'validate_linux_application_layout "$TREE" appdir', TREE=root
+ )
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn(str(root / relative), result.stderr)
+
+ def test_application_layout_rejects_executable_adjacent_sounds(self):
+ temporary, root = self.make_application_tree("appdir")
+ self.addCleanup(temporary.cleanup)
+ (root / "usr/bin/sounds").mkdir()
+ result = self.run_helper(
+ 'validate_linux_application_layout "$TREE" appdir', TREE=root
+ )
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn("usr/bin/sounds", result.stderr)
+
+ def test_appimage_layout_requires_qt_runtime_payload(self):
+ for relative in (
+ "usr/bin/qt.conf",
+ "usr/plugins/platforms/libqxcb.so",
+ "usr/plugins/sqldrivers/libqsqlite.so",
+ "usr/plugins/audio/libqtaudio_alsa.so",
+ "usr/lib/libQt5Core.so.5",
+ ):
+ with self.subTest(relative=relative):
+ temporary, root = self.make_application_tree()
+ self.addCleanup(temporary.cleanup)
+ (root / relative).unlink()
+ result = self.run_helper(
+ 'validate_linux_application_layout "$TREE" appimage', TREE=root
+ )
+ self.assertNotEqual(result.returncode, 0)
+
+ def test_armhf_elf_metadata_accepts_eabi5_hard_float_loader(self):
+ result = self.run_helper(
+ 'validate_elf_metadata armhf fixture "$FILE_OUT" "$HEADER_OUT" "$PROGRAM_OUT"',
+ FILE_OUT=(
+ "fixture: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 "
+ "(SYSV), dynamically linked"
+ ),
+ HEADER_OUT=(
+ "Class: ELF32\nMachine: ARM\n"
+ "Flags: 0x5000400, Version5 EABI, hard-float ABI"
+ ),
+ PROGRAM_OUT=(
+ "INTERP 0x000174 [Requesting program interpreter: "
+ "/lib/ld-linux-armhf.so.3]"
+ ),
+ )
+ self.assertEqual(result.returncode, 0, result.stderr)
+
+ def test_armhf_elf_metadata_rejects_wrong_abi_properties(self):
+ good = {
+ "FILE_OUT": (
+ "fixture: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 "
+ "(SYSV), dynamically linked"
+ ),
+ "HEADER_OUT": (
+ "Class: ELF32\nMachine: ARM\n"
+ "Flags: 0x5000400, Version5 EABI, hard-float ABI"
+ ),
+ "PROGRAM_OUT": (
+ "INTERP 0x000174 [Requesting program interpreter: "
+ "/lib/ld-linux-armhf.so.3]"
+ ),
+ }
+ mutations = {
+ "class": {"HEADER_OUT": good["HEADER_OUT"].replace("ELF32", "ELF64")},
+ "machine": {
+ "HEADER_OUT": good["HEADER_OUT"].replace("Machine: ARM", "Machine: X86-64")
+ },
+ "eabi": {"HEADER_OUT": good["HEADER_OUT"].replace("Version5", "Version4")},
+ "hard_float": {
+ "HEADER_OUT": good["HEADER_OUT"].replace("hard-float", "soft-float")
+ },
+ "loader": {"PROGRAM_OUT": good["PROGRAM_OUT"].replace("armhf", "arm")},
+ }
+ for fault, mutation in mutations.items():
+ with self.subTest(fault=fault):
+ environment = good | mutation
+ result = self.run_helper(
+ 'validate_elf_metadata armhf fixture "$FILE_OUT" "$HEADER_OUT" "$PROGRAM_OUT"',
+ **environment,
+ )
+ self.assertNotEqual(result.returncode, 0)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/.github/scripts/tests/test_linux_ccache_policy.py b/.github/scripts/tests/test_linux_ccache_policy.py
new file mode 100644
index 00000000..42c97e01
--- /dev/null
+++ b/.github/scripts/tests/test_linux_ccache_policy.py
@@ -0,0 +1,99 @@
+import pathlib
+import unittest
+
+
+REPOSITORY = pathlib.Path(__file__).resolve().parents[3]
+
+
+class LinuxCcachePolicyTests(unittest.TestCase):
+ def read(self, relative_path):
+ return (REPOSITORY / relative_path).read_text(encoding="utf-8")
+
+ def assert_cache_tiers(self, text, prefix):
+ primary = (
+ f"{prefix}${{{{ steps.image.outputs.ccache_compatibility_id }}}}-"
+ "${{ steps.image.outputs.generation }}-${{ github.sha }}"
+ "${{ steps.ccache-key.outputs.suffix }}"
+ )
+ generation = (
+ f"{prefix}${{{{ steps.image.outputs.ccache_compatibility_id }}}}-"
+ "${{ steps.image.outputs.generation }}-"
+ )
+ compatible = (
+ f"{prefix}${{{{ steps.image.outputs.ccache_compatibility_id }}}}-"
+ )
+ self.assertIn(f"key: {primary}", text)
+ generation_index = text.index(f" {generation}")
+ compatible_index = text.index(f" {compatible}", generation_index + 1)
+ self.assertLess(generation_index, compatible_index)
+
+ def test_normal_cache_prefers_current_image_generation(self):
+ action = self.read(".github/actions/build-linux-payload/action.yml")
+ self.assert_cache_tiers(action, "ccache-linux-${{ inputs.arch }}-")
+ self.assertIn(
+ 'export CCACHE_COMPILERCHECK="${{ steps.image.outputs.ccache_compiler_check }}"',
+ action,
+ )
+ self.assertIn('if: inputs.runtime_base == \'host\'', action)
+ self.assertIn('echo "CC=gcc"', action)
+ self.assertIn('echo "CXX=g++"', action)
+ self.assertIn(
+ "if: inputs.save_ccache == 'true' && steps.image.outputs.recipe_match == 'true' && steps.ccache.outputs.cache-hit != 'true'",
+ action,
+ )
+
+ def test_sanitizer_cache_keeps_profile_and_generation(self):
+ action = self.read(".github/actions/build-linux-sanitizers/action.yml")
+ self.assert_cache_tiers(
+ action,
+ "ccache-linux-x86_64-${{ steps.sanitizer.outputs.cache_key }}-",
+ )
+ self.assertIn(
+ 'export CCACHE_COMPILERCHECK="${{ steps.image.outputs.ccache_compiler_check }}"',
+ action,
+ )
+ self.assertIn(
+ "if: inputs.save_ccache == 'true' && steps.image.outputs.recipe_match == 'true' && steps.ccache.outputs.cache-hit != 'true'",
+ action,
+ )
+
+ def test_armhf_verifies_and_forwards_cache_identity(self):
+ workflow = self.read(".github/workflows/build-linux.yml")
+ self.assert_cache_tiers(workflow, "ccache-linux-armhf-")
+ self.assertIn(
+ "verify-armhf-ci-image.sh cross-builder armhf", workflow
+ )
+ self.assertIn("verify-armhf-ci-image.sh runtime armhf", workflow)
+ self.assertIn(
+ "CROSS_BUILDER_IMAGE: ${{ needs.resolve-image.outputs.cross_image_reference }}",
+ workflow,
+ )
+ self.assertEqual(
+ workflow.count(
+ "RUNTIME_IMAGE: ${{ needs.resolve-image.outputs.image_reference }}"
+ ),
+ 2,
+ )
+ self.assertIn("build-linux-armhf-cross.sh", workflow)
+ self.assertIn("validate-linux-armhf-runtime.sh", workflow)
+ self.assertIn("HAMLIB_BRANCH: ${{ inputs.hamlib_branch }}", workflow)
+ self.assertIn("CCACHE_COMPILERCHECK: ${{ steps.image.outputs.ccache_compiler_check }}", workflow)
+ self.assertIn("-e CCACHE_COMPILERCHECK", workflow)
+ self.assertIn("-e WSJTX_CI_IMAGE_ALLOW_RECIPE_MISMATCH", workflow)
+ self.assertIn("cross_recipe_match", workflow)
+ self.assertIn("runtime_recipe_match", workflow)
+ self.assertIn(
+ "if: inputs.save_ccache && steps.image.outputs.recipe_match == 'true' && steps.ccache.outputs.cache-hit != 'true'",
+ workflow,
+ )
+
+ def test_release_accepts_separately_promoted_armhf_recipe(self):
+ workflow = self.read(".github/workflows/release.yml")
+ armhf_job = workflow.split(" linux-armhf:\n", 1)[1].split(
+ "\n windows:\n", 1
+ )[0]
+ self.assertIn("allow_stale_image: true", armhf_job)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/.github/scripts/tests/test_linux_image_publication_policy.py b/.github/scripts/tests/test_linux_image_publication_policy.py
new file mode 100644
index 00000000..cb88ac95
--- /dev/null
+++ b/.github/scripts/tests/test_linux_image_publication_policy.py
@@ -0,0 +1,181 @@
+import pathlib
+import re
+import unittest
+
+
+ROOT = pathlib.Path(__file__).resolve().parents[3]
+PUBLISH = (ROOT / ".github/workflows/publish-linux-ci-images.yml").read_text()
+BUILD = (ROOT / ".github/workflows/build-linux.yml").read_text()
+WARM = (ROOT / ".github/workflows/warm-dependency-caches.yml").read_text()
+CLASSIFIER = (ROOT / ".github/scripts/is-linux-ci-image-input.sh").read_text()
+
+
+def job(name: str) -> str:
+ match = re.search(
+ rf"^ {re.escape(name)}:\n(?P<body>.*?)(?=^ [a-z][a-z0-9-]*:\n|\Z)",
+ PUBLISH,
+ re.MULTILINE | re.DOTALL,
+ )
+ if not match:
+ raise AssertionError(f"job not found: {name}")
+ return match.group("body")
+
+
+class LinuxImagePublicationPolicyTests(unittest.TestCase):
+ def test_public_release_publication_is_tag_scoped_and_complete(self):
+ validate = job("validate-inputs")
+ self.assertIn('[ "$REQUEST_REPOSITORY" != WSJTX/wsjtx ]', validate)
+ self.assertIn("^refs/tags/v[0-9]+\\.[0-9]+\\.[0-9]+", validate)
+ self.assertIn('[ "$PROMOTE" != false ]', validate)
+ self.assertIn('[ "$IMAGE_SET" != normal ]', validate)
+ self.assertIn('[ "$INCLUDE_ARMHF" != true ]', validate)
+
+ def test_public_release_images_use_release_tag_and_public_package_root(self):
+ metadata = job("metadata")
+ public_block = re.search(
+ r'if \[ "\$PUBLICATION_TARGET" = public-release \]; then(?P<body>.*?)else',
+ metadata,
+ re.DOTALL,
+ ).group("body")
+ self.assertIn(
+ 'release-${GITHUB_REF_NAME}-${GITHUB_SHA}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}',
+ public_block,
+ )
+ self.assertIn("package_root=ghcr.io/wsjtx/wsjtx", public_block)
+ self.assertNotIn(":stable", public_block)
+ self.assertIn("type=gha", public_block)
+ self.assertEqual(
+ PUBLISH.count(
+ "labels: ${{ inputs.publication_target == 'public-release' && 'org.opencontainers.image.source=https://github.com/WSJTX/wsjtx' || '' }}"
+ ),
+ 5,
+ )
+
+ def test_reusable_publisher_exports_all_release_image_digests(self):
+ self.assertIn("x86_64_digest:", PUBLISH)
+ self.assertIn("value: ${{ jobs.build-normal.outputs.digest }}", PUBLISH)
+ self.assertIn("aarch64_digest:", PUBLISH)
+ self.assertIn("value: ${{ jobs.build-arm64.outputs.digest }}", PUBLISH)
+ self.assertIn("armhf_digest:", PUBLISH)
+ self.assertIn("value: ${{ jobs.build-armhf-runtime.outputs.digest }}", PUBLISH)
+ self.assertIn("armhf_cross_digest:", PUBLISH)
+ self.assertIn("value: ${{ jobs.build-armhf-cross.outputs.digest }}", PUBLISH)
+
+ def test_public_release_builds_require_and_consume_digest_references(self):
+ self.assertIn("^sha256:[0-9a-f]{64}$", BUILD)
+ self.assertIn("public-release images require an immutable sha256 digest", BUILD)
+ self.assertIn(
+ 'image_reference=${package_root}/${package}@${IMAGE_DIGEST}', BUILD
+ )
+ self.assertIn(
+ 'cross_image_reference=${package_root}/${cross_package}@${ARMHF_CROSS_IMAGE_DIGEST}',
+ BUILD,
+ )
+ self.assertEqual(
+ BUILD.count("image: ${{ needs.resolve-image.outputs.image_reference }}"), 2
+ )
+ self.assertIn(
+ "CROSS_BUILDER_IMAGE: ${{ needs.resolve-image.outputs.cross_image_reference }}",
+ BUILD,
+ )
+ self.assertIn(
+ "RUNTIME_IMAGE: ${{ needs.resolve-image.outputs.image_reference }}", BUILD
+ )
+
+ def test_manual_target_mapping_keeps_tsan_independent(self):
+ self.assertRegex(WARM, r"linux\|linux-images\)\n\s+normal_images=true")
+ self.assertRegex(WARM, r"linux-tsan\)\n\s+tsan_images=true")
+ all_case = re.search(r"all\)\n(?P<body>.*?);;", WARM, re.DOTALL).group("body")
+ self.assertIn("enable_all", all_case)
+ self.assertNotIn("tsan_images=true", all_case)
+ self.assertIn("image_set: ${{ needs.detect.outputs.image_set }}", WARM)
+ self.assertRegex(
+ WARM,
+ r'if \[ "\$SCHEDULE" = "17 9 1 \* \*" \][\s\S]*?normal_images=true\s+tsan_images=true',
+ )
+
+ def test_push_selection_uses_tested_profile_classifier(self):
+ self.assertIn('is-linux-ci-image-input.sh --classify "$path"', WARM)
+ self.assertIn("expect_image_set normal ", CLASSIFIER)
+ self.assertIn("expect_image_set tsan ", CLASSIFIER)
+ self.assertIn("expect_image_set normal-and-tsan ", CLASSIFIER)
+ self.assertIn('expect_image_set none "CMake/Sources.cmake"', CLASSIFIER)
+ self.assertIn("armhf-cross-bookworm", CLASSIFIER)
+ self.assertIn("armhf-runtime-bookworm", CLASSIFIER)
+ self.assertIn('include_armhf: true', WARM)
+
+ def test_candidate_warm_uses_exact_tag_and_publishes_without_recache(self):
+ warm = job("warm-normal-ccache")
+ self.assertIn("- build-normal", warm)
+ self.assertIn("uses: ./.github/workflows/build-linux.yml", warm)
+ self.assertIn("image_tag: ${{ needs.metadata.outputs.build_tag }}", warm)
+ self.assertIn("allow_stale_image: false", warm)
+ self.assertIn("recache: false", warm)
+ self.assertIn("save_ccache: true", warm)
+
+ promote = job("promote")
+ self.assertIn("needs.warm-normal-ccache.result == 'success'", promote)
+ self.assertIn("- warm-normal-ccache", promote)
+
+ def test_metadata_loads_only_the_selected_image_cohort(self):
+ metadata = job("metadata")
+ self.assertIn('if [ "$IMAGE_SET" != tsan ]; then', metadata)
+ self.assertIn(". .github/scripts/linux-ci-image-config.sh", metadata)
+ self.assertIn("linux-ci-image-fingerprint.sh armhf-cross-bookworm", metadata)
+ self.assertIn("linux-ci-image-fingerprint.sh armhf-runtime-bookworm", metadata)
+ self.assertIn('if [ "$IMAGE_SET" != normal ]; then', metadata)
+ self.assertIn(". .github/scripts/tsan-linux-deps-config.sh", metadata)
+
+ def test_armhf_images_are_built_and_promoted_as_one_generation(self):
+ cross = job("build-armhf-cross")
+ runtime = job("build-armhf-runtime")
+ promote = job("promote")
+
+ self.assertIn("platforms: linux/amd64", cross)
+ self.assertIn("Dockerfile.armhf-cross", cross)
+ self.assertIn("/usr/local/lib/android /usr/share/dotnet /opt/ghc", cross)
+ self.assertNotIn("/usr/local/lib/android", job("build-normal"))
+ self.assertIn("- build-armhf-cross", runtime)
+ self.assertIn("platforms: linux/arm/v7", runtime)
+ self.assertIn("Dockerfile.armhf-runtime", runtime)
+ self.assertIn(
+ "CROSS_BUILDER_IMAGE=${{ needs.metadata.outputs.package_root }}/"
+ "linux-armhf-cross-bookworm:${{ needs.metadata.outputs.build_tag }}",
+ runtime,
+ )
+ self.assertIn("linux-armhf-cross-bookworm:${VALIDATED_TAG}", promote)
+ self.assertIn("linux-armv7-bookworm:${VALIDATED_TAG}", promote)
+ self.assertIn("linux-armhf-cross-bookworm:stable", promote)
+ self.assertIn("linux-armv7-bookworm:stable", promote)
+
+ def test_publication_mutations_require_develop(self):
+ validate = job("validate-inputs")
+ self.assertIn('[ "$MODE" = rollback ] || [ "$PROMOTE" = true ]', validate)
+ self.assertIn('[ "$REQUEST_REF" != refs/heads/develop ]', validate)
+
+ def test_tsan_only_jobs_and_tag_moves_exclude_normal_images(self):
+ validate = job("validate-inputs")
+ self.assertIn("normal|tsan|normal-and-tsan", validate)
+ self.assertIn('[ "$IMAGE_SET" = tsan ] && [ "$INCLUDE_ARMHF" = true ]', validate)
+ self.assertIn("inputs.image_set == 'tsan'", job("build-tsan"))
+ self.assertIn("inputs.image_set == 'normal'", job("build-normal"))
+ self.assertIn('if [ "$IMAGE_SET" != tsan ]; then', job("promote"))
+ self.assertIn('if [ "$IMAGE_SET" != normal ]; then', job("promote"))
+ self.assertIn('if [ "$IMAGE_SET" != tsan ]; then', job("rollback"))
+ self.assertIn('if [ "$IMAGE_SET" != normal ]; then', job("rollback"))
+
+ def test_rollback_uses_only_explicitly_selected_packages(self):
+ rollback = job("rollback")
+ self.assertNotIn("tsan_available", rollback)
+ self.assertNotIn("armhf_available", rollback)
+ self.assertIn("packages+=(linux-noble linux-arm64-bookworm)", rollback)
+ self.assertIn(
+ "packages+=(linux-armhf-cross-bookworm linux-armv7-bookworm)",
+ rollback,
+ )
+ self.assertIn("packages+=(linux-tsan-noble)", rollback)
+ self.assertIn("stable_packages+=(linux-noble)", rollback)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/.github/scripts/tests/test_release_policy.py b/.github/scripts/tests/test_release_policy.py
new file mode 100644
index 00000000..a7929484
--- /dev/null
+++ b/.github/scripts/tests/test_release_policy.py
@@ -0,0 +1,383 @@
+import importlib.util
+import json
+import io
+import shutil
+import subprocess
+import sys
+import tarfile
+import tempfile
+import unittest
+import zipfile
+from pathlib import Path
+
+
+SCRIPT = Path(__file__).parents[1] / "release-policy.py"
+SPEC = importlib.util.spec_from_file_location("release_policy", SCRIPT)
+release_policy = importlib.util.module_from_spec(SPEC)
+assert SPEC.loader
+SPEC.loader.exec_module(release_policy)
+
+
+class ReleasePolicyTest(unittest.TestCase):
+ def test_classifies_ga_and_rc(self):
+ self.assertEqual(release_policy.classify("3.2.0")["channel"], "GA")
+ identity = release_policy.classify("3.2.0-rc2")
+ self.assertEqual(identity["channel"], "RC")
+ self.assertEqual(identity["rc_number"], "2")
+ self.assertEqual(identity["release_branch"], "release/3.2")
+
+ def test_rejects_non_release_versions(self):
+ for version in ("v3.2.0", "3.2.0-beta1", "3.2", "3.2.0-rc0"):
+ with self.subTest(version=version), self.assertRaises(ValueError):
+ release_policy.classify(version)
+
+ def test_validates_tracked_release_state(self):
+ with tempfile.TemporaryDirectory() as directory:
+ root = Path(directory)
+ (root / "release-state.txt").write_text(
+ "version=3.2.0\n"
+ "channel=RC\n"
+ "rc=1\n"
+ "revision=$Format:%H$\n"
+ )
+ identity = release_policy.validate_source(root, "3.2.0-rc1")
+ self.assertEqual(identity["channel"], "RC")
+ self.assertEqual(identity["windows_signing"], "signpath")
+ with self.assertRaisesRegex(ValueError, "release channel"):
+ release_policy.validate_source(root, "3.2.0")
+ (root / "release-state.txt").write_text(
+ "version=3.2.0\nchannel=RC\nrc=1\nrevision=" + "a" * 40 + "\n"
+ )
+ with self.assertRaisesRegex(ValueError, "revision"):
+ release_policy.validate_source(root, "3.2.0-rc1")
+
+ def test_read_state_cli_accepts_single_digit_rc(self):
+ with tempfile.TemporaryDirectory() as directory:
+ root = Path(directory)
+ (root / "release-state.txt").write_text(
+ "version=3.2.0\n"
+ "channel=RC\n"
+ "rc=1\n"
+ "revision=$Format:%H$\n"
+ )
+ result = subprocess.run(
+ [sys.executable, SCRIPT, "read-state", "--root", root],
+ check=True,
+ capture_output=True,
+ text=True,
+ )
+ self.assertEqual(
+ json.loads(result.stdout),
+ {
+ "version": "3.2.0",
+ "channel": "RC",
+ "rc": "1",
+ "revision": "$Format:%H$",
+ "windows_signing": "signpath",
+ },
+ )
+
+ (root / "release-state.txt").write_text(
+ "version=3.2.0\n"
+ "channel=RC\n"
+ "rc=1beta\n"
+ "revision=$Format:%H$\n"
+ )
+ result = subprocess.run(
+ [sys.executable, SCRIPT, "read-state", "--root", root],
+ capture_output=True,
+ text=True,
+ )
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn("positive RC number", result.stderr)
+
+ def test_source_pins_unsigned_mode_and_rejects_unknown_mode(self):
+ with tempfile.TemporaryDirectory() as directory:
+ root = Path(directory)
+ state = (
+ "version=3.2.0\nchannel=RC\nrc=1\n"
+ "revision=$Format:%H$\nwindows_signing=unsigned\n"
+ )
+ (root / "release-state.txt").write_text(state)
+ self.assertEqual(
+ release_policy.validate_source(root, "3.2.0-rc1")["windows_signing"],
+ "unsigned",
+ )
+ archive = root / "source.zip"
+ commit = "c" * 40
+ with zipfile.ZipFile(archive, "w") as output:
+ output.writestr(
+ "wsjtx-3.2.0-rc1/release-state.txt",
+ state.replace("$Format:%H$", commit),
+ )
+ release_policy.validate_archive(archive, "3.2.0-rc1", commit)
+ with self.assertRaisesRegex(ValueError, "windows_signing"):
+ release_policy.parse_state(state.replace("unsigned", "ephemeral"))
+
+ def test_validates_exported_tar_and_zip_identity(self):
+ with tempfile.TemporaryDirectory() as directory:
+ root = Path(directory)
+ commit = "b" * 40
+ state = f"version=3.2.0\nchannel=RC\nrc=1\nrevision={commit}\n".encode()
+ tar_path = root / "source.tar.gz"
+ with tarfile.open(tar_path, "w:gz") as archive:
+ info = tarfile.TarInfo("wsjtx-3.2.0-rc1/release-state.txt")
+ info.size = len(state)
+ archive.addfile(info, io.BytesIO(state))
+ zip_path = root / "source.zip"
+ with zipfile.ZipFile(zip_path, "w") as archive:
+ archive.writestr("wsjtx-3.2.0-rc1/release-state.txt", state)
+ release_policy.validate_archive(tar_path, "3.2.0-rc1", commit)
+ release_policy.validate_archive(zip_path, "3.2.0-rc1", commit)
+ with self.assertRaisesRegex(ValueError, "revision"):
+ release_policy.validate_archive(tar_path, "3.2.0-rc1", "c" * 40)
+
+ def test_distribution_gate_rejects_unsigned_package(self):
+ with tempfile.TemporaryDirectory() as directory:
+ root = Path(directory)
+ version = "3.2.0-rc1"
+ for name in release_policy.expected_assets(version, True):
+ target = root / name
+ target.mkdir()
+ suffix = ".pkg" if "macOS" in name else ".AppImage" if "linux" in name else ".exe"
+ (target / f"artifact{suffix}").write_bytes(b"signed")
+ (root / "extra").mkdir()
+ (root / "extra" / "unexpected-unsigned.pkg").write_bytes(b"unsigned")
+ with self.assertRaisesRegex(ValueError, "unsigned macOS"):
+ release_policy.find_asset_files(root, version, True)
+
+ def test_manifest_binds_assets_to_tag_and_commit(self):
+ with tempfile.TemporaryDirectory() as directory:
+ root = Path(directory)
+ version = "3.2.0"
+ for name in release_policy.expected_assets(version, True):
+ target = root / name
+ target.mkdir()
+ suffix = ".pkg" if "macOS" in name else ".AppImage" if "linux" in name else ".exe"
+ (target / f"{name}{suffix}" if not name.endswith(suffix) else target / name).write_bytes(name.encode())
+ for arch in ("x86_64", "aarch64", "armhf"):
+ for package_type in ("deb", "rpm"):
+ target = root / f"wsjtx-{version}-linux-{arch}-{package_type}"
+ target.mkdir()
+ (target / f"wsjtx-{arch}.{package_type}").write_bytes(arch.encode())
+ (root / f"wsjtx-{version}-src.tar.gz").write_bytes(b"source")
+ args = type("Args", (), {
+ "artifacts": str(root), "version": version, "repository": "WSJTX/wsjtx",
+ "commit": "a" * 40, "run_id": "123",
+ "linux_x86_64_digest": "sha256:" + "1" * 64,
+ "linux_aarch64_digest": "sha256:" + "2" * 64,
+ "linux_armhf_cross_digest": "sha256:" + "3" * 64,
+ "linux_armhf_digest": "sha256:" + "4" * 64,
+ "macos_mode": "distribution",
+ "windows_mode": "signpath",
+ })()
+ release_policy.write_manifest(args)
+ manifest = json.loads((root / "release-manifest.json").read_text())
+ self.assertEqual(manifest["tag"], "v3.2.0")
+ self.assertEqual(manifest["commit"], "a" * 40)
+ self.assertEqual(manifest["linux_builders"]["armhf_cross"], "sha256:" + "3" * 64)
+ self.assertEqual(manifest["linux_builders"]["armhf_runtime"], "sha256:" + "4" * 64)
+ self.assertEqual(manifest["macos_signing"]["mode"], "distribution")
+ self.assertEqual(manifest["macos_signing"]["replaceable_assets"], [])
+ self.assertEqual(manifest["windows_signing"]["mode"], "signpath")
+ self.assertEqual(len(manifest["assets"]), 13)
+
+ def test_manual_macos_assets_keep_release_names_without_immutable_hashes(self):
+ with tempfile.TemporaryDirectory() as directory:
+ root = Path(directory)
+ version = "3.2.0"
+ for name in release_policy.public_expected_assets(version, "validation"):
+ target = root / name
+ target.mkdir()
+ if "macOS" in name:
+ filename = name.replace("-unsigned", "")
+ elif "linux" in name:
+ filename = f"{name}.AppImage"
+ else:
+ filename = "wsjtx-win64.exe"
+ (target / filename).write_bytes(name.encode())
+ for arch in ("x86_64", "aarch64", "armhf"):
+ for package_type in ("deb", "rpm"):
+ target = root / f"wsjtx-{version}-linux-{arch}-{package_type}"
+ target.mkdir()
+ (target / f"wsjtx-{arch}.{package_type}").write_bytes(arch.encode())
+ (root / f"wsjtx-{version}-src.tar.gz").write_bytes(b"source")
+ args = type("Args", (), {
+ "artifacts": str(root), "version": version, "repository": "WSJTX/wsjtx",
+ "commit": "a" * 40, "run_id": "123",
+ "linux_x86_64_digest": "sha256:" + "1" * 64,
+ "linux_aarch64_digest": "sha256:" + "2" * 64,
+ "linux_armhf_cross_digest": "sha256:" + "3" * 64,
+ "linux_armhf_digest": "sha256:" + "4" * 64,
+ "macos_mode": "validation",
+ "windows_mode": "signpath",
+ })()
+
+ release_policy.write_manifest(args)
+
+ manifest = json.loads((root / "release-manifest.json").read_text())
+ replaceable = {
+ f"wsjtx-{version}-arm64-macOS.pkg",
+ f"wsjtx-{version}-x86_64-macOS.pkg",
+ }
+ release_names = {path.name for path in release_policy.release_files(root, version, "validation")}
+ immutable_names = {entry["name"] for entry in manifest["assets"]}
+ checksum_names = {
+ line.split(" ", 1)[1]
+ for line in (root / "SHA256SUMS").read_text().splitlines()
+ }
+ self.assertEqual(manifest["macos_signing"]["mode"], "manual")
+ self.assertEqual(set(manifest["macos_signing"]["replaceable_assets"]), replaceable)
+ self.assertTrue(replaceable <= release_names)
+ self.assertTrue(replaceable.isdisjoint(immutable_names))
+ self.assertTrue(replaceable.isdisjoint(checksum_names))
+ self.assertIn("wsjtx-win64.exe", immutable_names)
+
+ def test_unsigned_windows_manifest_selects_and_hashes_installer(self):
+ with tempfile.TemporaryDirectory() as directory:
+ root = Path(directory)
+ version = "3.2.0-rc1"
+ for name in release_policy.public_expected_assets(version, "validation", "unsigned"):
+ target = root / name
+ target.mkdir()
+ if "macOS" in name:
+ filename = name.replace("-unsigned", "")
+ elif "linux" in name:
+ filename = f"{name}.AppImage"
+ else:
+ filename = f"wsjtx-{version}-win64.exe"
+ (target / filename).write_bytes(name.encode())
+ for arch in ("x86_64", "aarch64", "armhf"):
+ for package_type in ("deb", "rpm"):
+ target = root / f"wsjtx-{version}-linux-{arch}-{package_type}"
+ target.mkdir()
+ (target / f"wsjtx-{arch}.{package_type}").write_bytes(arch.encode())
+ (root / f"wsjtx-{version}-src.tar.gz").write_bytes(b"source")
+ args = type("Args", (), {
+ "artifacts": str(root), "version": version, "repository": "WSJTX/wsjtx",
+ "commit": "a" * 40, "run_id": "123",
+ "linux_x86_64_digest": "sha256:" + "1" * 64,
+ "linux_aarch64_digest": "sha256:" + "2" * 64,
+ "linux_armhf_cross_digest": "sha256:" + "3" * 64,
+ "linux_armhf_digest": "sha256:" + "4" * 64,
+ "macos_mode": "validation", "windows_mode": "unsigned",
+ })()
+ release_policy.write_manifest(args)
+ manifest = json.loads((root / "release-manifest.json").read_text())
+ installer = f"wsjtx-{version}-win64.exe"
+ self.assertEqual(manifest["windows_signing"]["mode"], "unsigned")
+ self.assertIn(installer, {entry["name"] for entry in manifest["assets"]})
+ self.assertIn(installer, (root / "SHA256SUMS").read_text())
+ installer_path = root / f"wsjtx-{version}-windows-x86_64-installer" / installer
+ installer_path.rename(installer_path.with_name("unexpected.exe"))
+ with self.assertRaisesRegex(ValueError, "unexpected unsigned Windows installer"):
+ release_policy.find_public_asset_files(root, version, "validation", "unsigned")
+ installer_path.with_name("unexpected.exe").rename(installer_path)
+ signed_dir = root / f"wsjtx-{version}-windows-x86_64-installer-signed"
+ signed_dir.mkdir()
+ with self.assertRaisesRegex(ValueError, "signed Windows installer"):
+ release_policy.find_public_asset_files(root, version, "validation", "unsigned")
+
+ def test_signing_reports_bind_hashes_and_source(self):
+ with tempfile.TemporaryDirectory() as directory:
+ root = Path(directory)
+ version = "3.2.0-rc1"
+ commit = "b" * 40
+ tag = f"v{version}"
+ for arch in ("arm64", "x86_64"):
+ package_dir = root / f"wsjtx-{version}-{arch}-macOS.pkg"
+ package_dir.mkdir()
+ package = package_dir / f"wsjtx-{version}-{arch}-macOS.pkg"
+ package.write_bytes(arch.encode())
+ report_dir = root / f"macos-signing-report-{version}-{arch}"
+ report_dir.mkdir()
+ (report_dir / "macos-signing-report.json").write_text(json.dumps({
+ "mode": "distribution", "git_sha": commit, "artifact": package.name,
+ "sha256": release_policy.hash_file(package), "notarization": {"status": "Accepted"},
+ "stapled": True, "gatekeeper_accepted": True, "team_id": "ABCDE12345",
+ "application_certificate_sha1": "A" * 40,
+ "installer_certificate_sha1": "B" * 40,
+ }))
+ installer_dir = root / f"wsjtx-{version}-windows-x86_64-installer-signed"
+ installer_dir.mkdir()
+ installer = installer_dir / "wsjtx.exe"
+ installer.write_bytes(b"windows")
+ request_dir = root / f"wsjtx-{version}-windows-signing-request"
+ request_dir.mkdir()
+ (request_dir / "request.json").write_text(json.dumps({
+ "policy": "release-signing", "commit": commit, "tag": tag,
+ }))
+ verification_dir = root / f"wsjtx-{version}-windows-signing-verification"
+ verification_dir.mkdir()
+ (verification_dir / "verification.json").write_text(json.dumps({
+ "commit": commit, "tag": tag, "artifact": installer.name,
+ "sha256": release_policy.hash_file(installer), "status": "Valid",
+ "timestamp_thumbprint": "1234", "signer_subject": "WSJT-X",
+ "signer_thumbprint": "5678", "identity_verified": True,
+ }))
+ release_policy.verify_signing_reports(root, version, commit, tag)
+ (verification_dir / "verification.json").write_text("{}")
+ with self.assertRaisesRegex(ValueError, "release ref"):
+ release_policy.verify_signing_reports(root, version, commit, tag)
+
+ def test_validation_reports_allow_unsigned_macos_with_signed_windows(self):
+ with tempfile.TemporaryDirectory() as directory:
+ root = Path(directory)
+ version = "3.2.0-rc1"
+ commit = "b" * 40
+ tag = f"v{version}"
+ for arch in ("arm64", "x86_64"):
+ package_dir = root / f"wsjtx-{version}-{arch}-macOS-unsigned.pkg"
+ package_dir.mkdir()
+ package = package_dir / f"wsjtx-{version}-{arch}-macOS.pkg"
+ package.write_bytes(arch.encode())
+ report_dir = root / f"macos-signing-report-{version}-{arch}"
+ report_dir.mkdir()
+ (report_dir / "macos-signing-report.json").write_text(json.dumps({
+ "mode": "validation", "git_sha": commit, "artifact": package.name,
+ "sha256": release_policy.hash_file(package), "signed": False,
+ "notarized": False, "publishable": False,
+ }))
+ installer_dir = root / f"wsjtx-{version}-windows-x86_64-installer-signed"
+ installer_dir.mkdir()
+ installer = installer_dir / "wsjtx.exe"
+ installer.write_bytes(b"windows")
+ request_dir = root / f"wsjtx-{version}-windows-signing-request"
+ request_dir.mkdir()
+ (request_dir / "request.json").write_text(json.dumps({
+ "policy": "release-signing", "commit": commit, "tag": tag,
+ }))
+ verification_dir = root / f"wsjtx-{version}-windows-signing-verification"
+ verification_dir.mkdir()
+ (verification_dir / "verification.json").write_text(json.dumps({
+ "commit": commit, "tag": tag, "artifact": installer.name,
+ "sha256": release_policy.hash_file(installer), "status": "Valid",
+ "timestamp_thumbprint": "1234", "signer_subject": "WSJT-X",
+ "signer_thumbprint": "5678", "identity_verified": True,
+ }))
+
+ release_policy.verify_signing_reports(root, version, commit, tag, "validation")
+
+ report = json.loads(
+ (root / f"macos-signing-report-{version}-arm64" / "macos-signing-report.json").read_text()
+ )
+ report["signed"] = True
+ (root / f"macos-signing-report-{version}-arm64" / "macos-signing-report.json").write_text(
+ json.dumps(report)
+ )
+ with self.assertRaisesRegex(ValueError, "unsigned package"):
+ release_policy.verify_signing_reports(root, version, commit, tag, "validation")
+
+ report["signed"] = False
+ (root / f"macos-signing-report-{version}-arm64" / "macos-signing-report.json").write_text(
+ json.dumps(report)
+ )
+ with self.assertRaisesRegex(ValueError, "Windows signing report"):
+ release_policy.verify_signing_reports(root, version, commit, tag, "validation", "unsigned")
+ shutil.rmtree(request_dir)
+ shutil.rmtree(verification_dir)
+ release_policy.verify_signing_reports(root, version, commit, tag, "validation", "unsigned")
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/.github/scripts/tests/test_resolve_linux_ci_image_tag.py b/.github/scripts/tests/test_resolve_linux_ci_image_tag.py
new file mode 100755
index 00000000..b8a3c1bd
--- /dev/null
+++ b/.github/scripts/tests/test_resolve_linux_ci_image_tag.py
@@ -0,0 +1,125 @@
+#!/usr/bin/env python3
+
+import importlib.util
+import sys
+import unittest
+from datetime import datetime, timezone
+from pathlib import Path
+
+
+SCRIPT = Path(__file__).parents[1] / "resolve-linux-ci-image-tag.py"
+SPEC = importlib.util.spec_from_file_location("resolve_linux_ci_image_tag", SCRIPT)
+MODULE = importlib.util.module_from_spec(SPEC)
+sys.modules[SPEC.name] = MODULE
+SPEC.loader.exec_module(MODULE)
+
+
+def version(version_id, tags):
+ return MODULE.Version(
+ id=version_id,
+ digest=f"sha256:{version_id:064x}",
+ created_at=datetime(2026, 8, 18, tzinfo=timezone.utc),
+ tags=tuple(tags),
+ )
+
+
+class FakeClient:
+ def __init__(self, packages):
+ self.packages = packages
+
+ def list_versions(self, owner, package):
+ return self.packages.get(package, [])
+
+
+class ResolveTests(unittest.TestCase):
+ def coherent(self):
+ tag = "build-20260818-123-1"
+ return tag, {
+ package: [
+ version(
+ index,
+ (tag, "stable")
+ if package in (MODULE.NORMAL_PACKAGE, MODULE.ARMHF_PACKAGE)
+ else (tag,),
+ )
+ ]
+ for index, package in enumerate(
+ (
+ MODULE.NORMAL_PACKAGE,
+ *MODULE.ROUTINE_PACKAGES,
+ MODULE.ARMHF_PACKAGE,
+ MODULE.ARMHF_CROSS_PACKAGE,
+ ),
+ start=1,
+ )
+ }
+
+ def test_resolves_build_tag_attached_to_stable_pointer(self):
+ tag, packages = self.coherent()
+ self.assertEqual(MODULE.resolve(FakeClient(packages)), tag)
+
+ def test_rejects_missing_generation_member(self):
+ _, packages = self.coherent()
+ packages[MODULE.ARM64_PACKAGE] = []
+ with self.assertRaisesRegex(RuntimeError, "does not exist"):
+ MODULE.resolve(FakeClient(packages))
+
+ def test_strict_resolution_rejects_missing_armhf(self):
+ _, packages = self.coherent()
+ packages[MODULE.ARMHF_PACKAGE] = []
+ with self.assertRaisesRegex(RuntimeError, "does not exist"):
+ MODULE.resolve(FakeClient(packages), require_armhf=True)
+
+ def test_routine_resolution_does_not_require_armhf(self):
+ tag, packages = self.coherent()
+ packages.pop(MODULE.ARMHF_PACKAGE)
+ self.assertEqual(MODULE.resolve(FakeClient(packages)), tag)
+
+ def test_armhf_resolution_uses_armhf_stable_pointer(self):
+ tag, packages = self.coherent()
+ self.assertEqual(MODULE.resolve_armhf(FakeClient(packages)), tag)
+
+ def test_armhf_resolution_requires_armhf_stable_pointer(self):
+ _, packages = self.coherent()
+ packages[MODULE.ARMHF_PACKAGE] = []
+ with self.assertRaisesRegex(RuntimeError, "armhf.*stable is missing"):
+ MODULE.resolve_armhf(FakeClient(packages))
+
+ def test_armhf_resolution_requires_matching_cross_builder(self):
+ _, packages = self.coherent()
+ packages[MODULE.ARMHF_CROSS_PACKAGE] = []
+ with self.assertRaisesRegex(RuntimeError, "linux-armhf-cross-bookworm"):
+ MODULE.resolve_armhf(FakeClient(packages))
+
+ def test_tsan_resolution_uses_tsan_stable_pointer(self):
+ tag, packages = self.coherent()
+ packages[MODULE.TSAN_PACKAGE] = [version(8, (tag, "stable"))]
+ self.assertEqual(MODULE.resolve_tsan(FakeClient(packages)), tag)
+
+ def test_tsan_resolution_requires_tsan_stable_pointer(self):
+ _, packages = self.coherent()
+ packages[MODULE.TSAN_PACKAGE] = []
+ with self.assertRaisesRegex(RuntimeError, "TSan.*stable is missing"):
+ MODULE.resolve_tsan(FakeClient(packages))
+
+ def test_rejects_ambiguous_stable_pointer(self):
+ _, packages = self.coherent()
+ packages[MODULE.NORMAL_PACKAGE].append(version(9, ("stable",)))
+ with self.assertRaisesRegex(RuntimeError, "expected one"):
+ MODULE.resolve(FakeClient(packages))
+
+ def test_reports_missing_promoted_generation(self):
+ _, packages = self.coherent()
+ packages[MODULE.NORMAL_PACKAGE] = []
+ with self.assertRaisesRegex(RuntimeError, "No promoted Linux CI image generation"):
+ MODULE.resolve(FakeClient(packages))
+
+ def test_rejects_stable_without_build_tag(self):
+ _, packages = self.coherent()
+ packages[MODULE.NORMAL_PACKAGE] = [version(1, ("stable", "candidate-123-1"))]
+ with self.assertRaisesRegex(RuntimeError, "exactly one"):
+ MODULE.resolve(FakeClient(packages))
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/.github/scripts/tests/test_should_refresh_linux_ci_images.py b/.github/scripts/tests/test_should_refresh_linux_ci_images.py
new file mode 100644
index 00000000..0b589dac
--- /dev/null
+++ b/.github/scripts/tests/test_should_refresh_linux_ci_images.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python3
+
+import importlib.util
+import sys
+import unittest
+from datetime import datetime, timedelta, timezone
+from pathlib import Path
+
+
+SCRIPT = Path(__file__).parents[1] / "should-refresh-linux-ci-images.py"
+SPEC = importlib.util.spec_from_file_location("should_refresh_linux_ci_images", SCRIPT)
+MODULE = importlib.util.module_from_spec(SPEC)
+sys.modules[SPEC.name] = MODULE
+SPEC.loader.exec_module(MODULE)
+
+
+def version(version_id, age_days, tags, now):
+ return MODULE.Version(
+ id=version_id,
+ digest=f"sha256:{version_id:064x}",
+ created_at=now - timedelta(days=age_days),
+ tags=tuple(tags),
+ )
+
+
+class RefreshDecisionTests(unittest.TestCase):
+ def setUp(self):
+ self.now = datetime(2026, 8, 25, tzinfo=timezone.utc)
+
+ def test_keeps_recent_stable_image(self):
+ refresh, age_days = MODULE.should_refresh(
+ [version(1, 29, ("stable", "build-20260801-1-1"), self.now)],
+ now=self.now,
+ max_age_days=30,
+ )
+ self.assertFalse(refresh)
+ self.assertEqual(age_days, 29)
+
+ def test_refreshes_old_stable_image(self):
+ refresh, age_days = MODULE.should_refresh(
+ [version(1, 30, ("stable", "build-20260726-1-1"), self.now)],
+ now=self.now,
+ max_age_days=30,
+ )
+ self.assertTrue(refresh)
+ self.assertEqual(age_days, 30)
+
+ def test_rejects_missing_or_ambiguous_stable_image(self):
+ with self.assertRaisesRegex(RuntimeError, "found 0"):
+ MODULE.should_refresh([], now=self.now, max_age_days=30)
+ with self.assertRaisesRegex(RuntimeError, "found 2"):
+ MODULE.should_refresh(
+ [
+ version(1, 1, ("stable",), self.now),
+ version(2, 2, ("stable",), self.now),
+ ],
+ now=self.now,
+ max_age_days=30,
+ )
+
+
+if __name__ == "__main__":
+ unittest.main()