Skip to content

Commit

Permalink
Implement 'project-path' for the load-cache and save-cache commands (#85
Browse files Browse the repository at this point in the history
)

* 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
  • Loading branch information
jjacque authored Dec 11, 2024
1 parent da2a036 commit 97ff7e4
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 7 deletions.
8 changes: 7 additions & 1 deletion src/commands/load-build-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ parameters:
description: "User-configurable component for cache key. Useful for avoiding collisions in complex workflows."
type: string
default: ""
project-path:
description: |
The path to the directory containing your Go project files: go.mod, go.sum.
Defaults to $CIRCLE_WORKING_DIRECTORY.
type: string
default: $CIRCLE_WORKING_DIRECTORY
steps:
- restore_cache:
keys:
- v1-<< parameters.key >>-go-build-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "go.sum" }}-{{ epoch | round "72h" }}
- v1-<< parameters.key >>-go-build-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "<< parameters.project-path >>/go.sum" }}-{{ epoch | round "72h" }}
8 changes: 7 additions & 1 deletion src/commands/load-golangci-lint-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ parameters:
description: "User-configurable component for cache key. Useful for avoiding collisions in complex workflows."
type: string
default: ""
project-path:
description: |
The path to the directory containing your Go project files: go.mod, go.sum.
Defaults to $CIRCLE_WORKING_DIRECTORY.
type: string
default: $CIRCLE_WORKING_DIRECTORY
steps:
- restore_cache:
keys:
- v1-<< parameters.key >>-golangci-lint-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "go.sum" }}-{{ epoch | round "72h" }}
- v1-<< parameters.key >>-golangci-lint-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "<< parameters.project-path >>/go.sum" }}-{{ epoch | round "72h" }}
8 changes: 7 additions & 1 deletion src/commands/load-mod-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ parameters:
description: "User-configurable component for cache key. Useful for avoiding collisions in complex workflows."
type: string
default: ""
project-path:
description: |
The path to the directory containing your Go project files: go.mod, go.sum.
Defaults to $CIRCLE_WORKING_DIRECTORY.
type: string
default: $CIRCLE_WORKING_DIRECTORY
steps:
- restore_cache:
keys:
- v1-<< parameters.key >>-go-mod-{{ arch }}-{{ checksum "go.sum" }}
- v1-<< parameters.key >>-go-mod-{{ arch }}-{{ checksum "<< parameters.project-path >>/go.sum" }}
8 changes: 7 additions & 1 deletion src/commands/save-build-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ parameters:
description: "Path to cache."
type: string
default: "/home/circleci/.cache/go-build"
project-path:
description: |
The path to the directory containing your Go project files: go.mod, go.sum.
Defaults to $CIRCLE_WORKING_DIRECTORY.
type: string
default: $CIRCLE_WORKING_DIRECTORY
steps:
- save_cache:
key: v1-<< parameters.key >>-go-build-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "go.sum" }}-{{ epoch | round "72h" }}
key: v1-<< parameters.key >>-go-build-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "<< parameters.project-path >>/go.sum" }}-{{ epoch | round "72h" }}
paths:
- << parameters.path >>
9 changes: 7 additions & 2 deletions src/commands/save-golangci-lint-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ parameters:
description: "Path to cache."
type: string
default: "/home/circleci/.cache/golangci-lint"
project-path:
description: |
The path to the directory containing your Go project files: go.mod, go.sum.
Defaults to $CIRCLE_WORKING_DIRECTORY.
type: string
default: $CIRCLE_WORKING_DIRECTORY
steps:
- save_cache:
key: v1-<< parameters.key >>-golangci-lint-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "go.sum" }}-{{ epoch | round "72h" }}
key: v1-<< parameters.key >>-golangci-lint-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "<< parameters.project-path >>/go.sum" }}-{{ epoch | round "72h" }}
paths:
- << parameters.path >>

8 changes: 7 additions & 1 deletion src/commands/save-mod-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ parameters:
type: string
# /home/circleci/go is the GOPATH in the cimg/go Docker image
default: "/home/circleci/go/pkg/mod"
project-path:
description: |
The path to the directory containing your Go project files: go.mod, go.sum.
Defaults to $CIRCLE_WORKING_DIRECTORY.
type: string
default: $CIRCLE_WORKING_DIRECTORY
steps:
- save_cache:
key: v1-<< parameters.key >>-go-mod-{{ arch }}-{{ checksum "go.sum" }}
key: v1-<< parameters.key >>-go-mod-{{ arch }}-{{ checksum "<< parameters.project-path >>/go.sum" }}
paths:
- << parameters.path >>

0 comments on commit 97ff7e4

Please sign in to comment.