Skip to content

Instantly share code, notes, and snippets.

@eddwinpaz
Forked from npenkov/golang.gitlab-ci.yml
Created August 19, 2019 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eddwinpaz/2d20272d07ba257f76289ef40f69bcce to your computer and use it in GitHub Desktop.
Save eddwinpaz/2d20272d07ba257f76289ef40f69bcce to your computer and use it in GitHub Desktop.
gitlab-ci for Go projects using go dep.
# Replace "projectname" and "username"
image: golang:1.9
variables:
BIN_NAME: projectname
ARTIFACTS_DIR: artifacts
GO_PROJECT: gitlab.com/username/projectname
stages:
- build
- test
before_script:
- mkdir -p ${GOPATH}/src/${GO_PROJECT}
- mkdir -p ${CI_PROJECT_DIR}/${ARTIFACTS_DIR}
- go get -u github.com/golang/dep/cmd/dep
- cp -r ${CI_PROJECT_DIR}/* ${GOPATH}/src/${GO_PROJECT}/
- cd ${GOPATH}/src/${GO_PROJECT}
build-projectname:
stage: build
script:
- dep ensure
- go build -o ${CI_PROJECT_DIR}/${ARTIFACTS_DIR}/${BIN_NAME}
artifacts:
paths:
- ${ARTIFACTS_DIR}
test-projectname:
stage: test
script:
- dep ensure
- go test -v -cover ./...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment