From 058f54d95db0489fe0a6cd0b65f8afdd9cb160a9 Mon Sep 17 00:00:00 2001 From: Christoph Kattmann Date: Sun, 6 Sep 2026 20:36:41 +0200 Subject: [PATCH] fix(component-test): let deploy test jobs reuse the Gradle build cache [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. --- .github/workflows/component-test-kotlin.yml | 25 ++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/component-test-kotlin.yml b/.github/workflows/component-test-kotlin.yml index 84a8d6a9..c8a19517 100644 --- a/.github/workflows/component-test-kotlin.yml +++ b/.github/workflows/component-test-kotlin.yml @@ -71,7 +71,22 @@ jobs: with: distribution: "corretto" java-version: ${{ inputs.java-version }} - cache: 'gradle' + # setup-java's own `cache: gradle` keys on a hash of the dependency files and skips saving on an + # exact hit, so the build-cache-1 inside it is a frozen snapshot: every deploy re-runs KSP and + # both Kotlin compiles from scratch. Key on the commit instead, like pull-request-kotlin.yml, + # and fall back to the previous deploy (and to any main-scoped Gradle cache) so task outputs + # accumulate and unchanged compilation comes back FROM-CACHE. + - name: Restore Gradle cache + id: gradle-cache + uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-deploy-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-gradle-deploy- + ${{ runner.os }}-gradle- - name: Test project env: GHL_USERNAME: ${{ secrets.GHL_USERNAME }} @@ -93,3 +108,11 @@ jobs: /home/runner/.gradle/daemon/**/daemon-*.out.log retention-days: 2 overwrite: true + - name: Save Gradle cache + if: ${{ always() && steps.gradle-cache.outputs.cache-hit != 'true' }} + uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 # v5 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-deploy-${{ github.sha }}