基于 dep 依赖管理的 Golang Gitlab CI 配置方法

.gitlab-ci.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
image: golang:latest

variables:
REPO_NAME: {Your Repo}

before_script:
- mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
- cd $GOPATH/src/$REPO_NAME
- go get -u github.com/golang/dep/cmd/dep


stages:
- test
- build

format:
stage: test
script:
- dep ensure
- go test

compile:
stage: build
script:
- dep ensure
- go build -o main
- mkdir mybinary && cp main mybinary/
artifacts:
paths:
- mybinary
0%