-
Notifications
You must be signed in to change notification settings - Fork 56
/
.gitlab-ci.yml
196 lines (188 loc) · 4.82 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
---
variables:
DOCKER_HOST: tcp://docker:2375
GO_VERSION: "1.23"
DOCKER_VERSION: "26.0"
stages:
- check-commit
- generate
- build
- lint
- test
- e2e
build-specification:
stage: build
needs: []
image:
name: $CI_REGISTRY_GO/golang:$GO_VERSION
entrypoint: [""]
tags:
- go
script:
- go run cmd/specification/*.go -file specification/haproxy-spec.yaml > specification/build/haproxy_spec_to_compare.yaml
- diff -u specification/build/haproxy_spec_to_compare.yaml specification/build/haproxy_spec.yaml
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
yaml-lint:
stage: lint
needs: ["build-specification"]
image:
name: $CI_REGISTRY_GO/cytopia/yamllint:latest
entrypoint: [""]
tags:
- go
script:
# to test locally, run: docker run --rm -v $(pwd):/data cytopia/yamllint .
- /bin/sh -c "yamllint -f colored ."
- chmod +x ./specification/scripts/lint-yaml.sh
- /bin/sh -c ./specification/scripts/lint-yaml.sh
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
generate:
stage: generate
image:
name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-go$GO_VERSION
entrypoint: [""]
services:
- name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-dind
alias: docker
tags:
- go
before_script:
- rm -rf models/*
- make models
script:
- test -z "$(git diff 2> /dev/null)" || exit "Models are not generated, issue \`make models\` and commit the result"
- test -z "$(git ls-files --others --exclude-standard 2> /dev/null)" || exit "Models generation created untracked files, cannot proceed"
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
build:
stage: build
needs: []
tags:
- go
before_script:
- mkdir -p .go
script:
- go build
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
tidy:
stage: lint
needs: ["build"]
image:
name: $CI_REGISTRY_GO/golang:$GO_VERSION
entrypoint: [""]
tags:
- go
script:
- go mod tidy
- test -z "$(git diff 2> /dev/null)" || exit 'Go modules not tidied, issue \`go mod tidy\` and commit the result'
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
lint:
stage: lint
needs: ["build"]
image:
name: $CI_REGISTRY_GO/golang:$GO_VERSION
entrypoint: [""]
tags:
- go
script:
- make lint
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
license-check:
stage: lint
needs: ["build"]
image:
name: $CI_REGISTRY_GO/golang:$GO_VERSION
entrypoint: [""]
tags:
- go
script:
- go install github.com/google/go-licenses@latest
- PROJECT="$(go list -m)"
- ALLOWED_LICENSES="$(<.allowed_license_types)"
- go-licenses report --ignore "$PROJECT" .
- go-licenses check --allowed_licenses="$ALLOWED_LICENSES" --ignore "$PROJECT" .
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
lint-commit-msg:
stage: lint
needs: ["build"]
image:
name: $CI_REGISTRY_GO/check-commit:v2.1.0
entrypoint: [""]
tags:
- go
script:
- /check
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
test:
stage: test
needs: ["build"]
image:
name: $CI_REGISTRY_GO/golang:$GO_VERSION
entrypoint: [""]
tags:
- go
script:
- go test ./...
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
.e2e:
stage: e2e
needs: ["build"]
image:
name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-go$GO_VERSION
entrypoint: [""]
services:
- name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-dind
alias: docker
tags:
- go
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY_GO
- docker pull -q $CI_REGISTRY_GO/golang:$GO_VERSION-alpine
- docker image tag $CI_REGISTRY_GO/golang:$GO_VERSION-alpine golang:$GO_VERSION-alpine
- docker pull -q $CI_REGISTRY_GO/haproxy-alpine:$HAPROXY_VERSION
- docker image tag $CI_REGISTRY_GO/haproxy-alpine:$HAPROXY_VERSION haproxytech/haproxy-alpine:$HAPROXY_VERSION
script:
- DOCKER_HAPROXY_VERSION=$HAPROXY_VERSION make e2e-docker
HAProxy-2.2:
extends: .e2e
variables:
HAPROXY_VERSION: "2.2"
HAProxy-2.4:
extends: .e2e
variables:
HAPROXY_VERSION: "2.4"
HAProxy-2.6:
extends: .e2e
variables:
HAPROXY_VERSION: "2.6"
HAProxy-2.8:
extends: .e2e
variables:
HAPROXY_VERSION: "2.8"
HAProxy-2.9:
extends: .e2e
variables:
HAPROXY_VERSION: "2.9"
HAProxy-3.0:
extends: .e2e
variables:
HAPROXY_VERSION: "3.0"