-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
45 lines (40 loc) · 1.25 KB
/
.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
image: golang:1.6
stages:
- mirror
- build
- test
before_script:
- mkdir -p ~/.ssh
- echo "$SSH_KEY" > ~/.ssh/id_rsa
- git config --global url."git@gitlab.com:".insteadOf "https://gitlab.com"
- export GLIDE_VERSION="0.9.0"
- mkdir -p $GOPATH/src/gitlab.com
- export PROJECT_NAME=$(basename "$CI_PROJECT_DIR")
- export BASE_DIR=$(dirname "$CI_PROJECT_DIR")
- export USER_NAME=$(basename "$BASE_DIR")
- cp -r $BASE_DIR $GOPATH/src/gitlab.com
- cd $GOPATH/src/gitlab.com/$USER_NAME/$PROJECT_NAME
- wget https://github.com/Masterminds/glide/releases/download/${GLIDE_VERSION}/glide-${GLIDE_VERSION}-linux-amd64.tar.gz
- tar -xf glide-${GLIDE_VERSION}-linux-amd64.tar.gz
- export PATH="$(pwd)/linux-amd64:$GOPATH/bin:$PATH"
build-code:
stage: build
script:
- glide install
- go build $(glide novendor)
- rm ~/.ssh/id_rsa
test-code:
stage: test
script:
- glide install
- go get github.com/stretchr/testify
- go test -v $(glide novendor)
- rm ~/.ssh/id_rsa
mirror-bitbucket:
stage: mirror
script:
- ssh-keyscan -H bitbucket.com > ~/.ssh/known_hosts
- chmod -R 0600 ~/.ssh/
- git remote add bitbucket git@bitbucket.com:hwuligans/$PROJECT_NAME.git
- git push bitbucket --mirror
- rm ~/.ssh/id_rsa