-
Notifications
You must be signed in to change notification settings - Fork 12
361 lines (317 loc) · 11.1 KB
/
ci.yaml
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
name: CI
on:
pull_request:
branches: ['main']
types: ['opened', 'reopened', 'synchronize']
workflow_dispatch:
permissions:
contents: read
jobs:
changes:
name: Changes
permissions:
contents: read
pull-requests: read
runs-on: ubuntu-latest
outputs:
base: ${{ steps.filter.outputs.base }}
go: ${{ steps.filter.outputs.go }}
helm: ${{ steps.filter.outputs.helm }}
runner: ${{ steps.runner.outputs.type }}
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.0.2
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.10.2
id: filter
with:
token: ${{ secrets.GITHUB_TOKEN }}
filters: |
base:
- 'NGINX_BASE'
go:
- '**/*.go'
- 'go.mod'
- 'go.sum'
- 'rootfs/**/*'
- 'TAG'
- 'test/e2e/**/*'
- 'NGINX_BASE'
helm:
- 'charts/ingress-nginx/Chart.yaml'
- 'charts/ingress-nginx/**/*'
- name: Prepare runner type
id: runner
run: |
RUNNER="self-hosted-4cpu"
if [ ${{ steps.filter.outputs.base }} == 'true' ]; then
RUNNER="self-hosted-32cpu"
fi
echo "Runner: ${RUNNER}"
echo "type=${RUNNER}" >> $GITHUB_OUTPUT
build:
name: Build images
runs-on: ${{ needs.changes.outputs.runner }}
if: |
(needs.changes.outputs.base == 'true' || needs.changes.outputs.go == 'true' || needs.changes.outputs.helm == 'true')
needs:
- changes
steps:
- name: Import secrets
uses: hashicorp/vault-action@cb841f2c86fb6d07cff94fda240828c1abc5ba43 # v2.7.3
id: secrets
with:
exportEnv: false
url: ${{ secrets.VAULT_URL }}
role: ${{ secrets.VAULT_ROLE }}
method: kubernetes
secrets: kv-gitlab-ci/data/github/shared/node-repo-key key | NODE_REPO_KEY
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.0.2
- name: Setup Docker Buildx
if: needs.changes.outputs.base == 'true'
uses: docker/setup-buildx-action@4c0219f9ac95b02789c1075625400b2acbff50b1 # v2.0.0
with:
version: latest
use: false
- name: Build base image
if: needs.changes.outputs.base == 'true'
run: |
eval $(ssh-agent -s)
echo "${{ steps.secrets.outputs.NODE_REPO_KEY }}" | tr -d '\r' | ssh-add -
make -C images/nginx OUTPUT=--load build
docker save -o base.tar $(cat NGINX_BASE)
- name: Build controller images
env:
ARCH: amd64
REGISTRY: wallarm
TAG: 1.0.0-dev
USER: runner
run: |
echo "Building controller images ..."
make clean-image build image image-chroot
echo "Building E2E image ..."
make -C test/e2e-image image
docker save -o controller.tar \
wallarm/ingress-controller:1.0.0-dev \
wallarm/ingress-controller-chroot:1.0.0-dev \
nginx-ingress-controller:e2e
- name: Cache controller images
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
with:
retention-days: 1
name: controller.tar
path: controller.tar
- name: Cache base image
if: needs.changes.outputs.base == 'true'
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
with:
retention-days: 1
name: base.tar
path: base.tar
smoke:
name: Smoke
runs-on: self-hosted-2cpu
needs:
- build
- changes
if: |
(needs.changes.outputs.helm == 'true' || needs.changes.outputs.go == 'true')
strategy:
fail-fast: false
matrix:
k8s: [v1.23.13, v1.24.12, v1.25.8, v1.26.3, v1.27.1]
steps:
- name: Import secrets
uses: hashicorp/vault-action@cb841f2c86fb6d07cff94fda240828c1abc5ba43 # v2.7.3
id: secrets
with:
exportEnv: false
url: ${{ secrets.VAULT_URL }}
role: ${{ secrets.VAULT_ROLE }}
method: kubernetes
secrets: |
kv-gitlab-ci/data/github/ingress api_token ;
kv-gitlab-ci/data/github/ingress user_secret ;
kv-gitlab-ci/data/github/ingress user_uuid ;
kv-gitlab-ci/data/github/shared/smoke-tests-registry-creds token_name ;
kv-gitlab-ci/data/github/shared/smoke-tests-registry-creds token_secret ;
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.0.2
- name: Load cache
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: controller.tar
- name: Load images
run: docker load -i controller.tar
- name: Create cluster
run: kind create cluster --image=kindest/node:${{ matrix.k8s }}
- name: Run smoke tests
env:
ARCH: amd64
KIND_CLUSTER_NAME: kind
SKIP_CLUSTER_CREATION: true
SKIP_IMAGE_CREATION: true
WALLARM_API_TOKEN: ${{ steps.secrets.outputs.api_token }}
USER_UUID: ${{ steps.secrets.outputs.user_uuid }}
USER_SECRET: ${{ steps.secrets.outputs.user_secret }}
SMOKE_REGISTRY_TOKEN: ${{ steps.secrets.outputs.token_name }}
SMOKE_REGISTRY_SECRET: ${{ steps.secrets.outputs.token_secret }}
CLIENT_ID: 4
run: |
kind get kubeconfig > $HOME/.kube/kind-config-kind
export KUBECONFIG=$HOME/.kube/kind-config-kind
make kind-smoke-test
chart-testing:
name: Chart testing
runs-on: self-hosted-2cpu
needs:
- build
- changes
if: needs.changes.outputs.helm == 'true'
strategy:
matrix:
# "upgrade" is disabled, there is an issue with this mode if values.yaml changed https://github.com/helm/chart-testing/issues/525
method: [ "install" ]
steps:
- name: Import secrets
uses: hashicorp/vault-action@cb841f2c86fb6d07cff94fda240828c1abc5ba43 # v2.7.3
id: secrets
with:
exportEnv: false
url: ${{ secrets.VAULT_URL }}
role: ${{ secrets.VAULT_ROLE }}
method: kubernetes
secrets: kv-gitlab-ci/data/github/ingress api_token
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.0.2
with:
fetch-depth: 0
- name: Load cache
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: controller.tar
- name: Load images
run: docker load -i controller.tar
- name: Create cluster
run: kind create cluster --image=kindest/node:v1.25.8 --config test/e2e/kind.yaml
- name: Run chart testing ${{ matrix.method }}
env:
ARCH: amd64
KIND_CLUSTER_NAME: kind
SKIP_CLUSTER_CREATION: true
SKIP_IMAGE_CREATION: true
WALLARM_API_TOKEN: ${{ steps.secrets.outputs.api_token }}
CT_MODE: ${{ matrix.method }}
run: |
kind get kubeconfig > $HOME/.kube/kind-config-kind
export KUBECONFIG=$HOME/.kube/kind-config-kind
make kind-e2e-chart-tests
e2e:
name: E2E
runs-on: self-hosted-4cpu
needs:
- build
- changes
if: needs.changes.outputs.go == 'true'
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.0.2
- name: Load base build cache
if: needs.changes.outputs.base == 'true'
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: base.tar
- name: Load base image
if: needs.changes.outputs.base == 'true'
run: docker load -i base.tar
- name: Load controller build cache
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: controller.tar
- name: Load controller images
run: docker load -i controller.tar
- name: Create cluster
run: kind create cluster --image=kindest/node:v1.25.8 --config test/e2e/kind.yaml
- name: Run e2e tests
env:
KIND_CLUSTER_NAME: kind
SKIP_CLUSTER_CREATION: true
SKIP_INGRESS_IMAGE_CREATION: true
SKIP_E2E_IMAGE_CREATION: true
ARCH: amd64
run: |
kind get kubeconfig > $HOME/.kube/kind-config-kind
make kind-e2e-test
e2e-wallarm:
name: E2E - Wallarm
runs-on: self-hosted-4cpu
needs:
- changes
- build
if: needs.changes.outputs.go == 'true'
strategy:
matrix:
k8s: [v1.24.12, v1.25.8, v1.26.3, v1.27.1]
steps:
- name: Import secrets
uses: hashicorp/vault-action@cb841f2c86fb6d07cff94fda240828c1abc5ba43 # v2.7.3
id: secrets
with:
exportEnv: false
url: ${{ secrets.VAULT_URL }}
role: ${{ secrets.VAULT_ROLE }}
method: kubernetes
secrets: kv-gitlab-ci/data/github/ingress api_token
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.0.2
- name: Load base build cache
if: needs.changes.outputs.base == 'true'
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: base.tar
- name: Load base image
if: needs.changes.outputs.base == 'true'
run: docker load -i base.tar
- name: Load controller build cache
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: controller.tar
- name: Load controller images
run: docker load -i controller.tar
- name: Create cluster ${{ matrix.k8s }}
run: kind create cluster --image=kindest/node:${{ matrix.k8s }} --config test/e2e/kind.yaml
- name: Run e2e tests
env:
ARCH: amd64
KIND_CLUSTER_NAME: kind
SKIP_CLUSTER_CREATION: true
SKIP_INGRESS_IMAGE_CREATION: true
SKIP_E2E_IMAGE_CREATION: true
WALLARM_ENABLED: true
WALLARM_API_TOKEN: ${{ steps.secrets.outputs.api_token }}
run: |
kind get kubeconfig > $HOME/.kube/kind-config-kind
make E2E_NODES=5 kind-e2e-test
scan:
name: Scan images
runs-on: self-hosted-1cpu
continue-on-error: true
needs:
- changes
- build
if: |
(needs.changes.outputs.base == 'true' || needs.changes.outputs.go == 'true')
steps:
- name: Load controller build cache
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: controller.tar
- name: Load controller images
run: docker load -i controller.tar
- name: Scan controller image
uses: anchore/scan-action@24fd7c9060f3c96848dd1929fac8d796fb5ae4b4
with:
image: "wallarm/ingress-controller:1.0.0-dev"
fail-build: true
output-format: 'table'
severity-cutoff: 'critical'