Skip to content

Commit 4eed191

Browse files
committed
REORG/MAJOR: ci: rearrange ci jobs into separate files
1 parent 9d4ee5e commit 4eed191

File tree

10 files changed

+276
-261
lines changed

10 files changed

+276
-261
lines changed

.gitlab-ci.yml

Lines changed: 11 additions & 261 deletions
Original file line numberDiff line numberDiff line change
@@ -5,271 +5,21 @@ stages:
55
- unit-tests
66
- build
77
- e2e-tests
8-
- e2e_k8s_30
9-
- e2e_k8s_31
10-
- e2e_k8s_32
8+
- e2e_k8s
9+
- e2e_k8s_sch_1
10+
- e2e_k8s_sch_2
1111
- e2e_crd_versions
1212
variables:
1313
KIND: v0.29.0
1414
DOCKER_HOST: tcp://docker:2375
1515
DOCKER_DRIVER: overlay2
1616
GO_VERSION: "1.24"
1717
DOCKER_VERSION: "28.1"
18-
pipelines-check:
19-
stage: bots
20-
needs: []
21-
image:
22-
name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-go$GO_VERSION
23-
entrypoint: [ "" ]
24-
rules:
25-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
26-
tags:
27-
- go
28-
script:
29-
- go run cmd/gitlab-mr-pipelines/main.go
30-
mr-backport-question:
31-
stage: bots
32-
needs: []
33-
image:
34-
name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-go$GO_VERSION
35-
entrypoint: [ "" ]
36-
rules:
37-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
38-
tags:
39-
- go
40-
script:
41-
- go run cmd/gitlab-mr-checker/main.go
42-
diff:
43-
stage: diff
44-
rules:
45-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
46-
- if: $CI_PIPELINE_SOURCE == 'push'
47-
image:
48-
name: $CI_REGISTRY_GO/golang:$GO_VERSION
49-
entrypoint: [ "" ]
50-
tags:
51-
- go
52-
before_script:
53-
- make doc
54-
script:
55-
- test -z "$(git diff 2> /dev/null)" || exit "Documentation is not generated, issue \`make doc\` and commit the result"
56-
- test -z "$(git ls-files --others --exclude-standard 2> /dev/null)" || exit "Documentation created untracked files, cannot proceed"
57-
diff-crd:
58-
stage: diff
59-
rules:
60-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
61-
- if: $CI_PIPELINE_SOURCE == 'push'
62-
image:
63-
name: $CI_REGISTRY_GO/golang:$GO_VERSION
64-
entrypoint: [ "" ]
65-
tags:
66-
- go
67-
before_script:
68-
- go version
69-
- make cr_generate
70-
script:
71-
- git diff
72-
- test -z "$(git diff 2> /dev/null)" || exit "CRD generation was not generated, issue \`make cr_generate\` and commit the result"
73-
- test -z "$(git ls-files --others --exclude-standard 2> /dev/null)" || exit "CRD generation created untracked files, cannot proceed"
74-
tidy:
75-
stage: lint
76-
needs: []
77-
rules:
78-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
79-
- if: $CI_PIPELINE_SOURCE == 'push'
80-
image:
81-
name: $CI_REGISTRY_GO/golang:$GO_VERSION
82-
entrypoint: [""]
83-
tags:
84-
- go
85-
script:
86-
- go mod tidy
87-
- test -z "$(git diff 2> /dev/null)" || exit 'Go modules not tidied, issue \`go mod tidy\` and commit the result'
88-
gofumpt:
89-
stage: lint
90-
needs: []
91-
rules:
92-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
93-
- if: $CI_PIPELINE_SOURCE == 'push'
94-
image:
95-
name: $CI_REGISTRY_GO/golang:$GO_VERSION
96-
entrypoint: [""]
97-
tags:
98-
- go
99-
script:
100-
- make gofumpt
101-
- test -z "$(git diff 2> /dev/null)" || exit 'Go code not formatted, issue \`make gofumpt\` and commit the result'
102-
golangci_lint:
103-
stage: lint
104-
needs: []
105-
rules:
106-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
107-
- if: $CI_PIPELINE_SOURCE == 'push'
108-
image:
109-
name: $CI_REGISTRY_GO/golang:$GO_VERSION
110-
entrypoint: [""]
111-
tags:
112-
- go
113-
script:
114-
- make lint-seq
115-
commit-policy:
116-
stage: lint
117-
needs: []
118-
rules:
119-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
120-
image:
121-
name: $CI_REGISTRY_GO/commit-check:5.2.0
122-
entrypoint: [""]
123-
tags:
124-
- go
125-
script:
126-
- /check
127-
unit-tests:
128-
needs: ["diff", "tidy"]
129-
rules:
130-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
131-
- if: $CI_PIPELINE_SOURCE == 'push'
132-
stage: unit-tests
133-
image:
134-
name: $CI_REGISTRY_GO/haproxy-alpine:3.1-go$GO_VERSION
135-
entrypoint: [""]
136-
tags:
137-
- go
138-
script:
139-
- go build -v .
140-
- go test -v ./...
141-
docker-build:
142-
stage: build
143-
needs: []
144-
rules:
145-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
146-
- if: $CI_PIPELINE_SOURCE == 'push'
147-
- if: $CI_PIPELINE_SOURCE == 'schedule'
148-
image: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-go$GO_VERSION
149-
services:
150-
- name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-dind
151-
alias: docker
152-
tags:
153-
- go
154-
before_script:
155-
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY_GO
156-
- go version
157-
- docker pull -q $CI_REGISTRY_GO/alpine:3
158-
- docker image tag $CI_REGISTRY_GO/alpine:3 alpine:3
159-
- docker pull -q $CI_REGISTRY_GO/golang:$GO_VERSION-alpine
160-
- docker image tag $CI_REGISTRY_GO/golang:$GO_VERSION-alpine golang:$GO_VERSION-alpine
161-
- sed -i "s~FROM golang~FROM $CI_REGISTRY_GO/golang~g" "build/Dockerfile"
162-
- sed -i "s~FROM haproxytech/haproxy-alpine~FROM $CI_REGISTRY_GO/haproxy-alpine~g" "build/Dockerfile"
163-
script:
164-
- mkdir -p tar
165-
- make build
166-
- docker save -o tar/k8sIC.tar haproxytech/kubernetes-ingress:latest
167-
artifacts:
168-
when: on_success
169-
paths:
170-
- tar
171-
expire_in: 60 minutes
172-
.kind_deployment:
173-
stage: e2e-tests
174-
retry: 2
175-
needs: ["diff", "tidy", "docker-build"]
176-
rules:
177-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
178-
- if: $CI_PIPELINE_SOURCE == 'push'
179-
- if: $CI_PIPELINE_SOURCE == 'schedule'
180-
image: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-go$GO_VERSION
181-
services:
182-
- name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-dind
183-
alias: docker
184-
tags:
185-
- go
186-
artifacts:
187-
paths:
188-
- tar
189-
expire_in: 1 minutes
190-
exclude:
191-
- tar/*
192-
before_script:
193-
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY_GO
194-
- docker load -i tar/k8sIC.tar
195-
- go version
196-
- go mod download &
197-
#- docker pull -q $CI_REGISTRY_GO/alpine:3
198-
#- docker image tag $CI_REGISTRY_GO/alpine:3 alpine:3
199-
#- docker pull -q $CI_REGISTRY_GO/golang:$GO_VERSION-alpine
200-
#- docker image tag $CI_REGISTRY_GO/golang:$GO_VERSION-alpine golang:$GO_VERSION-alpine
201-
- docker pull -q $CI_REGISTRY_GO/haproxytech/http-echo:latest
202-
- docker image tag $CI_REGISTRY_GO/haproxytech/http-echo:latest haproxytech/http-echo:latest
203-
- docker pull -q $CI_REGISTRY_GO/haproxytech/proxy-protocol:latest
204-
- docker image tag $CI_REGISTRY_GO/haproxytech/proxy-protocol:latest haproxytech/proxy-protocol:latest
205-
- wget -nv -O /usr/local/bin/kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND}/kind-linux-amd64
206-
- chmod +x /usr/local/bin/kind
207-
- wget -nv -O /usr/local/bin/kubectl https://dl.k8s.io/release/${KUBECTL}/bin/linux/amd64/kubectl
208-
- chmod +x /usr/local/bin/kubectl
209-
- sed -i "s/K8S_VERSION/$K8S_VERSION/g" ".gitlab/kind-config.yaml"
210-
- sed -i "s/KUBEADM_VER/$KUBEADM_VER/g" ".gitlab/kind-config.yaml"
211-
- sed -i "s~CI_REGISTRY_GO~$CI_REGISTRY_GO~g" ".gitlab/kind-config.yaml"
212-
- sed -i "s~FROM golang~FROM $CI_REGISTRY_GO/golang~g" "build/Dockerfile"
213-
- sed -i "s~FROM haproxytech/haproxy-alpine~FROM $CI_REGISTRY_GO/haproxy-alpine~g" "build/Dockerfile"
214-
- cat ./.gitlab/kind-config.yaml
215-
- kind create cluster --name=dev --config=./.gitlab/kind-config.yaml
216-
- sed -i -E -e "s/localhost|0\.0\.0\.0|127\.0\.0\.1/docker/g" "$HOME/.kube/config"
217-
- sed -i -E -e "s/localhost|0\.0\.0\.0|127\.0\.0\.1/docker/g" "deploy/tests/e2e/client.go"
218-
- until kubectl get nodes -o wide;do sleep 2; done
219-
- kubectl get pods -A
220-
after_script:
221-
- kubectl get pods -A
222-
- kind delete cluster --name=dev
223-
parallel:
224-
matrix:
225-
- TEST_PART: ["parallel", "https", "sequential-1", "sequential-2"]
226-
script:
227-
- gotest --version
228-
- CI_ENV=gitlab deploy/tests/create.sh
229-
- kubectl get pods -A
230-
- echo "running make -f Makefile.ci ci-e2e-$TEST_PART tests" && make -f Makefile.ci ci-e2e-$TEST_PART
231-
.kind_deployment_schedules:
232-
extends: .kind_deployment
233-
allow_failure: true
234-
e2e_k8s_30:
235-
stage: e2e_k8s_30
236-
needs: ["docker-build"]
237-
variables:
238-
K8S_VERSION: v1.31.9
239-
KUBEADM_VER: v1beta3
240-
KUBECTL: v1.31.0
241-
extends: .kind_deployment_schedules
242-
rules:
243-
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULE_TYPE == 'weekly' && $SCHEDULE_DAY == 'monday'
244-
e2e_k8s_31:
245-
stage: e2e_k8s_31
246-
needs: ["docker-build"]
247-
variables:
248-
K8S_VERSION: v1.32.5
249-
KUBEADM_VER: v1beta3
250-
KUBECTL: v1.32.0
251-
extends: .kind_deployment_schedules
252-
rules:
253-
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULE_TYPE == 'weekly' && $SCHEDULE_DAY == 'tuesday'
254-
e2e_crd_v1:
255-
stage: e2e_crd_versions
256-
needs: ["docker-build"]
257-
variables:
258-
K8S_VERSION: v1.33.1
259-
KUBEADM_VER: v1beta3
260-
KUBECTL: v1.33.1
261-
CRD_VERSION: v1
262-
extends: .kind_deployment_schedules
263-
rules:
264-
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULE_TYPE == 'weekly' && $SCHEDULE_DAY == 'wednesday'
265-
e2e_k8s_32:
266-
stage: e2e_k8s_32
267-
needs: ["docker-build"]
268-
variables:
269-
K8S_VERSION: v1.33.1
270-
KUBEADM_VER: v1beta3
271-
KUBECTL: v1.33.1
272-
extends: .kind_deployment
273-
rules:
274-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
275-
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_NAMESPACE != "haproxy-controller"'
18+
include:
19+
- local: .gitlab/bots.yml
20+
- local: .gitlab/diff.yml
21+
- local: .gitlab/lint.yml
22+
- local: .gitlab/unit-tests.yml
23+
- local: .gitlab/build.yml
24+
- local: .gitlab/e2e_k8s.yml
25+
- local: .gitlab/e2e_k8s_crd_versions_scheduled.yml

.gitlab/.templates.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
.kind_deployment:
2+
stage: e2e-tests
3+
retry: 2
4+
needs: ["diff", "tidy", "docker-build"]
5+
rules:
6+
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
7+
- if: $CI_PIPELINE_SOURCE == 'push'
8+
- if: $CI_PIPELINE_SOURCE == 'schedule'
9+
image: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-go$GO_VERSION
10+
services:
11+
- name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-dind
12+
alias: docker
13+
tags:
14+
- go
15+
artifacts:
16+
paths:
17+
- tar
18+
expire_in: 1 minutes
19+
exclude:
20+
- tar/*
21+
before_script:
22+
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY_GO
23+
- docker load -i tar/k8sIC.tar
24+
- go version
25+
- go mod download &
26+
#- docker pull -q $CI_REGISTRY_GO/alpine:3
27+
#- docker image tag $CI_REGISTRY_GO/alpine:3 alpine:3
28+
#- docker pull -q $CI_REGISTRY_GO/golang:$GO_VERSION-alpine
29+
#- docker image tag $CI_REGISTRY_GO/golang:$GO_VERSION-alpine golang:$GO_VERSION-alpine
30+
- docker pull -q $CI_REGISTRY_GO/haproxytech/http-echo:latest
31+
- docker image tag $CI_REGISTRY_GO/haproxytech/http-echo:latest haproxytech/http-echo:latest
32+
- docker pull -q $CI_REGISTRY_GO/haproxytech/proxy-protocol:latest
33+
- docker image tag $CI_REGISTRY_GO/haproxytech/proxy-protocol:latest haproxytech/proxy-protocol:latest
34+
- wget -nv -O /usr/local/bin/kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND}/kind-linux-amd64
35+
- chmod +x /usr/local/bin/kind
36+
- wget -nv -O /usr/local/bin/kubectl https://dl.k8s.io/release/${KUBECTL}/bin/linux/amd64/kubectl
37+
- chmod +x /usr/local/bin/kubectl
38+
- sed -i "s/K8S_VERSION/$K8S_VERSION/g" ".gitlab/kind-config.yaml"
39+
- sed -i "s/KUBEADM_VER/$KUBEADM_VER/g" ".gitlab/kind-config.yaml"
40+
- sed -i "s~CI_REGISTRY_GO~$CI_REGISTRY_GO~g" ".gitlab/kind-config.yaml"
41+
- sed -i "s~FROM golang~FROM $CI_REGISTRY_GO/golang~g" "build/Dockerfile"
42+
- sed -i "s~FROM haproxytech/haproxy-alpine~FROM $CI_REGISTRY_GO/haproxy-alpine~g" "build/Dockerfile"
43+
- cat ./.gitlab/kind-config.yaml
44+
- kind create cluster --name=dev --config=./.gitlab/kind-config.yaml
45+
- sed -i -E -e "s/localhost|0\.0\.0\.0|127\.0\.0\.1/docker/g" "$HOME/.kube/config"
46+
- sed -i -E -e "s/localhost|0\.0\.0\.0|127\.0\.0\.1/docker/g" "deploy/tests/e2e/client.go"
47+
- until kubectl get nodes -o wide;do sleep 2; done
48+
- kubectl get pods -A
49+
after_script:
50+
- kubectl get pods -A
51+
- kind delete cluster --name=dev
52+
parallel:
53+
matrix:
54+
- TEST_PART: ["parallel", "https", "sequential-1", "sequential-2"]
55+
script:
56+
- gotest --version
57+
- CI_ENV=gitlab deploy/tests/create.sh
58+
- kubectl get pods -A
59+
- echo "running make -f Makefile.ci ci-e2e-$TEST_PART tests" && make -f Makefile.ci ci-e2e-$TEST_PART
60+
.kind_deployment_schedules:
61+
extends: .kind_deployment
62+
allow_failure: true

.gitlab/bots.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
3+
pipelines-check:
4+
stage: bots
5+
needs: []
6+
image:
7+
name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-go$GO_VERSION
8+
entrypoint: [ "" ]
9+
rules:
10+
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
11+
tags:
12+
- go
13+
script:
14+
- go run cmd/gitlab-mr-pipelines/main.go
15+
mr-backport-question:
16+
stage: bots
17+
needs: []
18+
image:
19+
name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-go$GO_VERSION
20+
entrypoint: [ "" ]
21+
rules:
22+
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
23+
tags:
24+
- go
25+
script:
26+
- go run cmd/gitlab-mr-checker/main.go

0 commit comments

Comments
 (0)