Repository navigation
feat(component-test): opt-in Gradle build cache for deploy test jobs [ENERGY-2742] - #340
Merged
Merged
Conversation
…e [ENERGY-2742] The test job cached Gradle only through actions/setup-java's cache: 'gradle', which keys on a hash of the dependency files and, on an exact primary-key hit, does not save. The build-cache-1 inside that archive is therefore a frozen snapshot that never accumulates task outputs, so every deploy re-runs KSP and both Kotlin compiles from scratch. service-energy production deploy 2026-09-06 (run 34027976026): 'Test project' 6m33s, 'BUILD SUCCESSFUL in 6m 31s', '11 actionable tasks: 11 executed', nothing FROM-CACHE; :kspKotlin ~63s, :compileKotlin ~45s, :kspTestKotlin ~30s, :compileTestKotlin ~30s. The pull-request workflow restores the same tasks FROM-CACHE because it keys actions/cache on the commit and saves after a non-exact restore. Mirror that here: drop setup-java's cache input, restore with a per-commit key plus '-gradle-deploy-' and '-gradle-' fallbacks, and save only when the restore was not an exact hit.
Contributor
Author
|
Update on the validation note: the repo's |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014AaR9VvceeKm4EFQLLHX3s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014AaR9VvceeKm4EFQLLHX3s
ckattmann
marked this pull request as ready for review
October 4, 2026 13:39
Contributor
|
@ckattmann regarding the cache storage, for ARC we are using a different cache package which stores on S3, could that be used for this? |
Contributor
Author
@joscdk If you mean |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C1bF6Xi6hHBry6WzgP3tCN
joscdk
approved these changes
Oct 7, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The
testjob incomponent-test-kotlin.yml(used bydeploy-kotlin.ymlanddeploy-kotlin-v2.yml) caches Gradle only viaactions/setup-java'scache: 'gradle'. That key is a hash of the dependency files andactions/cacheskips saving on a primary-key hit, so the~/.gradle/caches/build-cache-1inside the archive is a frozen snapshot that never accumulates task outputs.Every deploy therefore runs all test-job tasks from scratch, including the prod deploy of a SHA that the staging deploy already tested.
Evidence (service-energy, 2026-09-23 to 2026-10-03)
main@4443e1b5):Test project3m31s,BUILD SUCCESSFUL in 3m 30s,11 actionable tasks: 11 executed, cache logCache hit occurred on the primary key …, not saving cache.Test projectacross the last five prod deploys: 3m31s, 4m32s, 4m26s, 3m59s, 3m48s.4443e1b5).kspKotlin,compileKotlin,compileTestKotlin,:testand the kover reports allFROM-CACHE,BUILD SUCCESSFUL in 23s.actions/cacherestored still ran every task (15 actionable tasks: 15 executed).Change
Opt-in input
cache-gradle-build-outputs(defaultfalse, so no behaviour change for existing callers) oncomponent-test-kotlin.yml, forwarded bydeploy-kotlin.ymlanddeploy-kotlin-v2.yml. Whentrue:actions/setup-javaruns withoutcache: gradleRestore Gradle cache(actions/cache/restore) over~/.gradle/caches+~/.gradle/wrapper, key${{ runner.os }}-gradle-deploy-${{ github.sha }}, restore-keys…-gradle-deploy-then…-gradle-Save Gradle cacheguarded byalways() && steps.gradle-cache.outputs.cache-hit != 'true'Staging (push to
main) and prod (dispatch frommain) share cache scope, so the prod deploy gets an exact hit on the key the staging deploy saved. A service opts in withcache-gradle-build-outputs: truein its deploy workflows.Measured effect
Throwaway branch in service-energy calling this branch's
component-test-kotlin.yml(test job only, no deploy; Blacksmith 16 vCPU arm64, same config as the deploy).Test projectstep, same sources every time:Test projectcompileKotlin,compileTestKotlin,:test):test):testcame from cache in 2 of 4 follow-up runs; in the other two its cache key changed between runs and I did not find out why.:kspKotlinand:kspTestKotlinnever came from cache (about 45 s plus 15 s); their keys differ on every run.Considerations for reviewers
setup-javaarchive, since it now holds build-cache entries). Restore takes ~15 s, save ~9 s.actions/cachegoes through Blacksmith's cache, not GitHub's. I don't know how that storage is billed; please check.main, or key per branch (loses the staging to prod exact hit).:testresult when inputs are identical (normal Gradle semantics). Tests that depend on time or external state are not re-run at prod.code-coverage-kotlin.ymlandcomponent-service-profile-kotlin.ymlhave been removed or changed onmain; not touched here.Ticket: https://montaapp.atlassian.net/browse/ENERGY-2742 (draft, CODEOWNERS is @monta-app/sre)
🤖 Generated with Claude Code
https://claude.ai/code/session_014AaR9VvceeKm4EFQLLHX3s