Skip to content

Commit 72529bc

Browse files
authored
Merge pull request #15935 from apache/ci/branch-keyed-dependency-cache
make CI dependency caching actually work (branch-keyed jar cache)
2 parents 4a8769e + 71208cf commit 72529bc

2 files changed

Lines changed: 156 additions & 22 deletions

File tree

.github/workflows/gradle.yml

Lines changed: 143 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ jobs:
3636
with:
3737
distribution: liberica
3838
java-version: 17
39+
- name: "🗄️ Restore dependency jar cache"
40+
uses: actions/cache@v4
41+
with:
42+
# Cache only downloaded dependency jars and wrapper distributions, never Grails build outputs.
43+
# Keyed by branch version so each release branch maintains its own warm cache.
44+
path: |
45+
~/.gradle/caches/modules-2
46+
~/.gradle/wrapper
47+
key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }}
48+
restore-keys: |
49+
gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-
3950
- name: "🐘 Setup Gradle"
4051
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
4152
with:
@@ -69,10 +80,21 @@ jobs:
6980
with:
7081
distribution: liberica
7182
java-version: ${{ matrix.java }}
83+
- name: "🗄️ Restore dependency jar cache"
84+
uses: actions/cache@v4
85+
with:
86+
# Cache only downloaded dependency jars and wrapper distributions, never Grails build outputs.
87+
# Keyed by branch version so each release branch maintains its own warm cache.
88+
path: |
89+
~/.gradle/caches/modules-2
90+
~/.gradle/wrapper
91+
key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }}
92+
restore-keys: |
93+
gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-
7294
- name: "🐘 Setup Gradle"
7395
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
7496
with:
75-
cache-provider: basic # 'basic' uses the MIT-licensed, open-source cache provider; the default 'enhanced' provider (v6+) is proprietary (Gradle commercial Terms of Use)
97+
cache-disabled: true # dependency jars are cached by the explicit branch-keyed step above
7698
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
7799
- name: "🔍 Setup TestLens"
78100
uses: testlens-app/setup-testlens@d96a555133c275a00949d2cc77b70fe9a4242ebf # v1.9.2
@@ -122,10 +144,21 @@ jobs:
122144
with:
123145
distribution: liberica
124146
java-version: ${{ matrix.java }}
147+
- name: "🗄️ Restore dependency jar cache"
148+
uses: actions/cache@v4
149+
with:
150+
# Cache only downloaded dependency jars and wrapper distributions, never Grails build outputs.
151+
# Keyed by branch version so each release branch maintains its own warm cache.
152+
path: |
153+
~/.gradle/caches/modules-2
154+
~/.gradle/wrapper
155+
key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }}
156+
restore-keys: |
157+
gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-
125158
- name: "🐘 Setup Gradle"
126159
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
127160
with:
128-
cache-provider: basic # 'basic' uses the MIT-licensed, open-source cache provider; the default 'enhanced' provider (v6+) is proprietary (Gradle commercial Terms of Use)
161+
cache-disabled: true # dependency jars are cached by the explicit branch-keyed step above
129162
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
130163
- name: "🔍 Setup TestLens"
131164
uses: testlens-app/setup-testlens@d96a555133c275a00949d2cc77b70fe9a4242ebf # v1.9.2
@@ -156,10 +189,21 @@ jobs:
156189
with:
157190
distribution: liberica
158191
java-version: ${{ matrix.java }}
192+
- name: "🗄️ Restore dependency jar cache"
193+
uses: actions/cache@v4
194+
with:
195+
# Cache only downloaded dependency jars and wrapper distributions, never Grails build outputs.
196+
# Keyed by branch version so each release branch maintains its own warm cache.
197+
path: |
198+
~/.gradle/caches/modules-2
199+
~/.gradle/wrapper
200+
key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }}
201+
restore-keys: |
202+
gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-
159203
- name: "🐘 Setup Gradle"
160204
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
161205
with:
162-
cache-provider: basic # 'basic' uses the MIT-licensed, open-source cache provider; the default 'enhanced' provider (v6+) is proprietary (Gradle commercial Terms of Use)
206+
cache-disabled: true # dependency jars are cached by the explicit branch-keyed step above
163207
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
164208
- name: "🔍 Setup TestLens"
165209
uses: testlens-app/setup-testlens@d96a555133c275a00949d2cc77b70fe9a4242ebf # v1.9.2
@@ -188,10 +232,21 @@ jobs:
188232
with:
189233
distribution: 'liberica'
190234
java-version: ${{ matrix.java }}
235+
- name: "🗄️ Restore dependency jar cache"
236+
uses: actions/cache@v4
237+
with:
238+
# Cache only downloaded dependency jars and wrapper distributions, never Grails build outputs.
239+
# Keyed by branch version so each release branch maintains its own warm cache.
240+
path: |
241+
~/.gradle/caches/modules-2
242+
~/.gradle/wrapper
243+
key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }}
244+
restore-keys: |
245+
gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-
191246
- name: "🐘 Setup Gradle"
192247
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
193248
with:
194-
cache-provider: basic # 'basic' uses the MIT-licensed, open-source cache provider; the default 'enhanced' provider (v6+) is proprietary (Gradle commercial Terms of Use)
249+
cache-disabled: true # dependency jars are cached by the explicit branch-keyed step above
195250
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
196251
- name: "🔍 Setup TestLens"
197252
uses: testlens-app/setup-testlens@d96a555133c275a00949d2cc77b70fe9a4242ebf # v1.9.2
@@ -247,10 +302,21 @@ jobs:
247302
with:
248303
distribution: liberica
249304
java-version: ${{ matrix.java }}
305+
- name: "🗄️ Restore dependency jar cache"
306+
uses: actions/cache@v4
307+
with:
308+
# Cache only downloaded dependency jars and wrapper distributions, never Grails build outputs.
309+
# Keyed by branch version so each release branch maintains its own warm cache.
310+
path: |
311+
~/.gradle/caches/modules-2
312+
~/.gradle/wrapper
313+
key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }}
314+
restore-keys: |
315+
gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-
250316
- name: "🐘 Setup Gradle"
251317
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
252318
with:
253-
cache-provider: basic # 'basic' uses the MIT-licensed, open-source cache provider; the default 'enhanced' provider (v6+) is proprietary (Gradle commercial Terms of Use)
319+
cache-disabled: true # dependency jars are cached by the explicit branch-keyed step above
254320
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
255321
- name: "🔍 Setup TestLens"
256322
uses: testlens-app/setup-testlens@d96a555133c275a00949d2cc77b70fe9a4242ebf # v1.9.2
@@ -399,10 +465,21 @@ jobs:
399465
with:
400466
distribution: liberica
401467
java-version: ${{ matrix.java }}
468+
- name: "🗄️ Restore dependency jar cache"
469+
uses: actions/cache@v4
470+
with:
471+
# Cache only downloaded dependency jars and wrapper distributions, never Grails build outputs.
472+
# Keyed by branch version so each release branch maintains its own warm cache.
473+
path: |
474+
~/.gradle/caches/modules-2
475+
~/.gradle/wrapper
476+
key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }}
477+
restore-keys: |
478+
gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-
402479
- name: "🐘 Setup Gradle"
403480
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
404481
with:
405-
cache-provider: basic # 'basic' uses the MIT-licensed, open-source cache provider; the default 'enhanced' provider (v6+) is proprietary (Gradle commercial Terms of Use)
482+
cache-disabled: true # dependency jars are cached by the explicit branch-keyed step above
406483
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
407484
- name: "🏃 Run Functional Tests"
408485
env:
@@ -433,10 +510,21 @@ jobs:
433510
with:
434511
distribution: liberica
435512
java-version: ${{ matrix.java }}
513+
- name: "🗄️ Restore dependency jar cache"
514+
uses: actions/cache@v4
515+
with:
516+
# Cache only downloaded dependency jars and wrapper distributions, never Grails build outputs.
517+
# Keyed by branch version so each release branch maintains its own warm cache.
518+
path: |
519+
~/.gradle/caches/modules-2
520+
~/.gradle/wrapper
521+
key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }}
522+
restore-keys: |
523+
gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-
436524
- name: "🐘 Setup Gradle"
437525
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
438526
with:
439-
cache-provider: basic # 'basic' uses the MIT-licensed, open-source cache provider; the default 'enhanced' provider (v6+) is proprietary (Gradle commercial Terms of Use)
527+
cache-disabled: true # dependency jars are cached by the explicit branch-keyed step above
440528
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
441529
- name: "🏃 Run Functional Tests"
442530
env:
@@ -462,10 +550,21 @@ jobs:
462550
with:
463551
distribution: liberica
464552
java-version: 17
553+
- name: "🗄️ Restore dependency jar cache"
554+
uses: actions/cache@v4
555+
with:
556+
# Cache only downloaded dependency jars and wrapper distributions, never Grails build outputs.
557+
# Keyed by branch version so each release branch maintains its own warm cache.
558+
path: |
559+
~/.gradle/caches/modules-2
560+
~/.gradle/wrapper
561+
key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }}
562+
restore-keys: |
563+
gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-
465564
- name: "🐘 Setup Gradle"
466565
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
467566
with:
468-
cache-provider: basic # 'basic' uses the MIT-licensed, open-source cache provider; the default 'enhanced' provider (v6+) is proprietary (Gradle commercial Terms of Use)
567+
cache-disabled: true # dependency jars are cached by the explicit branch-keyed step above
469568
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
470569
- name: "🔍 Setup TestLens"
471570
uses: testlens-app/setup-testlens@d96a555133c275a00949d2cc77b70fe9a4242ebf # v1.9.2
@@ -516,10 +615,21 @@ jobs:
516615
with:
517616
distribution: liberica
518617
java-version: 17
618+
- name: "🗄️ Restore dependency jar cache"
619+
uses: actions/cache@v4
620+
with:
621+
# Cache only downloaded dependency jars and wrapper distributions, never Grails build outputs.
622+
# Keyed by branch version so each release branch maintains its own warm cache.
623+
path: |
624+
~/.gradle/caches/modules-2
625+
~/.gradle/wrapper
626+
key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }}
627+
restore-keys: |
628+
gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-
519629
- name: "🐘 Setup Gradle"
520630
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
521631
with:
522-
cache-provider: basic # 'basic' uses the MIT-licensed, open-source cache provider; the default 'enhanced' provider (v6+) is proprietary (Gradle commercial Terms of Use)
632+
cache-disabled: true # dependency jars are cached by the explicit branch-keyed step above
523633
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
524634
- name: "🔍 Setup TestLens"
525635
uses: testlens-app/setup-testlens@d96a555133c275a00949d2cc77b70fe9a4242ebf # v1.9.2
@@ -571,10 +681,21 @@ jobs:
571681
with:
572682
distribution: liberica
573683
java-version: 17
684+
- name: "🗄️ Restore dependency jar cache"
685+
uses: actions/cache@v4
686+
with:
687+
# Cache only downloaded dependency jars and wrapper distributions, never Grails build outputs.
688+
# Keyed by branch version so each release branch maintains its own warm cache.
689+
path: |
690+
~/.gradle/caches/modules-2
691+
~/.gradle/wrapper
692+
key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }}
693+
restore-keys: |
694+
gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-
574695
- name: "🐘 Setup Gradle"
575696
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
576697
with:
577-
cache-provider: basic # 'basic' uses the MIT-licensed, open-source cache provider; the default 'enhanced' provider (v6+) is proprietary (Gradle commercial Terms of Use)
698+
cache-disabled: true # dependency jars are cached by the explicit branch-keyed step above
578699
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
579700
- name: "🔍 Setup TestLens"
580701
uses: testlens-app/setup-testlens@d96a555133c275a00949d2cc77b70fe9a4242ebf # v1.9.2
@@ -671,10 +792,21 @@ jobs:
671792
with:
672793
distribution: liberica
673794
java-version: 17
795+
- name: "🗄️ Restore dependency jar cache"
796+
uses: actions/cache@v4
797+
with:
798+
# Cache only downloaded dependency jars and wrapper distributions, never Grails build outputs.
799+
# Keyed by branch version so each release branch maintains its own warm cache.
800+
path: |
801+
~/.gradle/caches/modules-2
802+
~/.gradle/wrapper
803+
key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }}
804+
restore-keys: |
805+
gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-
674806
- name: "🐘 Setup Gradle"
675807
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
676808
with:
677-
cache-provider: basic # 'basic' uses the MIT-licensed, open-source cache provider; the default 'enhanced' provider (v6+) is proprietary (Gradle commercial Terms of Use)
809+
cache-disabled: true # dependency jars are cached by the explicit branch-keyed step above
678810
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
679811
- name: "🔨 Build Snapshot Documentation"
680812
run: >

