-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
188 lines (162 loc) · 3.48 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
stages:
- status-pre
- test
- build
- image
- status-post
.build-base:
image: docker.artifacts.apextoaster.com/apextoaster/base:1.5
tags:
- platform:k8s
- runner:shared
.build-climate:
image: docker.artifacts.apextoaster.com/apextoaster/code-climate:0.6
tags:
- platform:k8s
- runner:shared
allow_failure: false
variables:
CI_BRANCH: "${CI_COMMIT_REF_NAME}"
GIT_BRANCH: "${CI_COMMIT_REF_NAME}"
GIT_COMMIT_SHA: "${CI_COMMIT_SHA}"
.build-go:
extends:
- .build-base
stage: build
image: docker.artifacts.apextoaster.com/apextoaster/golang:1.14-master
variables:
GOPATH: /build
BUILD_OPTS: -a -v -x
before_script:
- make go-clean
artifacts:
expire_in: 1 hour
paths:
- bin/
cache: &go-cache
paths:
- vendor
policy: pull
# real jobs
test-go:
extends:
- .build-go
stage: test
script:
- make go-test
artifacts:
expire_in: 1 week
paths:
- out/cover.*
cache:
<<: *go-cache
policy: pull-push
build-go-darwin-x86:
extends:
- .build-go
script:
- GOOS=darwin GOARCH=386 make go-build
- GOOS=darwin GOARCH=amd64 make go-build
build-go-linux-arm:
extends:
- .build-go
script:
- GOOS=linux GOARCH=arm make go-build
- GOOS=linux GOARCH=arm64 make go-build
build-go-linux-x86:
extends:
- .build-go
script:
- GOOS=linux GOARCH=386 make go-build
- GOOS=linux GOARCH=amd64 make go-build
build-go-windows-x86:
extends:
- .build-go
script:
- GOOS=windows GOARCH=386 make go-build
- GOOS=windows GOARCH=amd64 make go-build
# always build an image (tagged by branch), publish tags to latest
.build-docker:
extends:
- .build-base
image: docker.artifacts.apextoaster.com/apextoaster/docker:20.10
services:
- docker.artifacts.apextoaster.com/apextoaster/docker-dind:20.10
variables: &vars-docker
DOCKER_CERT_PATH: "/shared/docker/client"
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://localhost:2376
DOCKER_TLS_CERTDIR: "/shared/docker"
DOCKER_TLS_VERIFY: 1
before_script:
- mkdir ${HOME}/.docker
- echo "${DOCKER_SECRET}" | base64 -d > ${HOME}/.docker/config.json
script:
- ./scripts/docker-build.sh --push --default
after_script:
- rm -rfv ${HOME}/.docker
build-image:
extends:
- .build-docker
stage: image
dependencies:
- build-go-linux-x86
variables:
IMAGE_ARCH: ubuntu
build-binary:
extends:
- .build-base
stage: image
only:
- master
- tags
dependencies:
- build-go-darwin-x86
- build-go-linux-arm
- build-go-linux-x86
- build-go-windows-x86
script:
- make bundle-all
artifacts:
expire_in: 1 day
paths:
- bin/
# commit status
climate-pending:
stage: status-pre
extends:
- .build-climate
script:
- cc-test-reporter before-build
climate-success:
stage: status-post
extends:
- .build-climate
dependencies:
- test-go
script:
# cc is overly picky about paths, so fix them up
- |
cat out/cover.out | sed "s+github.com\\/ssube\\/togo+${PWD}+" > c.out
- make upload-climate
# github jobs
github-pending:
stage: status-pre
extends:
- .build-base
script:
- ./scripts/github-status.sh pending
github-failure:
stage: status-post
extends:
- .build-base
when: on_failure
script:
- ./scripts/github-status.sh failure
github-success:
stage: status-post
extends:
- .build-base
when: on_success
script:
- ./scripts/github-status.sh success