Repository navigation
ci: tolerate optional S3 cache export outages on v4.3-dev #5187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ktechmidas
wants to merge
2
commits into
v5.1-dev
Choose a base branch
from
ci/v43-optional-cache-rollout-20260929
base: v5.1-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| """Execute the cache settings action with synthetic, credential-free inputs.""" | ||
| import json | ||
| from pathlib import Path | ||
| import subprocess | ||
| import textwrap | ||
| import unittest | ||
|
|
||
| ROOT = Path(__file__).resolve().parents[3] | ||
|
|
||
|
|
||
| class LayerCacheTests(unittest.TestCase): | ||
| def settings(self, shared=False, endpoint='https://cache.example.invalid'): | ||
| action = (ROOT / '.github/actions/s3-layer-cache-settings/action.yaml').read_text() | ||
| script = textwrap.dedent(action.split(' script: |\n', 1)[1]) | ||
| values = {'inputs.region': 'test-region', 'inputs.bucket': 'test-bucket', | ||
| 'inputs.prefix': 'cache-layers/linux/amd64/', 'inputs.endpoint': endpoint, | ||
| 'inputs.head_ref': 'refs/pull/42/merge', 'inputs.name': 'dashmate-helper', | ||
| 'github.sha': 'a' * 40, 'inputs.mode': 'max', | ||
| 'inputs.cache_to_name': str(shared).lower()} | ||
| for key, value in values.items(): | ||
| script = script.replace('${{ ' + key + ' }}', value) | ||
| self.assertNotIn('${{', script) | ||
| harness = 'const output = {}; const core = {setOutput: (k, v) => output[k] = v};\n' | ||
| result = subprocess.check_output(['node', '-e', harness + script | ||
| + '\nconsole.log(JSON.stringify(output));'], text=True) | ||
| return json.loads(result) | ||
|
|
||
| def test_should_tolerate_only_export_errors_and_preserve_imports(self): | ||
| settings = self.settings() | ||
| self.assertTrue(settings['cache_to'].endswith(',ignore-error=true')) | ||
| self.assertEqual(settings['cache_to'].count('ignore-error='), 1) | ||
| imports = settings['cache_from'].splitlines() | ||
| self.assertEqual(len(imports), 3) | ||
| for item in imports: | ||
| self.assertNotIn('ignore-error', item) | ||
| self.assertNotIn('mode=', item) | ||
| self.assertIn('prefix=cache-layers/linux/amd64/', item) | ||
| self.assertIn('endpoint_url=https://cache.example.invalid', item) | ||
| expected = 'dashmate-helper_sha_' + 'a' * 40 + ';dashmate-helper_tag_refs-pull-42-merge' | ||
| self.assertIn('name=' + expected + ',ignore-error=true', settings['cache_to']) | ||
|
|
||
| def test_should_keep_shared_manifest_writes_explicitly_opt_in(self): | ||
| self.assertNotIn(';dashmate-helper,', self.settings()['cache_to']) | ||
| self.assertIn(';dashmate-helper,ignore-error=true', self.settings(shared=True)['cache_to']) | ||
| self.assertNotIn('endpoint_url=', self.settings(endpoint='')['cache_to']) | ||
|
|
||
| def test_should_not_ignore_build_or_registry_publication_failures(self): | ||
| action = (ROOT / '.github/actions/docker/action.yaml').read_text() | ||
| build = action.split(' - name: Build and push Docker image', 1)[1] | ||
| self.assertNotIn('continue-on-error', build) | ||
| self.assertNotIn('ignore-error', build) | ||
| self.assertIn('cache-to: ${{ steps.layer_cache_settings.outputs.cache_to }}', build) | ||
| self.assertIn('name-canonical=true,push=true', build) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| name: Cache action regression tests | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - '.github/actions/s3-layer-cache-settings/**' | ||
| - '.github/actions/docker/**' | ||
| - '.github/scripts/tests/test_s3_layer_cache.py' | ||
| - '.github/workflows/cache-action-tests.yml' | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| cache-action-tests: | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| - name: Test optional cache export and fatal publication boundaries | ||
| run: python3 -m unittest discover -s .github/scripts/tests -p 'test_s3_layer_cache.py' -v |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.