-
Notifications
You must be signed in to change notification settings - Fork 16
466 lines (404 loc) · 14.5 KB
/
dev-be-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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
---
name: API CI
on:
push:
paths-ignore:
- 'ui/**'
- '.github/workflows/dev-fe-ci.yaml'
branches:
- main
pull_request:
paths-ignore:
- 'ui/**'
- '.github/workflows/dev-fe-ci.yaml'
permissions:
contents: read
packages: write
checks: write
pull-requests: write
jobs:
test:
name: Test
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
go-version: [ 1.23.x ]
may-fail: [ false ]
continue-on-error: ${{ matrix.may-fail }}
runs-on: ubuntu-20.04
steps:
- name: Set up Go release
uses: percona-platform/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Set GO_VERSION environment variable
run: |
go version
echo "GO_VERSION=$(go version)" >> $GITHUB_ENV
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
lfs: true
ref: ${{ github.event.pull_request.head.sha }}
- name: Enable Go modules cache
uses: percona-platform/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ matrix.os }}-go-${{ matrix.go-version }}-modules-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ matrix.os }}-go-${{ matrix.go-version }}-modules-
- name: Enable Go build cache
uses: percona-platform/cache@v3
with:
path: ~/.cache/go-build
key: ${{ matrix.os }}-go-${{ matrix.go-version }}-build-${{ github.ref }}-${{ hashFiles('**') }}
restore-keys: |
${{ matrix.os }}-go-${{ matrix.go-version }}-build-${{ github.ref }}-
${{ matrix.os }}-go-${{ matrix.go-version }}-build-
- name: Download Go modules
run: go mod download
- name: Install development tools
run: make init
- name: Generate code
run: make gen
- name: Install binaries
run: make build
- name: Run tests
run: |
go clean -testcache
make test-crosscover
- name: Check that there are no source code changes
run: |
# Break job if any files were changed during its run (code generation, etc), except go.sum.
# `go mod tidy` could remove old checksums from that file, and that's okay on CI,
# and actually expected for PRs made by @dependabot.
# Checksums of actually used modules are checked by previous `go` subcommands.
pushd tools && go mod tidy -v && git checkout go.sum
popd && go mod tidy -v && git checkout go.sum
git diff --exit-code
- name: Run debug commands on failure
if: ${{ failure() }}
run: |
env
go version
go env
pwd
git status
check:
name: Check
timeout-minutes: 10
if: github.event_name == 'pull_request'
strategy:
fail-fast: false
matrix:
go-version: [1.23.x]
may-fail: [false]
continue-on-error: ${{ matrix.may-fail }}
runs-on: ubuntu-latest
steps:
- name: Set up Go release
if: matrix.go-version != 'tip'
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Set up Go tip
if: matrix.go-version == 'tip'
run: |
git clone --depth=1 https://go.googlesource.com/go $HOME/gotip
cd $HOME/gotip/src
./make.bash
echo "GOROOT=$HOME/gotip" >> $GITHUB_ENV
echo "$HOME/gotip/bin" >> $GITHUB_PATH
- name: Set GO_VERSION environment variable
run: |
go version
echo "GO_VERSION=$(go version)" >> $GITHUB_ENV
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
lfs: true
ref: ${{ github.event.pull_request.head.sha }}
- name: Enable Go modules cache
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ matrix.os }}-go-${{ matrix.go-version }}-modules-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ matrix.os }}-go-${{ matrix.go-version }}-modules-
- name: Enable Go build cache
uses: actions/cache@v4
with:
path: ~/.cache/go-build
key: ${{ matrix.os }}-go-${{ matrix.go-version }}-build-${{ github.ref }}-${{ hashFiles('**') }}
restore-keys: |
${{ matrix.os }}-go-${{ matrix.go-version }}-build-${{ github.ref }}-
${{ matrix.os }}-go-${{ matrix.go-version }}-build-
- name: Download Go modules
run: go mod download
- name: Install tools
run: make init
- name: Run linters
run: |
bin/golangci-lint run --new --out-format=line-number | env REVIEWDOG_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} bin/reviewdog -f=golangci-lint -reporter=github-pr-review -filter-mode=nofilter -fail-on-error=true
- name: Check that dev Helm chart is up-to-date
run: |
make update-dev-chart
git diff --exit-code
- name: Check that there are no source code changes
run: |
make format
pushd tools && go mod tidy -v
popd && go mod tidy -v
git status
git diff --exit-code
- name: Check the Makefile references dev version
run: |
if ! grep -q "RELEASE_VERSION ?= v0.0.0" Makefile; then
echo "default RELEASE_VERSION in Makefile should be 0.0.0"
exit 1
fi
- name: Run debug commands on failure
if: ${{ failure() }}
run: |
env
go version
go env
pwd
git status
integration_tests_api:
strategy:
fail-fast: false
matrix:
go-version: [ 1.23.x ]
may-fail: [ false ]
name: API Integration Tests
runs-on: ubuntu-20.04
env:
PERCONA_VERSION_SERVICE_URL: https://check-dev.percona.com/versions/v1
steps:
- name: Set up Go release
uses: percona-platform/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Set GO_VERSION environment variable
run: |
go version
echo "GO_VERSION=$(go version)" >> $GITHUB_ENV
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
lfs: true
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Enable Go modules cache
uses: percona-platform/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ matrix.os }}-go-${{ matrix.go-version }}-modules-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ matrix.os }}-go-${{ matrix.go-version }}-modules-
- name: Enable Go build cache
uses: percona-platform/cache@v3
with:
path: ~/.cache/go-build
key: ${{ matrix.os }}-go-${{ matrix.go-version }}-build-${{ github.ref }}-${{ hashFiles('**') }}
restore-keys: |
${{ matrix.os }}-go-${{ matrix.go-version }}-build-${{ github.ref }}-
${{ matrix.os }}-go-${{ matrix.go-version }}-build-
- name: Start local Kubernetes cluster with the local registry
uses: medyagh/setup-minikube@latest
id: minikube
with:
cpus: 2
memory: 2000m
addons: registry
insecure-registry: 'localhost:5000'
- name: Expose local registry
run: |
kubectl port-forward --namespace kube-system service/registry 5000:80 &
- name: Build Everest API Server
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make build-debug
- name: Build Everest docker container
uses: docker/metadata-action@v5
id: meta
with:
images: localhost:5000/perconalab/everest
tags:
0.0.0
- name: Build and Push everest dev image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
# We need to have Everest CRDs available before running provisioning and everest API Server
# to have an ability to create monitoring configs and use them during the provisioning as
# a mock pmm server without running a real PMM.
- name: Install everest operator without Everest
run: |
kubectl create ns everest-system
kubectl create ns everest-monitoring
curl https://raw.githubusercontent.com/percona/everest-operator/main/deploy/bundle.yaml -o bundle.yaml
sed -i "s/namespace: everest-operator-system/namespace: everest-system/g" bundle.yaml
kubectl -n everest-system apply -f bundle.yaml
# We create a dummy monitoring instance so we can enable monitoring during provisioning
# without having to install PMM.
- name: Create a monitoring instance
run: |
cat <<EOF | kubectl apply -f -
kind: Secret
apiVersion: v1
metadata:
name: pmm-local
namespace: everest-monitoring
type: Opaque
stringData:
"apiKey": "dummy-key"
EOF
cat <<EOF | kubectl apply -f -
kind: MonitoringConfig
apiVersion: everest.percona.com/v1alpha1
metadata:
name: pmm-local
namespace: everest-monitoring
spec:
type: pmm
credentialsSecretName: pmm-local
pmm:
url: http://localhost
image: percona/pmm-client:2
EOF
- name: Provision Everest using CLI
shell: bash
run: |
make build-cli
./bin/everestctl install -v \
--version 0.0.0 \
--version-metadata-url https://check-dev.percona.com \
--operator.mongodb \
--operator.postgresql \
--operator.xtradb-cluster \
--skip-wizard \
--namespaces everest \
--helm.set server.image=localhost:5000/perconalab/everest \
--helm.set server.apiRequestsRateLimit=200 \
--helm.set versionMetadataURL=https://check-dev.percona.com
- name: Expose Everest API Server
run: |
kubectl port-forward --namespace everest-system deployment/everest-server 8080:8080 &
- name: Create Everest test user
run: |
./bin/everestctl accounts create -u everest_ci -p password
echo "API_TOKEN=$(curl --location -s 'localhost:8080/v1/session' --header 'Content-Type: application/json' --data '{"username": "everest_ci","password": "password"}' | jq -r .token)" >> $GITHUB_ENV
- name: Add CI user to admin role
run: |
kubectl patch configmap everest-rbac -n everest-system --patch "$(kubectl get configmap everest-rbac -n everest-system -o json | jq '.data["policy.csv"] += "\ng, everest_ci, role:admin"' | jq '{data: { "policy.csv": .data["policy.csv"] } }')"
kubectl get configmap everest-rbac -n everest-system -ojsonpath='{.data.policy\.csv}'
- name: Run integration tests
run: |
cd api-tests
make init
make test
- name: Run debug commands on failure
if: ${{ failure() }}
run: |
kubectl -n everest-system describe pods
kubectl -n everest-monitoring describe pods
kubectl -n everest describe pods
kubectl -n everest-system logs deploy/everest-server
integration_tests_cli:
name: CLI Integration Tests
strategy:
fail-fast: false
matrix:
go-version: [ 1.23.x ]
may-fail: [ false ]
runs-on: ubuntu-20.04
env:
PERCONA_VERSION_SERVICE_URL: https://check-dev.percona.com/versions/v1
steps:
- name: Set up Go release
uses: percona-platform/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Set GO_VERSION environment variable
run: |
go version
echo "GO_VERSION=$(go version)" >> $GITHUB_ENV
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
lfs: true
ref: ${{ github.event.pull_request.head.sha }}
- name: Enable Go modules cache
uses: percona-platform/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ matrix.os }}-go-${{ matrix.go-version }}-modules-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ matrix.os }}-go-${{ matrix.go-version }}-modules-
- name: Enable Go build cache
uses: percona-platform/cache@v3
with:
path: ~/.cache/go-build
key: ${{ matrix.os }}-go-${{ matrix.go-version }}-build-${{ github.ref }}-${{ hashFiles('**') }}
restore-keys: |
${{ matrix.os }}-go-${{ matrix.go-version }}-build-${{ github.ref }}-
${{ matrix.os }}-go-${{ matrix.go-version }}-build-
- name: Set up Go release for CLI
uses: percona-platform/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Build CLI binary
run: |
make init
make build-cli
- name: Create KIND cluster
uses: helm/kind-action@v1.10.0
- name: Run integration tests
working-directory: cli-tests
id: cli-tests
run: |
make init
make install-operators
make test-cli
- name: Attach the report
if: ${{ always() && steps.cli-tests.outcome != 'skipped' }}
uses: actions/upload-artifact@v4
with:
name: cli-tests-report
path: cli-tests/test-report
overwrite: true
integration_tests_flows:
strategy:
fail-fast: false
matrix:
make_target: [
'test-all-operators',
'test-mongo-operator',
'test-pg-operator',
'test-pxc-operator',
'test-namespaces'
]
name: CLI tests
uses: ./.github/workflows/cli-tests.yml
secrets: inherit
with:
make_target: ${{ matrix.make_target }}
merge-gatekeeper:
needs: [ test, check, integration_tests_api, integration_tests_flows, integration_tests_cli]
name: Merge Gatekeeper
if: ${{ always() }}
runs-on: ubuntu-22.04
steps:
- name: Run Merge Gatekeeper
uses: upsidr/merge-gatekeeper@v1.2.1
with:
self: Merge Gatekeeper
token: ${{ secrets.GITHUB_TOKEN }}
interval: 45
timeout: 300
ignored: "license/snyk (Percona Everest), security/snyk (Percona Everest)"
ref: ${{ github.event.pull_request.head.sha || github.sha }}