Skip to content

Commit 71f5179

Browse files
fix(ci): Correctly update and restore cache for lint:cpp-static-check's generated files . (#260)
Co-authored-by: Lin Zhihao <59785146+LinZhihao-723@users.noreply.github.com>
1 parent d57a1a3 commit 71f5179

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

.github/workflows/code-linting-checks.yaml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ jobs:
5353
run: "task deps:lib_install"
5454

5555
# NOTE: We don't use the cache for scheduled runs so that they run lint:cpp-static-check
56-
# on all files.
56+
# NOTE: We don't restore the cache for `schedule` runs so that below,
57+
# `lint:cpp-static-check` runs on all files. If we don't do this periodically,
58+
# `lint:cpp-static-check` could miss issues in files that haven't changed but depend on
59+
# files which have changed.
5760
- if: "'schedule' != github.event_name"
5861
name: "Restore lint:cpp-static-check cache"
5962
id: "cache-restore-lint-cpp-static-check"
@@ -63,7 +66,14 @@ jobs:
6366
.task/checksum/lint-cpp-static-check
6467
.task/checksum/utils-cpp-lint-clang-tidy-*
6568
build/lint-clang-tidy
66-
key: "main-branch-ubuntu-latest-lint:cpp-static-check"
69+
70+
# NOTE:
71+
# * This key must be kept in-sync with the key prefix in the `actions/cache/save` step
72+
# below (we can't use the output of the current step since `schedule` workflow runs
73+
# don't run this step).
74+
# * Do not provide an exact (explicit) key here. Use a prefix so the cache action can
75+
# match and restore the most recent cache entry that shares that prefix.
76+
key: "lint:check-cpp-static-on-ubuntu-latest"
6777

6878
- run: "task lint:check -C $(nproc)"
6979

@@ -78,4 +88,12 @@ jobs:
7888
.task/checksum/lint-cpp-static-check
7989
.task/checksum/utils-cpp-lint-clang-tidy-*
8090
build/lint-clang-tidy
81-
key: "${{steps.cache-restore-lint-cpp-static-check.outputs.cache-primary-key}}"
91+
92+
# NOTE: This key prefix (without the hash) must be kept in-sync with the
93+
# `actions/cache/restore` step above.
94+
key: >-
95+
lint:check-cpp-static-on-ubuntu-latest-${{hashFiles(
96+
'.task/checksum/lint-cpp-static-check',
97+
'.task/checksum/utils-cpp-lint-clang-tidy-*',
98+
'build/lint-clang-tidy/**/*'
99+
)}}

0 commit comments

Comments
 (0)