mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 04:25:38 +00:00
ci: save the Robolectric jar cache from main only (#3604)
A pull request's cache entry is visible only to that pull request, so each PR stored its own ~830 MB copy that no other PR could restore, while new PRs started from main's incomplete set and downloaded the rest from Maven Central, where the 429s come from. The copies also kept the repository at its 10 GB cache limit and pushed out other caches.
This commit is contained in:
1 parent
c514c59018
commit
ecbda604e2
2 files changed
+10
-1
No files matched your search
@@ -178,8 +178,10 @@ jobs:
|
||||
PY
|
||||
after=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)
|
||||
[ "$after" -gt "${ROBOLECTRIC_JARS_BEFORE:-0}" ] && echo "save=true" >> "$GITHUB_OUTPUT" || true
|
||||
# A pull request's cache is visible only to that pull request, and each copy is hundreds of megabytes against the
|
||||
# repository's 10 GB cache limit. Only main saves, so every pull request restores main's set.
|
||||
- name: Store Robolectric's Android jars
|
||||
if: always() && steps.robolectric-jars-final.outputs.save == 'true'
|
||||
if: always() && github.event_name != 'pull_request' && steps.robolectric-jars-final.outputs.save == 'true'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: ${{ steps.robolectric-jars.outputs.path }}
|
||||
|
||||
@@ -33,6 +33,13 @@ class CiChecksTest(unittest.TestCase):
|
||||
robolectric = [cache['path'] for cache in caches if cache['key'].startswith('robolectric-')]
|
||||
self.assertEqual(robolectric, ['${{ steps.robolectric-jars.outputs.path }}'] * 2)
|
||||
|
||||
def test_only_main_saves_the_robolectric_cache(self):
|
||||
steps = yaml.safe_load((ROOT / '.github/workflows/unit-tests.yml').read_text())['jobs']['unit-tests']['steps']
|
||||
saves = [step for step in steps if step.get('uses', '').startswith('actions/cache/save')
|
||||
and step['with']['key'].startswith('robolectric-')]
|
||||
self.assertEqual(len(saves), 1)
|
||||
self.assertIn("github.event_name != 'pull_request'", saves[0]['if'])
|
||||
|
||||
def test_unit_test_retry_requires_maven_exception(self):
|
||||
steps = yaml.safe_load((ROOT / '.github/workflows/unit-tests.yml').read_text())['jobs']['unit-tests']['steps']
|
||||
run = next(step['run'] for step in steps if step.get('id') == 'unit-tests')
|
||||
|
||||
Reference in new issue
Block a user