Skip to content

Commit 91a5ee6

Browse files
committed
ci: improve go caching
Adds the go build cache directory to our saved cache so that we won't rebuild the go tool binaries unless there are module updates in the subsequent steps. It also adds fallbacks to the restore_cache step so that it will restore from the most recent cache when we've modified the go dependencies or tools. This change reduces the run time of our CI jobs by a few minutes.
1 parent 055b0ec commit 91a5ee6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

.circleci/config.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ commands:
1212
md5sum tools.mk >> /tmp/mod-checksums.txt
1313
- restore_cache:
1414
keys:
15-
- v1-go-mod-{{ arch }}-{{ checksum "/tmp/mod-checksums.txt" }}
15+
- v2-go-mod-{{ arch }}-{{ checksum "/tmp/mod-checksums.txt" }}
16+
# Fallback to the most recently-generated cache if an exact match
17+
# does not exist.
18+
- v2-go-mod-
19+
- v1-go-mod-
1620
- run:
1721
name: go mod download
1822
command: |
@@ -23,10 +27,11 @@ commands:
2327
name: Install tools
2428
command: make install-tools
2529
- save_cache:
26-
key: v1-go-mod-{{ arch }}-{{ checksum "/tmp/mod-checksums.txt" }}
30+
key: v2-go-mod-{{ arch }}-{{ checksum "/tmp/mod-checksums.txt" }}
2731
paths:
2832
- /home/circleci/go/pkg/mod
2933
- /home/circleci/go/bin
34+
- /home/circleci/.cache/go-build
3035
jobs:
3136
test:
3237
docker:

0 commit comments

Comments
 (0)