-
Notifications
You must be signed in to change notification settings - Fork 78
/
.gitlab-ci.yml
205 lines (199 loc) · 5.29 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
stages:
- lint
- checks
- build
- test
- e2e
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_BASE_IMAGE: $CI_REGISTRY_GO/haproxy-debian
BATS_VERSION: v1.4.1
GO_VERSION: "1.23"
DOCKER_VERSION: "26.0"
diff:
stage: lint
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'
script:
#- apk add make curl bash jq
- SWAGGER_VERSION=$(curl -s https://raw.githubusercontent.com/haproxytech/client-native/master/Makefile | grep SWAGGER_VERSION -m 1 | awk -F"=" '{print $2}')
- wget -q "https://github.com/go-swagger/go-swagger/releases/download/${SWAGGER_VERSION}/swagger_linux_amd64" -O /usr/local/bin/swagger && chmod +x /usr/local/bin/swagger
- make generate-native
- test -z "$(git diff 2> /dev/null)" || exit "Specification is not generated, issue \`make generate\` and commit the result"
- test -z "$(git ls-files --others --exclude-standard 2> /dev/null)" || exit "Specification generation created untracked files, cannot proceed"
diff-spec-parent:
stage: lint
image:
name: $CI_REGISTRY_GO/golang:$GO_VERSION
entrypoint: [""]
tags:
- go
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
script:
- make generate-parent-aliases
- test -z "$(git diff 2> /dev/null)" || exit "Parent aliases are not generated, issue \`make generate-parent-aliases\` and commit the result"
- test -z "$(git ls-files --others --exclude-standard 2> /dev/null)" || exit "Parent aliases created untracked files, cannot proceed"
golangci-lint:
stage: lint
artifacts:
paths:
- 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'
gofumpt:
stage: lint
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
image:
name: $CI_REGISTRY_GO/golang:$GO_VERSION
entrypoint: [""]
tags:
- go
script:
- make gofumpt
- test -z "$(git diff 2> /dev/null)" || exit 'Go code not formatted, issue \`make gofumpt\` and commit the result'
commit-policy:
stage: lint
image:
name: $CI_REGISTRY_GO/commit-check:5.0.4
entrypoint: [""]
tags:
- go
script:
- /check
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
build:
stage: build
artifacts:
paths:
- build
image:
name: $CI_REGISTRY_GO/golang:$GO_VERSION
entrypoint: [""]
tags:
- go
script:
- go env
- go mod verify
- make build
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
test:
stage: test
image:
name: $CI_REGISTRY_GO/golang:$GO_VERSION
entrypoint: [ "" ]
tags:
- go
before_script:
- go env -w "GONOSUMDB=gitlab.int.haproxy.com/*" "GOPROXY=http://goproxy.int.haproxy.com"
script:
- go test ./...
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: "$CI_PROJECT_NAMESPACE == 'haproxy-controller' && $CI_PIPELINE_SOURCE == 'push'"
.e2e:
stage: e2e
artifacts:
paths:
- build
- e2e/logs/*
when: on_failure
image:
name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION
entrypoint: [""]
services:
- name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-dind
alias: docker
variables:
LOCAL_IP_ADDRESS: docker
tags:
- go
before_script:
- apk add git bash curl jq git
- git clone https://github.com/bats-core/bats-core.git && cd bats-core && git checkout $BATS_VERSION && ./install.sh /usr/local && cd ..
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY_GO
script:
- bash -x ./e2e/run.bash
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
govulncheck:
stage: checks
needs: []
image:
name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-go$GO_VERSION
entrypoint: [ "" ]
rules:
- if: $CI_PIPELINE_SOURCE == 'schedule' && $SCHEDULE_TYPE == 'daily'
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
changes:
- go.mod
- if: "$CI_PROJECT_NAMESPACE == 'haproxy-controller' && $CI_PIPELINE_SOURCE == 'push'"
changes:
- go.mod
tags:
- go
script:
- go install golang.org/x/vuln/cmd/govulncheck@latest
- govulncheck -version
- go mod tidy
- go run cmd/govulncheck-report/main.go
HAProxy_2_2:
extends: .e2e
parallel:
matrix:
- TESTPART: ["1/2", "2/2"]
HAPROXY_VERSION: "2.2"
HAProxy_2_4:
extends: .e2e
parallel:
matrix:
- TESTPART: ["1/2", "2/2"]
HAPROXY_VERSION: "2.4"
HAProxy_2_6:
extends: .e2e
parallel:
matrix:
- TESTPART: ["1/2", "2/2"]
HAPROXY_VERSION: "2.6"
HAProxy_2_8:
extends: .e2e
parallel:
matrix:
- TESTPART: ["1/2", "2/2"]
HAPROXY_VERSION: "2.8"
HAProxy_2_9:
extends: .e2e
parallel:
matrix:
- TESTPART: ["1/2", "2/2"]
HAPROXY_VERSION: "2.9"
HAProxy_3_0:
extends: .e2e
parallel:
matrix:
- TESTPART: ["1/2", "2/2"]
HAPROXY_VERSION: "3.0"