diff --git a/python/test/test_action_yml.py b/python/test/test_action_yml.py index b8fc9cec..d016858d 100644 --- a/python/test/test_action_yml.py +++ b/python/test/test_action_yml.py @@ -1,3 +1,4 @@ +import hashlib import pathlib import unittest @@ -28,6 +29,15 @@ def test_composite_action(self): self.assertEqual(dockerfile_action_wo_runs, composite_action_wo_runs) self.assertIn(('using', 'composite'), composite_action.get('runs', {}).items()) + # check cache key hash is up-to-date in composite action + with open(project_root / 'python' / 'requirements.txt', mode='rb') as r: + expected_hash = hashlib.md5(r.read()).hexdigest() + cache_hash = next(step.get('with', {}).get('key', '').split('-')[-1] + for step in composite_action.get('runs', {}).get('steps', []) + if step.get('uses', '').startswith('actions/cache/restore@')) + self.assertEqual(expected_hash, cache_hash, msg='Changing python/requirements.txt requires ' + 'to update the MD5 hash in composite/action.yaml') + def test_composite_inputs(self): with open(project_root / 'composite/action.yml', encoding='utf-8') as r: action = yaml.safe_load(r)