.github/workflows/groovy-joint-workflow.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ jobs:
4040
with:
4141
java-version: 17
4242
distribution: liberica
43-
- name: "🗄️ Cache local Maven repository"
44-
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
45-
with:
46-
path: ~/.m2/repository
47-
key: cache-local-maven-${{ github.sha }}
4843
- name: "📥 Checkout Grails Core to fetch Gradle Plugin versions it uses"
4944
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5045
with:
@@ -65,7 +60,7 @@ jobs:
6560
- name: "🐘 Setup Gradle"
6661
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
6762
with:
68-
cache-provider: basic # 'basic' uses the MIT-licensed, open-source cache provider; the default 'enhanced' provider (v6+) is proprietary (Gradle commercial Terms of Use)
63+
cache-disabled: true # this workflow rebuilds Groovy each run; a Gradle home cache is not useful here
6964
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
7065
- name: "🔍 Setup TestLens"
7166
uses: testlens-app/setup-testlens@d96a555133c275a00949d2cc77b70fe9a4242ebf # v1.9.2
@@ -124,6 +119,13 @@ jobs:
124119
run: |
125120
cd groovy
126121
./gradlew pTML -x groovydoc -x javadoc -x javadocAll -x groovydocAll -x asciidoc -x docGDK
122+
- name: "📤 Share locally built Groovy artifacts with the build_grails job"
123+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
124+
with:
125+
name: local-groovy-maven-repo
126+
path: ~/.m2/repository/org/apache/groovy/
127+
if-no-files-found: 'error'
128+
retention-days: 1
127129

