Skip to content

Commit bd56e0b

Browse files
committed
Use explicit save/restore cache actions.
This is to force a save, even in case of cache hit, as the contents of the directory may have changed. Signed-off-by: Eric Bottard <[email protected]> Auto-cherry-pick to 1.1.x
1 parent 95bf79a commit bd56e0b

File tree

2 files changed

+51
-18
lines changed

2 files changed

+51
-18
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,25 @@ jobs:
2929
distribution: 'temurin'
3030
cache: 'maven'
3131

32-
- name: Setup Maven Build-Cache (~/.m2/build-cache)
32+
- name: Restore Maven Build-Cache (~/.m2/build-cache)
3333
if: ${{ github.event_name != 'schedule' }}
34-
uses: actions/cache@v4
34+
uses: actions/cache/restore@v4
3535
with:
3636
path: ~/.m2/build-cache
37-
key: build-cache-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
37+
key: build-cache-${{ runner.os }}-${{ hashFiles('**/pom.xml', '!**/target/**') }}
3838
restore-keys: |
3939
build-cache-${{ runner.os }}-
4040
4141
- name: Build all modules with unit tests
4242
run: |
4343
./mvnw --batch-mode -ntp --update-snapshots clean install
4444
45+
- name: Save Maven Build-Cache (~/.m2/build-cache)
46+
uses: actions/cache/save@v4
47+
with:
48+
path: ~/.m2/build-cache
49+
key: build-cache-${{ runner.os }}-${{ hashFiles('**/pom.xml', '!**/target/**') }}
50+
4551
- name: Upload Spring-AI Built Artifacts
4652
uses: actions/upload-artifact@v4
4753
with:
@@ -78,12 +84,12 @@ jobs:
7884
distribution: 'temurin'
7985
cache: 'maven'
8086

81-
- name: Setup Maven Build-Cache (~/.m2/build-cache)
82-
uses: actions/cache@v4
87+
- name: Restore Maven Build-Cache (~/.m2/build-cache)
8388
if: ${{ github.event_name != 'schedule' }}
89+
uses: actions/cache/restore@v4
8490
with:
8591
path: ~/.m2/build-cache
86-
key: build-cache-${{ runner.os }}-ollama-${{ hashFiles('**/pom.xml') }}
92+
key: build-cache-${{ runner.os }}-ollama-${{ hashFiles('**/pom.xml', '!**/target/**') }}
8793
restore-keys: |
8894
build-cache-${{ runner.os }}-
8995
@@ -108,6 +114,12 @@ jobs:
108114
-Dfailsafe.rerunFailingTestsCount=3 \
109115
verify
110116
117+
- name: Save Maven Build-Cache (~/.m2/build-cache)
118+
uses: actions/cache/save@v4
119+
with:
120+
path: ~/.m2/build-cache
121+
key: build-cache-${{ runner.os }}-ollama-${{ hashFiles('**/pom.xml', '!**/target/**') }}
122+
111123
test-openai:
112124
name: Test OpenAI
113125
if: ${{ github.repository_owner == 'spring-projects' }}
@@ -124,11 +136,12 @@ jobs:
124136
distribution: 'temurin'
125137
cache: 'maven'
126138

