summaryrefslogtreecommitdiff
path: root/.github/scripts/tests/test_linux_ccache_policy.py
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/test_linux_ccache_policy.py
parentd83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff)
New upstream version 3.2.0~rc1+dfsgupstream/3.2.0_rc1+dfsg
Diffstat (limited to '.github/scripts/tests/test_linux_ccache_policy.py')
-rw-r--r--.github/scripts/tests/test_linux_ccache_policy.py99
1 files changed, 99 insertions, 0 deletions
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()