open-vault/.circleci/config/commands/@caches.yml
Christopher Swenson 6c3c79c3a1
GOPATH is being set incorrectly in latest CircleCI machine image (#15288)
For some reason, GOPATH is being overridden in the `go mod download`
step after the latest machine image update in #15215.

This causes all of the modules to be downloaded to the
`/home/circleci/.go_workspace` cache instead of `/home/circleci/go` like
we require for the build (which will otherwise fail since we build with
`GOPROXY=off`).

Without this fix, the build will start to fail once the existing cache
is no longer used (after the root `go.mod`) is updated.
2022-05-04 13:39:23 -07:00

60 lines
2 KiB
YAML

restore_yarn_cache:
steps:
- restore_cache:
name: Restore yarn cache
key: &YARN_LOCK_CACHE_KEY yarn-lock-v7-{{ checksum "ui/yarn.lock" }}
save_yarn_cache:
steps:
- save_cache:
name: Save yarn cache
key: *YARN_LOCK_CACHE_KEY
paths:
- ui/node_modules
# allows restoring go mod caches by incomplete prefix. This is useful when re-generating
# cache, but not when running builds and tests that require an exact match.
# TODO should we be including arch in cache key?
restore_go_mod_cache_permissive:
steps:
- restore_cache:
name: Restore closest matching go modules cache
keys:
- &gocachekey v1.5-{{checksum "go.sum"}}-{{checksum "sdk/go.sum"}}-{{checksum "api/go.sum"}}
- v1.5-{{checksum "go.sum"}}-{{checksum "sdk/go.sum"}}
- v1.5-{{checksum "go.sum"}}
restore_go_mod_cache:
steps:
- restore_cache:
name: Restore exact go modules cache
keys:
- *gocachekey
save_go_mod_cache:
steps:
- save_cache:
name: Save go modules cache
key: *gocachekey
paths:
- /home/circleci/go/pkg/mod
refresh_go_mod_cache:
steps:
- restore_go_mod_cache_permissive
- run:
name: go mod download
command: |
# set GOPATH explicitly to download to the right cache
export GOPATH=$HOME/go
# go list ./... forces downloading some additional versions of modules that 'go mod
# download' misses. We need this because we make use of go list itself during
# code generation in later builds that rely on this module cache.
go list ./...
go mod download -json
( cd sdk && go mod download -json; )
( cd api && go mod download -json; )
- run:
name: Verify downloading modules did not modify any files
command: |
git --no-pager diff --exit-code || {
echo "ERROR: Files modified by go mod download, see above."
exit 1
}
- save_go_mod_cache