-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
226 lines (206 loc) · 4.75 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
include:
- template: Dependency-Scanning.gitlab-ci.yml
- template: License-Scanning.gitlab-ci.yml
- template: SAST.gitlab-ci.yml
- template: Code-Quality.gitlab-ci.yml
variables:
SAST_DEFAULT_ANALYZERS: "gosec,secrets"
GO111MODULE: "on"
stages:
- test
- security
- build
- acceptance-test
- package
- publish
- docker
.on-non-tag:
rules:
- if: '$CI_MERGE_REQUEST_EVENT_TYPE == "detached"'
when: never
- if: '$CI_COMMIT_TAG == null'
when: always
- if: '$CI_MERGE_REQUEST_EVENT_TYPE != null && $CI_MERGE_REQUEST_EVENT_TYPE != "detached"'
when: always
reuse-lint:
extends: .on-non-tag
image:
name: fsfe/reuse:latest
entrypoint: [""]
stage: test
needs: []
allow_failure: true
script:
- reuse lint
lint:
extends: .on-non-tag
image: golangci/golangci-lint:v1.45-alpine
stage: test
allow_failure: true
needs: []
script:
- golangci-lint run -v --max-issues-per-linter=0 --max-same-issues=0 --out-format=junit-xml --timeout=10m > golangci-output.xml
- golangci-lint run -v --max-issues-per-linter=0 --max-same-issues=0 --out-format=checkstyle --timeout=10m > golangci-output-checkstyle.xml
artifacts:
paths:
- golangci-output-checkstyle.xml
reports:
junit: golangci-output.xml
expire_in: 7 days
.go-builder:
extends: .on-non-tag
image: registry.gitlab.com/lightmeter/golang-builder-docker-image:latest
depencencies_graph:
extends: .go-builder
stage: build
needs: []
script:
- make dependencies.svg
artifacts:
paths:
- dependencies.svg
build:
extends: .go-builder
stage: build
needs: []
script:
- make static_release
artifacts:
paths:
- ./lightmeter
expire_in: 7 days
dev-build:
extends: .go-builder
stage: test
needs: []
script:
- make dev
test:
extends: .go-builder
stage: test
needs: []
script:
- make mocks
- go test ./... -race -v | go run github.com/jstemmer/go-junit-report > report.xml
artifacts:
reports:
junit: report.xml
expire_in: 7 days
cover:
extends: .go-builder
stage: test
needs: []
script:
- go get -u github.com/t-yuki/gocover-cobertura
- ./tools/go_test.sh -coverprofile=coverinfo_with_gen.txt
- grep -v '.gen.go' < coverinfo_with_gen.txt > coverinfo.txt
- go run github.com/t-yuki/gocover-cobertura < coverinfo.txt > cobertura.xml
- go tool cover -html=coverinfo.txt -o coverage.html
- go tool cover -func=coverinfo.txt
coverage: /^total:\s+.*\s(\d+\.\d+)%$/
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: cobertura.xml
paths:
- coverage.html
- coverinfo.txt
expire_in: 7 days
acceptance-test:
extends: .on-non-tag
image: registry.gitlab.com/lightmeter/acceptance-tests-docker-image
stage: acceptance-test
needs:
- build
script:
- npm --prefix acceptance_tests link
- npm --prefix acceptance_tests test
cache:
key: "${CI_JOB_NAME}"
paths:
- acceptance_tests/node_modules/
artifacts:
when: always
paths:
- acceptance_tests/reports/html-report/
reports:
junit: acceptance_tests/reports/xml-report/result.xml
expire_in: 7 days
allow_failure: true
publish-release:
extends: .on-non-tag
stage: publish
image: registry.gitlab.com/gitlab-org/release-cli:v0.10.0
needs:
- build
dependencies:
- build
rules:
- if: '$CI_COMMIT_REF_NAME == "master"'
when: manual
script:
- ./ci/release_on_gitlab.sh
license_scanning:
extends: .on-non-tag
stage: test
needs: []
sast:
extends: .on-non-tag
stage: test
needs: []
artifacts:
paths:
- gl-sast-report.json
expire_in: 7 days
dependency_scanning:
extends: .on-non-tag
stage: test
needs: []
code_quality:
extends: .on-non-tag
stage: test
needs: []
publish-docker-image:
rules:
- if: '$CI_COMMIT_TAG != null'
when: always
- if: '$SCHEDULED_DOCKER_IMAGE_TAG != null'
when: always
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
stage: docker
needs: []
script:
- sh ci/publish_docker_image.sh
# NOTE: this step must come after the coverage report
# as it collects some artefacts from it!
sonarcloud-check:
stage: security
dependencies:
- cover
- lint
needs:
- cover
- lint
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- sonar-scanner -Dsonar.projectVersion=$(cat VERSION.txt)
rules:
- if: '$CI_MERGE_REQUEST_EVENT_TYPE == "detached"'
when: never
- if: '$CI_COMMIT_TAG == null && $SONAR_HOST_URL != null'
when: always
usage_docs:
extends: .go-builder
stage: test
needs: []
script:
- make update_cli_docs