Using Codeship with Go and Glide

Cameron Stitt
OpenPixel
Published in
2 min readAug 24, 2016

Note: This has been migrated from my original blog. Originally posted on Wednesday, May 25, 2016

Codeship is a fantastic tool to assist in all your continuous integration/deployment needs. Go support is provided out of the box however does not use aspects such as version locked dependencies out the box. When I happened to trial it out, I managed to get a working example of a Go setup including Glide dependencies. This post will provide you with a breakdown of how I managed to get this working. The example should be easily transferable to most other vendor tools such as Godep.

Test Settings

Our test settings need to do a few things.

  1. Install Glide
  2. Run glide install
  3. Ensure dependencies are in $GOPATH
  4. Run our tests

Let’s step through this line by line:

source /dev/stdin <<< “$(curl -sSL https://raw.githubusercontent.com/codeship/scripts/master/languages/go.sh)"

First, we run this script that installs the version of Go declared in the GO_VERSION environment variable. This is not required for this tutorial, but can be helpful when using Go within Codeship.

go get github.com/Masterminds/glide

Then we have to install Glide via the go get command. This is the easiest way to install the dependency and automatically has it included in the PATH.

glide install

Now that glide is installed, we need to fetch all of our dependencies.

rsync -razC vendor/ $GOPATH/src/

Our final step in preparation is syncing the vendor directory into our GOPATH.

Now that we have all our version locked dependencies installed into our GOPATH we can run our desired test commands.

go vet -v $(glide novendor)
go test -v $(glide novendor)

If you have not previously used Glide, $(glide novendor) allows us to ignore the vendor directory when running our test commands.

All done. We now have version locked dependencies being used within our continuous integration platform.

--

--