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

42 lines
1.3 KiB
YAML
Raw Normal View History

2021-09-30 23:02:18 +05:30
# To contribute improvements to CI/CD templates, please follow the Development guide at:
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Go.gitlab-ci.yml
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:
2019-09-04 21:01:54 +05:30
- test
- build
- deploy
2017-08-17 22:00:37 +05:30
format:
2019-09-04 21:01:54 +05:30
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/)
2017-08-17 22:00:37 +05:30
compile:
2019-09-04 21:01:54 +05:30
stage: build
script:
- go build -race -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/mybinary
artifacts:
paths:
- mybinary