forked from haproxytech/client-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
191 lines (180 loc) · 4.15 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
---
stages:
- check-commit
- generate
- build
- lint
- test
- e2e
variables:
DOCKER_HOST: tcp://docker:2375
build-specification:
stage: build
needs: []
image:
name: $CI_REGISTRY_GO/golang:1.18
entrypoint: [""]
tags:
- go
script:
- go run specification/build/build.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
only:
- merge_requests
- branches
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
only:
- merge_requests
- branches
.go-cache:
variables:
GOPATH: $CI_PROJECT_DIR/.go
image:
name: $CI_REGISTRY_GO/golang:1.18
entrypoint: [""]
before_script:
- mkdir -p .go
cache:
paths:
- .go/pkg/mod/
generate:
stage: generate
image:
name: $CI_REGISTRY_GO/docker:stable-go1.18
entrypoint: [""]
services:
- name: $CI_REGISTRY_GO/docker:18.09.7-dind
alias: docker
tags:
- go
before_script:
- apk add make git
- wget -O /usr/local/bin/swagger https://github.com/go-swagger/go-swagger/releases/download/v0.29.0/swagger_linux_amd64
- chmod +x /usr/local/bin/swagger
- make models-native
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"
only:
- merge_requests
- branches
build:
extends: .go-cache
stage: build
needs: []
tags:
- go
before_script:
- mkdir -p .go
script:
- go build
only:
- merge_requests
- branches
tidy:
stage: lint
needs: ["build"]
image:
name: $CI_REGISTRY_GO/golang:1.18
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'
only:
- merge_requests
- branches
golangci-lint:
stage: lint
needs: ["generate", "build"]
image:
name: $CI_REGISTRY_GO/lint:1.46.2
entrypoint: [""]
tags:
- go
script:
- golangci-lint run --timeout 5m --color always --max-issues-per-linter 0 --max-same-issues 0
only:
- merge_requests
- branches
lint-commit-msg:
stage: lint
needs: ["build"]
image:
name: $CI_REGISTRY_GO/check-commit:v2.1.0
entrypoint: [""]
tags:
- go
script:
- /check
only:
- merge_requests
test:
extends: .go-cache
stage: test
needs: ["generate", "build"]
image:
name: $CI_REGISTRY_GO/golang:1.18
entrypoint: [""]
tags:
- go
script:
- go test ./...
only:
- merge_requests
- branches
.e2e:
stage: e2e
needs: ["test"]
extends: .go-cache
image:
name: $CI_REGISTRY_GO/docker:stable
entrypoint: [""]
services:
- name: $CI_REGISTRY_GO/docker:18.09.7-dind
alias: docker
tags:
- go
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY_GO
- docker pull $CI_REGISTRY_GO/client-native:$HAPROXY_VERSION
- docker image tag $CI_REGISTRY_GO/client-native:$HAPROXY_VERSION test_env:$HAPROXY_VERSION
- docker build --file ./e2e/Dockerfile --build-arg HAPROXY_VERSION=$HAPROXY_VERSION --build-arg DOCKER_URL=$CI_REGISTRY_GO --tag client-native-test:$HAPROXY_VERSION .
script:
- docker run client-native-test:$HAPROXY_VERSION
only:
- merge_requests
- branches
HAProxy-2.1:
extends: .e2e
variables:
HAPROXY_VERSION: "2.1"
HAProxy-2.2:
extends: .e2e
variables:
HAPROXY_VERSION: "2.2"
HAProxy-2.3:
extends: .e2e
variables:
HAPROXY_VERSION: "2.3"
HAProxy-2.4:
extends: .e2e
variables:
HAPROXY_VERSION: "2.4"
HAProxy-2.5:
extends: .e2e
variables:
HAPROXY_VERSION: "2.5"