Skip to content

Commit f8ed716

Browse files
committed
REORG/MAJOR: ci: rearrange ci jobs into separate files
1 parent f2428ae commit f8ed716

File tree

9 files changed

+253
-237
lines changed

9 files changed

+253
-237
lines changed

.gitlab-ci.yml

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

.gitlab/build.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
docker-build:
2+
stage: build
3+
needs: []
4+
rules:
5+
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
6+
- if: $CI_PIPELINE_SOURCE == 'push'
7+
- if: $CI_PIPELINE_SOURCE == 'schedule'
8+
image: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-go$GO_VERSION
9+
services:
10+
- name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-dind
11+
alias: docker
12+
tags:
13+
- go
14+
before_script:
15+
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY_GO
16+
- go version
17+
- docker pull -q $CI_REGISTRY_GO/alpine:3
18+
- docker image tag $CI_REGISTRY_GO/alpine:3 alpine:3
19+
- docker pull -q $CI_REGISTRY_GO/golang:$GO_VERSION-alpine
20+
- docker image tag $CI_REGISTRY_GO/golang:$GO_VERSION-alpine golang:$GO_VERSION-alpine
21+
- sed -i "s~FROM golang~FROM $CI_REGISTRY_GO/golang~g" "build/Dockerfile"
22+
- sed -i "s~FROM haproxytech/haproxy-alpine~FROM $CI_REGISTRY_GO/haproxy-alpine~g" "build/Dockerfile"
23+
script:
24+
- mkdir -p tar
25+
- make build
26+
- docker save -o tar/k8sIC.tar haproxytech/kubernetes-ingress:latest
27+
artifacts:
28+
when: on_success
29+
paths:
30+
- tar
31+
expire_in: 60 minutes

.gitlab/diff.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
diff:
2+
stage: diff
3+
rules:
4+
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
5+
- if: $CI_PIPELINE_SOURCE == 'push'
6+
image:
7+
name: $CI_REGISTRY_GO/golang:$GO_VERSION
8+
entrypoint: [ "" ]
9+
tags:
10+
- go
11+
before_script:
12+
- cd documentation/gen && go run .
13+
script:
14+
- test -z "$(git diff 2> /dev/null)" || exit "Documentation is not generated, issue \`cd documentation/gen && go run .\` and commit the result"
15+
- test -z "$(git ls-files --others --exclude-standard 2> /dev/null)" || exit "Documentation created untracked files, cannot proceed"
16+
diff-crd:
17+
stage: diff
18+
rules:
19+
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
20+
- if: $CI_PIPELINE_SOURCE == 'push'
21+
image:
22+
name: $CI_REGISTRY_GO/golang:$GO_VERSION
23+
entrypoint: [ "" ]
24+
tags:
25+
- go
26+
before_script:
27+
- go version
28+
- make cr_generate
29+
script:
30+
- git diff
31+
- test -z "$(git diff 2> /dev/null)" || exit "CRD generation was not generated, issue \`make cr_generate\` and commit the result"
32+
- test -z "$(git ls-files --others --exclude-standard 2> /dev/null)" || exit "CRD generation created untracked files, cannot proceed"

0 commit comments

Comments
 (0)