ci: cache dep too

Running `dep ensure` via `make vendor`, with a clean dep cache, takes
around 30 seconds.

For run https://circleci.com/gh/influxdata/platform/1838, we can see
that `make vendor` took 33 seconds and saving the dep cache took 38
seconds. The 38 seconds to save the dep cache is paid the first time
that a particular version of Gopkg.lock is pushed. A subsequent run that
fully uses the dep cache costs 14 seconds to restore the dep cache and 5
seconds to run `make vendor`, so this saves about 10 seconds for any run
that doesn't change Gopkg.lock. See
https://circleci.com/gh/influxdata/platform/1840.
pull/10616/head
Mark Rushakoff 2018-08-28 11:58:55 -07:00 committed by Mark Rushakoff
parent d26233f47e
commit 66b0ea1f14
1 changed files with 18 additions and 2 deletions

View File

@ -13,18 +13,34 @@ jobs:
- image: circleci/golang:1.11
environment:
GOCACHE: /tmp/go-cache
DEPCACHEDIR: /tmp/dep-cache
working_directory: /go/src/github.com/influxdata/platform
steps:
- checkout
# Run dep ensure, using Circle's cache if applicable.
- restore_cache:
name: Restoring dep cache
keys:
- platform-depcache-{{ checksum "Gopkg.lock" }}
- platform-depcache-
- run: make vendor
- save_cache:
name: Saving dep cache
key: platform-depcache-{{ checksum "Gopkg.lock" }}
paths:
- /tmp/dep-cache
# Populate GOCACHE.
- restore_cache:
name: Restoring GOCACHE
keys:
- platform-gocache-{{ .Branch }}-{{ .Revision }} # Matches when retrying a single run.
- platform-gocache-{{ .Branch }}- # Matches a new commit on an existing branch.
- platform-gocache- # Matches a new branch.
- run: make test-go # This caches so it may complete quickly.
- run: make test-go # This uses the test cache so it may succeed or fail quickly.
- run: make vet
- run: make test-go-race # This doesn't cache, and will not complete quickly.
- run: make test-go-race # This doesn't use the test cache, and will not complete quickly.
# TODO add these checks to the Makefile
# - run: go get -v -t -d ./...
# - run: go get honnef.co/go/tools/cmd/megacheck