Created
November 8, 2018 14:59
-
-
Save arush-sal/46a6998414ffa88288c52eb1d0cbb65a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: golang:latest | |
variables: | |
# Please edit to your GitLab project | |
REPO_NAME: gitlab.com/namespace/project | |
# The problem is that to be able to use go get, one needs to put | |
# the repository in the $GOPATH. So for example if your gitlab domain | |
# is gitlab.com, and that your repository is namespace/project, and | |
# the default GOPATH being /go, then you'd need to have your | |
# repository in /go/src/gitlab.com/namespace/project | |
# Thus, making a symbolic link corrects this. | |
before_script: | |
- mkdir -p $GOPATH/src/$(dirname $REPO_NAME) | |
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME | |
- cd $GOPATH/src/$REPO_NAME | |
stages: | |
- test | |
- build | |
format: | |
stage: test | |
script: | |
- go fmt $(go list ./... | grep -v /vendor/) | |
- go vet $(go list ./... | grep -v /vendor/) | |
- go test -race $(go list ./... | grep -v /vendor/) | |
compile: | |
stage: build | |
script: | |
- go build -race -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/mybinary | |
artifacts: | |
paths: | |
- mybinary |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment