Skip to content

Commit 6781935

Browse files
authored
Support customising the checksum template (#111)
1 parent cc6571d commit 6781935

File tree

8 files changed

+50
-17
lines changed

8 files changed

+50
-17
lines changed

.circleci/test-deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ jobs:
114114
key: "integration"
115115
mod: true
116116
golangci-lint: true
117+
checksum: '{{ checksum "go.mod" }}-{{ checksum "go.sum" }}'
117118
steps:
118119
- go/mod-download
119120
- run: go version && go build ./...

src/commands/load-build-cache.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ parameters:
44
description: "User-configurable component for cache key. Useful for avoiding collisions in complex workflows."
55
type: string
66
default: ""
7+
checksum:
8+
description: "Checksum template instruction"
9+
type: string
10+
default: '{{ checksum "go.sum" }}'
711
steps:
812
- restore_cache:
913
keys:
10-
- v1-<< parameters.key >>-go-build-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "go.sum" }}-{{ epoch | round "72h" }}
14+
- v1-<< parameters.key >>-go-build-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-<< parameters.checksum >>-{{ epoch | round "72h" }}

src/commands/load-golangci-lint-cache.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ parameters:
44
description: "User-configurable component for cache key. Useful for avoiding collisions in complex workflows."
55
type: string
66
default: ""
7+
checksum:
8+
description: "Checksum template instruction"
9+
type: string
10+
default: '{{ checksum "go.sum" }}'
711
steps:
812
- restore_cache:
913
keys:
10-
- v1-<< parameters.key >>-golangci-lint-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "go.sum" }}-{{ epoch | round "72h" }}
14+
- v1-<< parameters.key >>-golangci-lint-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-<< parameters.checksum >>-{{ epoch | round "72h" }}

src/commands/load-mod-cache.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ parameters:
44
description: "User-configurable component for cache key. Useful for avoiding collisions in complex workflows."
55
type: string
66
default: ""
7+
checksum:
8+
description: "Checksum template instruction"
9+
type: string
10+
default: '{{ checksum "go.sum" }}'
711
steps:
812
- restore_cache:
913
keys:
10-
- v1-<< parameters.key >>-go-mod-{{ arch }}-{{ checksum "go.sum" }}
14+
- v1-<< parameters.key >>-go-mod-{{ arch }}-<< parameters.checksum >>

src/commands/save-build-cache.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ parameters:
88
description: "Path to cache."
99
type: string
1010
default: ~/.cache/go-build
11+
checksum:
12+
description: "Checksum template instruction"
13+
type: string
14+
default: '{{ checksum "go.sum" }}'
1115
steps:
1216
- save_cache:
13-
key: v1-<< parameters.key >>-go-build-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "go.sum" }}-{{ epoch | round "72h" }}
17+
key: v1-<< parameters.key >>-go-build-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-<< parameters.checksum >>-{{ epoch | round "72h" }}
1418
paths:
1519
- << parameters.path >>

src/commands/save-golangci-lint-cache.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ parameters:
88
description: "Path to cache."
99
type: string
1010
default: ~/.cache/golangci-lint
11+
checksum:
12+
description: "Checksum template instruction"
13+
type: string
14+
default: '{{ checksum "go.sum" }}'
1115
steps:
1216
- save_cache:
13-
key: v1-<< parameters.key >>-golangci-lint-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "go.sum" }}-{{ epoch | round "72h" }}
17+
key: v1-<< parameters.key >>-golangci-lint-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-<< parameters.checksum >>-{{ epoch | round "72h" }}
1418
paths:
1519
- << parameters.path >>
16-

src/commands/save-mod-cache.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ parameters:
77
path:
88
description: "Path to cache."
99
type: string
10-
# /home/circleci/go is the GOPATH in the cimg/go Docker image
1110
default: ~/go/pkg/mod
11+
checksum:
12+
description: "Checksum template instruction"
13+
type: string
14+
default: '{{ checksum "go.sum" }}'
1215
steps:
1316
- save_cache:
14-
key: v1-<< parameters.key >>-go-mod-{{ arch }}-{{ checksum "go.sum" }}
17+
key: v1-<< parameters.key >>-go-mod-{{ arch }}-<< parameters.checksum >>
1518
paths:
1619
- << parameters.path >>

src/commands/with-cache.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,38 +34,48 @@ parameters:
3434
description: "Location of golangci-lint cache."
3535
type: string
3636
default: ~/.cache/golangci-lint
37+
checksum:
38+
description: "Checksum template instruction"
39+
type: string
40+
default: '{{ checksum "go.sum" }}'
3741
steps:
3842
- when:
3943
condition: << parameters.build >>
4044
steps:
4145
- load-build-cache:
42-
key: << parameters.key >>
46+
key: '<< parameters.key >>'
47+
checksum: '<< parameters.checksum >>'
4348
- when:
4449
condition: << parameters.mod >>
4550
steps:
4651
- load-mod-cache:
47-
key: << parameters.key >>
52+
key: '<< parameters.key >>'
53+
checksum: '<< parameters.checksum >>'
4854
- when:
4955
condition: << parameters.golangci-lint >>
5056
steps:
5157
- load-golangci-lint-cache:
52-
key: << parameters.key >>
58+
key: '<< parameters.key >>'
59+
checksum: '<< parameters.checksum >>'
5360
- steps: << parameters.steps >>
5461
- when:
5562
condition: << parameters.build >>
5663
steps:
5764
- save-build-cache:
58-
key: << parameters.key >>
59-
path: << parameters.build-path >>
65+
key: '<< parameters.key >>'
66+
checksum: '<< parameters.checksum >>'
67+
path: '<< parameters.build-path >>'
6068
- when:
6169
condition: << parameters.mod >>
6270
steps:
6371
- save-mod-cache:
64-
key: << parameters.key >>
65-
path: << parameters.mod-path >>
72+
key: '<< parameters.key >>'
73+
checksum: '<< parameters.key >>'
74+
path: '<< parameters.mod-path >>'
6675
- when:
6776
condition: << parameters.golangci-lint >>
6877
steps:
6978
- save-golangci-lint-cache:
70-
key: << parameters.key >>
71-
path: << parameters.golangci-lint-path >>
79+
key: '<< parameters.key >>'
80+
checksum: '<< parameters.checksum >>'
81+
path: '<< parameters.golangci-lint-path >>'

0 commit comments

Comments
 (0)