127-
- name: Setup Maven Build-Cache (~/.m2/build-cache)
128-
uses: actions/cache@v4
139+
- name: Restore Maven Build-Cache (~/.m2/build-cache)
140+
if: ${{ github.event_name != 'schedule' }}
141+
uses: actions/cache/restore@v4
129142
with:
130143
path: ~/.m2/build-cache
131-
key: build-cache-${{ runner.os }}-openai-${{ hashFiles('**/pom.xml') }}
144+
key: build-cache-${{ runner.os }}-openai-${{ hashFiles('**/pom.xml', '!**/target/**') }}
132145
restore-keys: |
133146
build-cache-${{ runner.os }}-
134147
@@ -153,6 +166,12 @@ jobs:
153166
-Dfailsafe.rerunFailingTestsCount=3 \
154167
verify
155168
169+
- name: Save Maven Build-Cache (~/.m2/build-cache)
170+
uses: actions/cache/save@v4
171+
with:
172+
path: ~/.m2/build-cache
173+
key: build-cache-${{ runner.os }}-openai-${{ hashFiles('**/pom.xml', '!**/target/**') }}
174+
156175
test-remaining:
157176
name: Test Remaining (MCP, Google GenAI, Chroma, PgVector)
158177
if: ${{ github.repository_owner == 'spring-projects' }}
@@ -169,11 +188,12 @@ jobs:
169188
distribution: 'temurin'
170189
cache: 'maven'
171190

172-
- name: Setup Maven Build-Cache (~/.m2/build-cache)
173-
uses: actions/cache@v4
191+
- name: Restore Maven Build-Cache (~/.m2/build-cache)
192+
if: ${{ github.event_name != 'schedule' }}
193+
uses: actions/cache/restore@v4
174194
with:
175195
path: ~/.m2/build-cache
176-
key: build-cache-${{ runner.os }}-other-${{ hashFiles('**/pom.xml') }}
196+
key: build-cache-${{ runner.os }}-other-${{ hashFiles('**/pom.xml', '!**/target/**') }}
177197
restore-keys: |
178198
build-cache-${{ runner.os }}-
179199
@@ -198,6 +218,12 @@ jobs:
198218
-Dfailsafe.rerunFailingTestsCount=3 \
199219
verify
200220
221+
- name: Save Maven Build-Cache (~/.m2/build-cache)
222+
uses: actions/cache/save@v4
223+
with:
224+
path: ~/.m2/build-cache
225+
key: build-cache-${{ runner.os }}-other-${{ hashFiles('**/pom.xml', '!**/target/**') }}
226+
201227
handle-documentation:
202228
name: Generate and upload javadocs, trigger antora reference doc
203229
if: ${{ github.repository_owner == 'spring-projects' && github.event_name != 'schedule'}}
@@ -259,11 +285,12 @@ jobs:
259285
distribution: 'temurin'
260286
cache: 'maven'
261287

262-
- name: Setup Maven Build-Cache (~/.m2/build-cache)
263-
uses: actions/cache@v4
288+
- name: Restore Maven Build-Cache (~/.m2/build-cache)
289+
if: ${{ github.event_name != 'schedule' }}
290+
uses: actions/cache/restore@v4
264291
with:
265292
path: ~/.m2/build-cache
266-
key: build-cache-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
293+
key: build-cache-${{ runner.os }}-${{ hashFiles('**/pom.xml', '!**/target/**') }}
267294
restore-keys: |
268295
build-cache-${{ runner.os }}-
269296

.github/workflows/pr-check.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,20 @@ jobs:
1919
distribution: 'temurin'
2020
cache: 'maven'
2121

22-
- name: Setup Maven Build-Cache (~/.m2/build-cache)
23-
uses: actions/cache@v4
22+
- name: Restore Maven Build-Cache (~/.m2/build-cache)
23+
uses: actions/cache/restore@v4
2424
with:
2525
path: ~/.m2/build-cache
26-
key: build-cache-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
26+
key: build-cache-${{ runner.os }}-${{ hashFiles('**/pom.xml', '!**/target/**') }}
2727
restore-keys: |
2828
build-cache-${{ runner.os }}-
2929
3030
- name: Run tests
3131
run: |
3232
./mvnw -ntp -B -U test
33+
34+
- name: Save Maven Build-Cache (~/.m2/build-cache)
35+
uses: actions/cache/save@v4
36+
with:
37+
path: ~/.m2/build-cache
38+
key: build-cache-${{ runner.os }}-${{ hashFiles('**/pom.xml', '!**/target/**') }}

0 commit comments

Comments
 (0)