-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
64 lines (58 loc) · 1.94 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
before_script:
- go version || echo "Go executable not found."
- echo $CI_BUILD_REF
- echo $CI_PROJECT_DIR
- echo $HOME
- echo $PWD
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan -t rsa $GITLAB_SERVER > ~/.ssh/known_hosts
- git config --global url."git@$GITLAB_SERVER:".insteadOf "https://gitlab.com/"
- git config --global url."git@$GITLAB_SERVER:".insteadOf "https://git.xx.network/" --add
- export PATH=$HOME/go/bin:$PATH
#- go env -w GOPROXY=direct
# Clear out old locally-cached tags
- git tag -l | xargs git tag -d
- git fetch --tags
# Uncomment below to set GOPATH to where it is downloaded
- go env -w GOPATH=$PWD/.go
- go env
stages:
- build
- trigger_integration
build:
stage: build
image: $DOCKER_IMAGE
script:
- git clean -ffdx
- go mod vendor -v
- go build ./...
- go mod tidy
- mkdir -p testdata
- go-acc --covermode atomic --output testdata/coverage.out ./... -- -v
- go tool cover -func=testdata/coverage.out
- go tool cover -html=testdata/coverage.out -o testdata/coverage.html
# Test Coverage Check
- go tool cover -func=testdata/coverage.out | grep "total:" | awk '{print $3}' | sed 's/\%//g' > testdata/coverage-percentage.txt
- export CODE_CHECK=$(echo "$(cat testdata/coverage-percentage.txt) >= $MIN_CODE_COVERAGE" | bc -l)
- (if [ "$CODE_CHECK" == "1" ]; then echo "Minimum coverage of $MIN_CODE_COVERAGE succeeded"; else echo "Minimum coverage of $MIN_CODE_COVERAGE failed"; exit 1; fi);
- mkdir -p release
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '-w -s' ./...
- cd release
artifacts:
paths:
- .go/
- vendor/
- testdata/
- release/
when: always
trigger_integration:
stage: trigger_integration
trigger:
project: elixxir/integration
branch: $CI_COMMIT_REF_NAME
only:
- release
- master