-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy path.gitlab-ci.yml
51 lines (46 loc) · 1.12 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
stages:
- lint
- unit-test
- build
variables:
COVERAGE_STANDARD: 70
REPOSITORY_PREFIX: harbor.mock.org/cloudnative/horizon/
GOPROXY: https://goproxy.cn,direct
before_script:
- export APP_REVISION="${CI_COMMIT_TAG:-${CI_COMMIT_REF_NAME##*/}-r$CI_PIPELINE_ID}"
golint:
stage: lint
script:
- golangci-lint run
only:
refs:
- merge_requests
variables:
- $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"
unit-tests:
stage: unit-test
script:
- |
COVERAGE=$(. .unit-test.sh)
[[ "$?" == 0 ]] || exit 1
[[ $(awk -v M=$COVERAGE -v N=$COVERAGE_STANDARD 'BEGIN{print(M>=N)?"0":"1"}') == "0" ]] && \
echo "coverage is $COVERAGE" || {
echo "coverage is $COVERAGE, is less than $COVERAGE_STANDARD"; exit 1
}
only:
refs:
- merge_requests
variables:
- $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"
- $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"
build:
stage: build
variables:
DOCKER_CONFIG_JSON: $DOCKER_AUTH_CONFIG_ONLINE
script:
- bash build/build.sh || exit 1
only:
- develop
- tags
except:
- schedules