forked from haproxytech/kubernetes-ingress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
232 lines (232 loc) · 7.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
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
227
228
229
230
231
232
stages:
- diff
- lint
- unit-tests
- build
- e2e-tests
- e2e_k8s_28
- e2e_k8s_29
- e2e_k8s_30
variables:
KIND: v0.23.0
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
GO_VERSION: "1.22"
DOCKER_VERSION: "26.0"
diff:
stage: diff
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
image:
name: $CI_REGISTRY_GO/golang:$GO_VERSION
entrypoint: [ "" ]
tags:
- go
before_script:
- cd documentation/gen && go run .
script:
- test -z "$(git diff 2> /dev/null)" || exit "Documentation is not generated, issue \`cd documentation/gen && go run .\` and commit the result"
- test -z "$(git ls-files --others --exclude-standard 2> /dev/null)" || exit "Documentation created untracked files, cannot proceed"
diff-crd:
stage: diff
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
image:
name: $CI_REGISTRY_GO/golang:$GO_VERSION
entrypoint: [ "" ]
tags:
- go
before_script:
- go version
- make cr_generate
script:
- git diff
- test -z "$(git diff 2> /dev/null)" || exit "CRD generation was not generated, issue \`make cr_generate\` and commit the result"
- test -z "$(git ls-files --others --exclude-standard 2> /dev/null)" || exit "CRD generation created untracked files, cannot proceed"
tidy:
stage: lint
needs: []
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:
- go mod tidy
- test -z "$(git diff 2> /dev/null)" || exit 'Go modules not tidied, issue \`go mod tidy\` and commit the result'
gofumpt:
stage: lint
needs: []
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'
golangci_lint:
stage: lint
retry: 2
needs: []
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 lint
lint-commit-msg:
stage: lint
needs: []
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
image:
name: $CI_REGISTRY_GO/commit-check:3.0.0
entrypoint: [""]
tags:
- go
script:
- /check
unit-tests:
needs: ["diff", "tidy"]
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
stage: unit-tests
image:
name: $CI_REGISTRY_GO/haproxy-alpine:2.7-go$GO_VERSION
entrypoint: [""]
tags:
- go
script:
- go build -v .
- go test -v ./...
docker-build:
stage: build
needs: []
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
- if: $CI_PIPELINE_SOURCE == 'schedule'
image: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-go$GO_VERSION
services:
- name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-dind
alias: docker
tags:
- go
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY_GO
- go version
- docker pull -q $CI_REGISTRY_GO/alpine:3
- docker image tag $CI_REGISTRY_GO/alpine:3 alpine:3
- docker pull -q $CI_REGISTRY_GO/golang:$GO_VERSION-alpine
- docker image tag $CI_REGISTRY_GO/golang:$GO_VERSION-alpine golang:$GO_VERSION-alpine
- sed -i "s~FROM golang~FROM $CI_REGISTRY_GO/golang~g" "build/Dockerfile"
- sed -i "s~FROM haproxytech/haproxy-alpine~FROM $CI_REGISTRY_GO/haproxy-alpine~g" "build/Dockerfile"
script:
- mkdir -p tar
- make build
- docker save -o tar/k8sIC.tar haproxytech/kubernetes-ingress:latest
artifacts:
when: on_success
paths:
- tar
expire_in: 60 minutes
.kind_deployment:
stage: e2e-tests
retry: 2
needs: ["diff", "tidy", "docker-build"]
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
- if: $CI_PIPELINE_SOURCE == 'schedule'
image: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-go$GO_VERSION
services:
- name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-dind
alias: docker
tags:
- go
artifacts:
paths:
- tar
expire_in: 1 minutes
exclude:
- tar/*
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY_GO
- docker load -i tar/k8sIC.tar
- go version
- go mod download &
#- docker pull -q $CI_REGISTRY_GO/alpine:3
#- docker image tag $CI_REGISTRY_GO/alpine:3 alpine:3
#- 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/haproxytech/http-echo:latest
- docker image tag $CI_REGISTRY_GO/haproxytech/http-echo:latest haproxytech/http-echo:latest
- wget -nv -O /usr/local/bin/kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND}/kind-linux-amd64
- chmod +x /usr/local/bin/kind
- wget -nv -O /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBECTL}/bin/linux/amd64/kubectl
- chmod +x /usr/local/bin/kubectl
- sed -i "s/K8S_VERSION/$K8S_VERSION/g" ".gitlab/kind-config.yaml"
- sed -i "s/KUBEADM_VER/$KUBEADM_VER/g" ".gitlab/kind-config.yaml"
- sed -i "s~CI_REGISTRY_GO~$CI_REGISTRY_GO~g" ".gitlab/kind-config.yaml"
- sed -i "s~FROM golang~FROM $CI_REGISTRY_GO/golang~g" "build/Dockerfile"
- sed -i "s~FROM haproxytech/haproxy-alpine~FROM $CI_REGISTRY_GO/haproxy-alpine~g" "build/Dockerfile"
- cat ./.gitlab/kind-config.yaml
- kind create cluster --name=dev --config=./.gitlab/kind-config.yaml
- sed -i -E -e "s/localhost|0\.0\.0\.0|127\.0\.0\.1/docker/g" "$HOME/.kube/config"
- sed -i -E -e "s/localhost|0\.0\.0\.0|127\.0\.0\.1/docker/g" "deploy/tests/e2e/client.go"
- until kubectl get nodes -o wide;do sleep 2; done
- kubectl get pods -A
after_script:
- kubectl get pods -A
- kind delete cluster --name=dev
parallel:
matrix:
- TEST_PART: ["parallel", "https", "sequential-1", "sequential-2"]
script:
- gotest --version
- CI_ENV=gitlab deploy/tests/create.sh
- kubectl get pods -A
- echo "running make -f Makefile.ci ci-e2e-$TEST_PART tests" && make -f Makefile.ci ci-e2e-$TEST_PART
.kind_deployment_schedules:
extends: .kind_deployment
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
allow_failure: true
e2e_k8s_28:
stage: e2e_k8s_28
needs: ["docker-build"]
variables:
K8S_VERSION: v1.28.6
KUBEADM_VER: v1beta3
KUBECTL: v1.28.0
extends: .kind_deployment_schedules
e2e_k8s_29:
stage: e2e_k8s_29
needs: ["docker-build"]
variables:
K8S_VERSION: v1.29.1
KUBEADM_VER: v1beta3
KUBECTL: v1.29.0
extends: .kind_deployment_schedules
e2e_k8s_30:
stage: e2e_k8s_30
needs: ["docker-build"]
variables:
K8S_VERSION: v1.30.0
KUBEADM_VER: v1beta3
KUBECTL: v1.30.0
extends: .kind_deployment