128130
build_grails:
129131
needs: [build_groovy]
@@ -149,15 +151,15 @@ jobs:
149151
- name: "🐘 Setup Gradle"
150152
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
151153
with:
152-
cache-provider: basic # 'basic' uses the MIT-licensed, open-source cache provider; the default 'enhanced' provider (v6+) is proprietary (Gradle commercial Terms of Use)
154+
cache-disabled: true # this workflow rebuilds Groovy each run; a Gradle home cache is not useful here
153155
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
154156
- name: "🔍 Setup TestLens"
155157
uses: testlens-app/setup-testlens@d96a555133c275a00949d2cc77b70fe9a4242ebf # v1.9.2
156-
- name: "🗄️ Restore local Maven repository from cache"
157-
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
158+
- name: "📥 Fetch the locally built Groovy artifacts"
159+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
158160
with:
159-
path: ~/.m2/repository
160-
key: cache-local-maven-${{ github.sha }}
161+
name: local-groovy-maven-repo
162+
path: ~/.m2/repository/org/apache/groovy
161163
- name: 'Swap Groovy Version'
162164
run: |
163165
sed -i "/['\"]groovy\.version['\"][[:space:]]*:/c\'groovy.version':'${{ needs.build_groovy.outputs.groovyVersion }}'," dependencies.gradle

0 commit comments

Comments
 (0)