Skip to content

Commit 97ff7e4

Browse files
authored
Implement 'project-path' for the load-cache and save-cache commands (#85)
* feat: add 'project-path' param to build-cache actions * feat: add 'project-path' param to golangci-lint-cache actions * feat: add 'project-path' param to mod-cache actions
1 parent da2a036 commit 97ff7e4

File tree

6 files changed

+42
-7
lines changed

6 files changed

+42
-7
lines changed

src/commands/load-build-cache.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ parameters:
44
description: "User-configurable component for cache key. Useful for avoiding collisions in complex workflows."
55
type: string
66
default: ""
7+
project-path:
8+
description: |
9+
The path to the directory containing your Go project files: go.mod, go.sum.
10+
Defaults to $CIRCLE_WORKING_DIRECTORY.
11+
type: string
12+
default: $CIRCLE_WORKING_DIRECTORY
713
steps:
814
- restore_cache:
915
keys:
10-
- v1-<< parameters.key >>-go-build-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "go.sum" }}-{{ epoch | round "72h" }}
16+
- v1-<< parameters.key >>-go-build-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "<< parameters.project-path >>/go.sum" }}-{{ epoch | round "72h" }}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ parameters:
44
description: "User-configurable component for cache key. Useful for avoiding collisions in complex workflows."
55
type: string
66
default: ""
7+
project-path:
8+
description: |
9+
The path to the directory containing your Go project files: go.mod, go.sum.
10+
Defaults to $CIRCLE_WORKING_DIRECTORY.
11+
type: string
12+
default: $CIRCLE_WORKING_DIRECTORY
713
steps:
814
- restore_cache:
915
keys:
10-
- v1-<< parameters.key >>-golangci-lint-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "go.sum" }}-{{ epoch | round "72h" }}
16+
- v1-<< parameters.key >>-golangci-lint-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "<< parameters.project-path >>/go.sum" }}-{{ epoch | round "72h" }}

src/commands/load-mod-cache.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ parameters:
44
description: "User-configurable component for cache key. Useful for avoiding collisions in complex workflows."
55
type: string
66
default: ""
7+
project-path:
8+
description: |
9+
The path to the directory containing your Go project files: go.mod, go.sum.
10+
Defaults to $CIRCLE_WORKING_DIRECTORY.
11+
type: string
12+
default: $CIRCLE_WORKING_DIRECTORY
713
steps:
814
- restore_cache:
915
keys:
10-
- v1-<< parameters.key >>-go-mod-{{ arch }}-{{ checksum "go.sum" }}
16+
- v1-<< parameters.key >>-go-mod-{{ arch }}-{{ checksum "<< parameters.project-path >>/go.sum" }}

src/commands/save-build-cache.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ parameters:
88
description: "Path to cache."
99
type: string
1010
default: "/home/circleci/.cache/go-build"
11+
project-path:
12+
description: |
13+
The path to the directory containing your Go project files: go.mod, go.sum.
14+
Defaults to $CIRCLE_WORKING_DIRECTORY.
15+
type: string
16+
default: $CIRCLE_WORKING_DIRECTORY
1117
steps:
1218
- save_cache:
13-
key: v1-<< parameters.key >>-go-build-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "go.sum" }}-{{ epoch | round "72h" }}
19+
key: v1-<< parameters.key >>-go-build-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "<< parameters.project-path >>/go.sum" }}-{{ epoch | round "72h" }}
1420
paths:
1521
- << parameters.path >>

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@ parameters:
88
description: "Path to cache."
99
type: string
1010
default: "/home/circleci/.cache/golangci-lint"
11+
project-path:
12+
description: |
13+
The path to the directory containing your Go project files: go.mod, go.sum.
14+
Defaults to $CIRCLE_WORKING_DIRECTORY.
15+
type: string
16+
default: $CIRCLE_WORKING_DIRECTORY
1117
steps:
1218
- save_cache:
13-
key: v1-<< parameters.key >>-golangci-lint-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "go.sum" }}-{{ epoch | round "72h" }}
19+
key: v1-<< parameters.key >>-golangci-lint-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "<< parameters.project-path >>/go.sum" }}-{{ epoch | round "72h" }}
1420
paths:
1521
- << parameters.path >>
16-

src/commands/save-mod-cache.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ parameters:
99
type: string
1010
# /home/circleci/go is the GOPATH in the cimg/go Docker image
1111
default: "/home/circleci/go/pkg/mod"
12+
project-path:
13+
description: |
14+
The path to the directory containing your Go project files: go.mod, go.sum.
15+
Defaults to $CIRCLE_WORKING_DIRECTORY.
16+
type: string
17+
default: $CIRCLE_WORKING_DIRECTORY
1218
steps:
1319
- save_cache:
14-
key: v1-<< parameters.key >>-go-mod-{{ arch }}-{{ checksum "go.sum" }}
20+
key: v1-<< parameters.key >>-go-mod-{{ arch }}-{{ checksum "<< parameters.project-path >>/go.sum" }}
1521
paths:
1622
- << parameters.path >>

0 commit comments

Comments
 (0)