diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-07 09:09:13 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-07 09:09:13 +0000 |
commit | 41cb558299b483b44b45351730ee4c0e9fe4ca2c (patch) | |
tree | 00688a9e40021c66195ad826ceddd9c19385cdcf /doc/ci/caching/index.md | |
parent | 3d064c737e8448880e6180aeddc59000a01aa6a8 (diff) | |
download | gitlab-ce-41cb558299b483b44b45351730ee4c0e9fe4ca2c.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/ci/caching/index.md')
-rw-r--r-- | doc/ci/caching/index.md | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/doc/ci/caching/index.md b/doc/ci/caching/index.md index c2d206dde54..12267b4ab9f 100644 --- a/doc/ci/caching/index.md +++ b/doc/ci/caching/index.md @@ -329,6 +329,30 @@ rspec: - rspec spec ``` +### Caching Go dependencies + +Assuming your project is using [Go Modules](https://github.com/golang/go/wiki/Modules) to install +Go dependencies, the following example defines `cache` in a `go-cache` template, that +any job can extend. Go modules are installed in `${GOPATH}/pkg/mod/` and +are cached for all of the `go` projects: + +```yaml +.go-cache: + variables: + GOPATH: $CI_PROJECT_DIR/.go + before_script: + - mkdir -p .go + cache: + paths: + - .go/pkg/mod/ + +test: + image: golang:1.13 + extends: .go-cache + script: + - go test ./... -v -short +``` + ## Availability of the cache Caching is an optimization, but isn't guaranteed to always work, so you need to |