简体   繁体   中英

Global GOPATH in gitlab-ci

We are building several GO projects on our gitlab ci and we have the following dilemma.

When building projects with a global GOPATH (like on local machines), the builds take too long as all the dependencies are fetched on every build.

On the other hand, when defining a local GOPATH and caching the folders created by go get, we get fast builds, but awkward project setups, where the project itself is not on the GOPATH etc...

It would be nice if there was global caching but gitlab-ci does not allow that:

WARNING: /build/src/git.my.repo: not supported: outside build directory

I would agree with @Kaedys on this one. If you use vendored dependencies and cached your vendor directories you wouldn't have to fetch them for every build. If you aren't vendoring already there's a handful of tools to help you .

I have seen local GOPATH work too. I'm not sure exactly how you implemented it, but you can take a look here for an example of how it can be done. They have a local environment that sets the GOPATH to the project directory when inside the directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM