Skip to content

Commit 3a6c1a6

Browse files
authored
Merge pull request #2502 from norio-nomura/ci-include-matrix-template-in-the-cache-key
test.yml: include `matrix.template` in the cache key.
2 parents 265431b + d57d9ba commit 3a6c1a6

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

.github/workflows/test.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ jobs:
162162
with:
163163
path: ~/Library/Caches/lima/download
164164
# hashFiles do not seem to support symlinks
165-
key: ${{ runner.os }}-${{ hashFiles('examples/*.yaml') }}
165+
key: ${{ runner.os }}-${{ hashFiles('templates/default.yaml') }}
166166
- name: Unit tests
167167
run: go test -v ./...
168168
- name: Make
@@ -225,12 +225,15 @@ jobs:
225225
- uses: actions/setup-go@v5
226226
with:
227227
go-version: 1.22.x
228+
- id: path_for_hashFiles
229+
# It seems that `hashFiles` cannot use `..` as a path component, so generate a normalized path here.
230+
run: echo "NORMALIZED=$(realpath --relative-to=$PWD examples/${{ matrix.template }})" >> "$GITHUB_OUTPUT"
228231
- uses: actions/cache@v4
229232
with:
230233
path: ~/.cache/lima/download
231234
# hashFiles do not seem to support symlinks
232235
# TODO: more fine-grained cache
233-
key: ${{ runner.os }}-${{ hashFiles('examples/*.yaml') }}
236+
key: ${{ runner.os }}-${{ hashFiles(steps.path_for_hashFiles.outputs.NORMALIZED) }}
234237
- name: Make
235238
run: make
236239
- name: Install
@@ -401,12 +404,15 @@ jobs:
401404
- uses: actions/setup-go@v5
402405
with:
403406
go-version: 1.22.x
407+
- id: path_for_hashFiles
408+
# It seems that `hashFiles` cannot use `..` as a path component, so generate a normalized path here.
409+
run: echo "NORMALIZED=$(realpath examples/${{ matrix.template }})" >> "$GITHUB_OUTPUT"
404410
- name: Cache ~/Library/Caches/lima/download
405411
uses: actions/cache@v4
406412
with:
407413
path: ~/Library/Caches/lima/download
408414
# hashFiles do not seem to support symlinks
409-
key: ${{ runner.os }}-${{ hashFiles('examples/*.yaml') }}
415+
key: ${{ runner.os }}-${{ hashFiles(steps.path_for_hashFiles.outputs.NORMALIZED) }}
410416
- name: Make
411417
run: make
412418
- name: Install

0 commit comments

Comments
 (0)