debian-mirror-gitlab/lib/gitlab/ci/templates/Go.gitlab-ci.yml

37 lines
1 KiB
YAML
Raw Normal View History

2017-08-17 22:00:37 +05:30
image: golang:latest
2018-03-17 18:26:18 +05:30
variables:
# Please edit to your GitLab project
REPO_NAME: gitlab.com/namespace/project
2017-08-17 22:00:37 +05:30
# 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
2018-03-17 18:26:18 +05:30
# is gitlab.com, and that your repository is namespace/project, and
2017-08-17 22:00:37 +05:30
# the default GOPATH being /go, then you'd need to have your
2018-03-17 18:26:18 +05:30
# repository in /go/src/gitlab.com/namespace/project
2017-08-17 22:00:37 +05:30
# Thus, making a symbolic link corrects this.
before_script:
2018-03-17 18:26:18 +05:30
- mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
- cd $GOPATH/src/$REPO_NAME
2017-08-17 22:00:37 +05:30
stages:
- test
- build
2019-07-31 22:56:46 +05:30
- deploy
2017-08-17 22:00:37 +05:30
format:
stage: test
script:
2018-03-17 18:26:18 +05:30
- go fmt $(go list ./... | grep -v /vendor/)
- go vet $(go list ./... | grep -v /vendor/)
- go test -race $(go list ./... | grep -v /vendor/)
2017-08-17 22:00:37 +05:30
compile:
stage: build
script:
2018-03-17 18:26:18 +05:30
- go build -race -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/mybinary
2017-08-17 22:00:37 +05:30
artifacts:
2018-03-17 18:26:18 +05:30
paths:
- mybinary