-
Notifications
You must be signed in to change notification settings - Fork 2
341 lines (298 loc) · 13 KB
/
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
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
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
types: [opened, synchronize, reopened, labeled]
jobs:
golang-tests:
name: Go unit tests
timeout-minutes: 30
strategy:
fail-fast: true
runs-on: ubuntu-latest
env:
TOOLS_PATH: "/opt/tools/bin"
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up Go release
uses: actions/setup-go@v5
with:
go-version: '1.23'
check-latest: true
- name: Install tools
run: |
mkdir -p $TOOLS_PATH
echo $TOOLS_PATH >> $GITHUB_PATH
curl -LO https://dl.k8s.io/release/v$KUBECTL_VERSION/bin/linux/amd64/kubectl
curl -LO "https://dl.k8s.io/v$KUBECTL_VERSION/bin/linux/amd64/kubectl.sha256"
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
chmod +x kubectl
cp kubectl "$TOOLS_PATH"
rm kubectl
env:
KUBECTL_VERSION: 1.27.9
- name: Run tests
run:
make test
env:
PXC_OPERATOR_VERSION: 1.16.1
PSMDB_OPERATOR_VERSION: 1.18.0
PG_OPERATOR_VERSION: 2.5.0
PERCONA_VERSION_SERVICE_URL: https://check-dev.percona.com/versions/v1
integration-tests:
name: Integration tests
timeout-minutes: 30
strategy:
fail-fast: true
runs-on: ubuntu-latest
env:
TOOLS_PATH: "/opt/tools/bin"
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up Go release
uses: actions/setup-go@v5
with:
go-version: '1.23'
check-latest: true
- name: Build operator
run:
make build
- name: Install tools
run: |
mkdir -p $TOOLS_PATH
echo $TOOLS_PATH >> $GITHUB_PATH
# Kubectl
curl -LO https://dl.k8s.io/release/v$KUBECTL_VERSION/bin/linux/amd64/kubectl
curl -LO "https://dl.k8s.io/v$KUBECTL_VERSION/bin/linux/amd64/kubectl.sha256"
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
chmod +x kubectl
cp kubectl "$TOOLS_PATH"
rm kubectl
# Kuttl
curl -Lo ./kubectl-kuttl https://github.com/kudobuilder/kuttl/releases/download/v0.15.0/kubectl-kuttl_0.15.0_linux_x86_64
chmod +x ./kubectl-kuttl
mv ./kubectl-kuttl "$TOOLS_PATH"
env:
KUBECTL_VERSION: 1.27.9
- name: Run core tests
if: always()
run: |
kubectl kuttl test --config ./tests/integration/kuttl-core.yaml
env:
PXC_OPERATOR_VERSION: 1.16.1
PSMDB_OPERATOR_VERSION: 1.18.0
PG_OPERATOR_VERSION: 2.5.0
PERCONA_VERSION_SERVICE_URL: https://check-dev.percona.com/versions/v1
- name: Run features tests
if: always()
run: |
kubectl kuttl test --config ./tests/integration/kuttl-features.yaml
env:
PXC_OPERATOR_VERSION: 1.16.1
PSMDB_OPERATOR_VERSION: 1.18.0
PG_OPERATOR_VERSION: 2.5.0
PERCONA_VERSION_SERVICE_URL: https://check-dev.percona.com/versions/v1
- name: Run upgrade tests
if: always()
run: |
kubectl kuttl test --config ./tests/integration/kuttl-upgrade.yaml
env:
PXC_OPERATOR_VERSION: 1.16.1
PSMDB_OPERATOR_VERSION: 1.18.0
PG_OPERATOR_VERSION: 2.5.0
PREVIOUS_PG_OPERATOR_VERSION: 2.4.1
PREVIOUS_PXC_OPERATOR_VERSION: 1.15.0
PREVIOUS_PSMDB_OPERATOR_VERSION: 1.17.0
PERCONA_VERSION_SERVICE_URL: https://check-dev.percona.com/versions/v1
eks-e2e-tests:
name: E2E tests (EKS)
if: contains(github.event.pull_request.labels.*.name, 'test/e2e') || contains(github.event.pull_request.labels.*.name, 'test/e2e-upgrade') || contains(github.event.pull_request.labels.*.name, 'test/e2e-core')
timeout-minutes: 80
concurrency: eks-e2e-tests
strategy:
fail-fast: true
runs-on: ubuntu-latest
env:
TOOLS_PATH: "/opt/tools/bin"
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up Go release
uses: actions/setup-go@v5
with:
go-version: '1.23'
check-latest: true
- name: Build operator
run:
make build
- name: Configure AWS
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.EVEREST_EKS_E2E_IAM_USER_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.EVEREST_EKS_E2E_IAM_USER_ACCESS_KEY_SECRET }}
aws-region: us-east-2
- name: Configure env
run: |
mkdir -p $TOOLS_PATH
echo $TOOLS_PATH >> $GITHUB_PATH
aws eks update-kubeconfig --name everest-e2e-dev-eks-cluster
- name: Install tools
run: |
# Kubectl
curl -LO https://dl.k8s.io/release/v$KUBECTL_VERSION/bin/linux/amd64/kubectl
curl -LO "https://dl.k8s.io/v$KUBECTL_VERSION/bin/linux/amd64/kubectl.sha256"
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
chmod +x kubectl
cp kubectl "$TOOLS_PATH"
rm kubectl
# Kuttl
curl -Lo ./kubectl-kuttl https://github.com/kudobuilder/kuttl/releases/download/v0.15.0/kubectl-kuttl_0.15.0_linux_x86_64
chmod +x ./kubectl-kuttl
mv ./kubectl-kuttl "$TOOLS_PATH"
# Install EKSCTL
ARCH=amd64
PLATFORM=$(uname -s)_$ARCH
curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_$PLATFORM.tar.gz"
tar -xzf eksctl_$PLATFORM.tar.gz -C "$TOOLS_PATH"
chmod +x "$TOOLS_PATH"/eksctl
env:
KUBECTL_VERSION: 1.27.9
- name: Scale up cluster
run: |
eksctl scale nodegroup --cluster="$CLUSTER_NAME" --nodes=10 "$NODEPOOL_NAME" --wait
env:
CLUSTER_NAME: "everest-e2e-dev-eks-cluster"
NODEPOOL_NAME: "everest-e2e-dev-eks-workers"
- name: Run upgrade tests
if: contains(github.event.pull_request.labels.*.name, 'test/e2e') || contains(github.event.pull_request.labels.*.name, 'test/e2e-upgrade')
run: |
kubectl kuttl test --config ./tests/e2e/kuttl-upgrade.yaml
env:
PXC_OPERATOR_VERSION: 1.16.1
PSMDB_OPERATOR_VERSION: 1.18.0
PG_OPERATOR_VERSION: 2.5.0
PREVIOUS_PG_OPERATOR_VERSION: 2.4.1
PREVIOUS_PXC_OPERATOR_VERSION: 1.15.0
PREVIOUS_PSMDB_OPERATOR_VERSION: 1.17.0
PERCONA_VERSION_SERVICE_URL: https://check-dev.percona.com/versions/v1
- name: Clean up custom resources
if: always()
continue-on-error: true
# If this does not finish in 10 minutes, it's stuck with some resource having a finalizer.
timeout-minutes: 10
run: |
namespaces=$(kubectl get pxc -A -o jsonpath='{.items[*].metadata.namespace}')
for namespace in ${namespaces[@]}
do
kubectl -n $namespace get pxc -o name | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl patch pxc -n $namespace -p '{"metadata":{"finalizers":null}}' --type merge
done
namespaces=$(kubectl get psmdb -A -o jsonpath='{.items[*].metadata.namespace}')
for namespace in ${namespaces[@]}
do
kubectl -n $namespace get psmdb -o name | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl patch psmdb -n $namespace -p '{"metadata":{"finalizers":null}}' --type merge
done
namespaces=$(kubectl get pg -A -o jsonpath='{.items[*].metadata.namespace}')
for namespace in ${namespaces[@]}
do
kubectl -n $namespace get pg -o name | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl patch pg -n $namespace -p '{"metadata":{"finalizers":null}}' --type merge
done
namespaces=$(kubectl get db -A -o jsonpath='{.items[*].metadata.namespace}')
for namespace in ${namespaces[@]}
do
kubectl -n $namespace get db -o name | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl patch db -n $namespace -p '{"metadata":{"finalizers":null}}' --type merge
done
kubectl delete db --all-namespaces --all --cascade=foreground
kubectl delete pvc --all-namespaces --all
kubectl delete backupstorage --all-namespaces --all
kubectl get ns -o name | grep kuttl | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl delete ns
- name: Run core tests
if: contains(github.event.pull_request.labels.*.name, 'test/e2e') || contains(github.event.pull_request.labels.*.name, 'test/e2e-core')
run: |
kubectl kuttl test --config ./tests/e2e/kuttl-core.yaml
env:
PXC_OPERATOR_VERSION: 1.16.1
PSMDB_OPERATOR_VERSION: 1.18.0
PG_OPERATOR_VERSION: 2.5.0
PERCONA_VERSION_SERVICE_URL: https://check-dev.percona.com/versions/v1
- name: Clean up custom resources
if: always()
run: |
namespaces=$(kubectl get pxc -A -o jsonpath='{.items[*].metadata.namespace}')
for namespace in ${namespaces[@]}
do
kubectl -n $namespace get pxc -o name | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl patch pxc -n $namespace -p '{"metadata":{"finalizers":null}}' --type merge
done
namespaces=$(kubectl get psmdb -A -o jsonpath='{.items[*].metadata.namespace}')
for namespace in ${namespaces[@]}
do
kubectl -n $namespace get psmdb -o name | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl patch psmdb -n $namespace -p '{"metadata":{"finalizers":null}}' --type merge
done
namespaces=$(kubectl get pg -A -o jsonpath='{.items[*].metadata.namespace}')
for namespace in ${namespaces[@]}
do
kubectl -n $namespace get pg -o name | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl patch pg -n $namespace -p '{"metadata":{"finalizers":null}}' --type merge
done
namespaces=$(kubectl get db -A -o jsonpath='{.items[*].metadata.namespace}')
for namespace in ${namespaces[@]}
do
kubectl -n $namespace get db -o name | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl patch db -n $namespace -p '{"metadata":{"finalizers":null}}' --type merge
done
kubectl delete db --all-namespaces --all --cascade=foreground
kubectl delete pvc --all-namespaces --all
kubectl delete backupstorage --all-namespaces --all
kubectl get ns -o name | grep kuttl | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl delete ns
kubectl delete ns operators olm --ignore-not-found=true --wait=false
sleep 10
kubectl delete apiservice v1.packages.operators.coreos.com --ignore-not-found=true
kubectl get crd -o name | grep .coreos.com$ | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl delete crd
- name: Scale down cluster
if: always()
run: |
eksctl scale nodegroup --cluster="$CLUSTER_NAME" --nodes=0 "$NODEPOOL_NAME"
env:
CLUSTER_NAME: "everest-e2e-dev-eks-cluster"
NODEPOOL_NAME: "everest-e2e-dev-eks-workers"
- name: Clean up resources and CRDs
if: always()
run: |
kubectl get crd -o name | grep .percona.com$ | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl delete crd
kubectl delete crd postgresclusters.postgres-operator.crunchydata.com
make-bundle:
name: Make Bundle
strategy:
fail-fast: true
runs-on: ubuntu-latest
env:
TOOLS_PATH: "/opt/tools/bin"
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go release
uses: actions/setup-go@v5
with:
go-version: '1.23'
check-latest: true
- name: Install operator-sdk
run: |
mkdir -p $TOOLS_PATH
echo $TOOLS_PATH >> $GITHUB_PATH
export ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac)
export OS=$(uname | awk '{print tolower($0)}')
export OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.38.0
curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH}
gpg --keyserver keyserver.ubuntu.com --recv-keys 052996E2A20B5C7E
curl -LO ${OPERATOR_SDK_DL_URL}/checksums.txt
curl -LO ${OPERATOR_SDK_DL_URL}/checksums.txt.asc
gpg -u "Operator SDK (release) <[email protected]>" --verify checksums.txt.asc
grep operator-sdk_${OS}_${ARCH} checksums.txt | sha256sum -c -
chmod +x operator-sdk_${OS}_${ARCH}
mv operator-sdk_${OS}_${ARCH} $TOOLS_PATH/operator-sdk
- name: Make bundle and build bundle image
run: |
make bundle bundle-build