Skip to content

Commit d57d9ba

Browse files
committed
test.yml: include matrix.template in the cache key.
Currently, caching is not very effective in the Integration Tests. By breaking down the cache key into finer details, the cache should become more effective. Signed-off-by: Norio Nomura <[email protected]> test.yml: `hashFiles` does not support path including `..` Signed-off-by: Norio Nomura <[email protected]> realpath on macOS does not support --relative-to= option. Signed-off-by: Norio Nomura <[email protected]> silence `yamllint` warning `too few spaces before comment` Signed-off-by: Norio Nomura <[email protected]>
1 parent 495db7a commit d57d9ba

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 3 deletions
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)