diff options
| author | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
| commit | c25cbdf6fb6d946175f4335fab77bfea601b56db (patch) | |
| tree | 6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /.github/scripts/tests/test_linux_ccache_policy.py | |
| parent | 71f5689252c9f13e70e1c24856904475b2307809 (diff) | |
| parent | 0685fcada9f95fe90f70b387cd7d757da8209624 (diff) | |
Merge tag 'debian/3.2.0_rc1+dfsg-2' into debian/trixie-backportsdebian/trixie-backports
tagging wsjtx 3.2.0~rc1+dfsg-2
Diffstat (limited to '.github/scripts/tests/test_linux_ccache_policy.py')
| -rw-r--r-- | .github/scripts/tests/test_linux_ccache_policy.py | 99 |
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() |
