forked from k8ssandra/k8ssandra
-
Notifications
You must be signed in to change notification settings - Fork 0
357 lines (314 loc) · 12.1 KB
/
integration-tests-release.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
---
name: Integration Tests and Release
on:
pull_request:
paths:
- 'pkg/**'
- 'cmd/**'
- 'charts/**'
- 'tests/integration/**'
- '.github/workflows/**'
push:
branches:
branches-ignore:
- 'docs'
- 'docs-v1'
- 'docs-v2'
paths:
- 'pkg/**'
- 'cmd/**'
- 'charts/**'
- 'tests/integration/**'
- '.github/workflows/**'
release:
types:
- published
workflow_dispatch:
inputs:
kubernetes_version:
description: 'Kubernetes version'
required: true
default: 'v1.21.1'
tags:
description: 'Run integration tests with different versions of K8s'
jobs:
set_k8s_version:
runs-on: ubuntu-latest
outputs:
kubernetes_version: ${{ steps.k8s-version.outputs.kubernetes_version }}
steps:
- id: k8s-version
name: Set Kubernetes version
env:
DEFAULT_K8S_VERSION: v1.21.1
run: |
if [[ -z "${{ github.event.inputs.kubernetes_version }}" ]]; then
echo '::set-output name=kubernetes_version::${{ env.DEFAULT_K8S_VERSION }}'
else
echo '::set-output name=kubernetes_version::${{ github.event.inputs.kubernetes_version }}'
fi
build_docker_images:
name: Build Docker Images
needs: [set_k8s_version]
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-integ-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-integ-
- name: Create env variables
run: ./.github/scripts/env_variables.sh
- name: Create chart release for the upgrader image
run: |
scripts/install-yq.sh ${{ env.YQ_VERSION }}
VER=$(bin/yq eval '.version' charts/k8ssandra/Chart.yaml)
mkdir -p build/$VER
cp -rv charts/* build/$VER/
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: cmd/k8ssandra-client/Dockerfile
push: false
tags: k8ssandra/k8ssandra-tools:latest
platforms: linux/amd64
outputs: type=docker,dest=/tmp/k8ssandra-tools.tar
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Upload k8ssandra-tools image
uses: actions/upload-artifact@v2
with:
name: k8ssandra-tools
path: /tmp/k8ssandra-tools.tar
integration-tests:
runs-on: ubuntu-latest
needs: [set_k8s_version, build_docker_images]
strategy:
fail-fast: false
matrix:
k8s_version: ["${{ needs.set_k8s_version.outputs.kubernetes_version }}"]
cassandra_version: ["3.11.10", "4.0.0"]
scenario:
- "TestMedusaDeploymentScenario/\"S3\""
- "TestMedusaDeploymentScenario/\"Minio\""
- "TestMedusaDeploymentScenario/\"local\""
- "TestMedusaDeploymentScenario/\"azure_blobs\""
- "TestReaperDeploymentScenario"
- "TestMonitoringDeploymentScenario"
- "TestStargateDeploymentScenario"
#- "TestRestoreAfterUpgrade"
#- "TestUpgradeScenario"
- "TestCustomCassandraConfiguration"
exclude:
- scenario: "TestUpgradeScenario"
k8s_version: "v1.22.2"
- scenario: "TestRestoreAfterUpgrade"
k8s_version: "v1.22.2"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-k8ssandra-buildx
restore-keys: |
${{ runner.os }}-k8ssandra-buildx
- name: Create env variables
run: ./.github/scripts/env_variables.sh
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: ${{ env.GO_VERSION }}
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: ${{ env.HELM_VERSION }}
- name: Kind kube-proxy issue workaround
run: sudo sysctl net/netfilter/nf_conntrack_max=524288
- name: Download k8ssandra-tools image
uses: actions/download-artifact@v2
with:
name: k8ssandra-tools
path: /tmp
- name: Load Docker images
run: |
docker load --input /tmp/k8ssandra-tools.tar
- name: Install Dependencies
run: |
set -x
sudo apt-get update || echo "something went slightly wrong with apt-get update"
# install kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
# Update Helm dependencies
./scripts/update-helm-deps.sh
- name: Write Secrets
run: |
printf "%s" '${{ secrets.K8SSANDRA_MEDUSA_SECRET_S3 }}' > ~/medusa_secret_s3.yaml
printf "%s" '${{ secrets.K8SSANDRA_MEDUSA_SECRET_AZURE }}' > ~/medusa_secret_azure.yaml
- name: Check if integration tests can run
env:
SCENARIO: ${{ matrix.scenario }}
run: |
if [[ $SCENARIO == *"S3"* ]]; then
# Medusa on S3 requires a secret. Skip integration tests if the secret is absent.
if [[ -s ~/medusa_secret_s3.yaml ]]; then
echo "IT_CAN_RUN=yes" >> $GITHUB_ENV
fi
elif [[ $SCENARIO == *"azure"* ]]; then
# Medusa on Azure requires a secret. Skip integration tests if the secret is absent.
if [[ -s ~/medusa_secret_azure.yaml ]]; then
echo "IT_CAN_RUN=yes" >> $GITHUB_ENV
fi
else
echo "IT_CAN_RUN=yes" >> $GITHUB_ENV
fi
- name: Run Integration Tests
if: ${{ env.IT_CAN_RUN == 'yes' }}
env:
SCENARIO: ${{ matrix.scenario }}
K8SSANDRA_CASSANDRA_VERSION: ${{ matrix.cassandra_version }}
K8SSANDRA_MEDUSA_BUCKET_NAME: ${{ secrets.K8SSANDRA_MEDUSA_BUCKET_NAME }}
K8SSANDRA_MEDUSA_BUCKET_REGION: ${{ secrets.K8SSANDRA_MEDUSA_BUCKET_REGION }}
run: |
# Set a valid name for the artifacts in case of failure
echo "ARTIFACT_NAME=k8s-artifacts-${K8SSANDRA_CASSANDRA_VERSION}-$(echo $SCENARIO|tr '":/' '___')" >> $GITHUB_ENV
make kind-integ-test TESTS="$SCENARIO" GO_FLAGS="-v" CLUSTER_CLEANUP="success"
- name: Collect artifacts
if: ${{ failure() }}
env:
ARTIFACTS_DIR: artifacts
run: tests/integration/scripts/collect_artifacts.sh
- uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
name: k8s-artifacts-${{ env.ARTIFACT_NAME }}
path: artifacts/
# Uncomment to run with SSH on failure
- name: Setup tmate session
if: "failure() && contains(github.event.head_commit.message, '[SSH]')"
uses: mxschmitt/action-tmate@v3
timeout-minutes: 10
release:
# Release job should never run on forks and should only trigger on main pushes and published releases
if: |
( github.event_name == 'release' && github.event.action == 'published' )
|| ( github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'k8ssandra' )
runs-on: ubuntu-latest
needs: integration-tests
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Update PATH
run: |
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
- name: Create env variables
run: ./.github/scripts/env_variables.sh
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: ${{ env.HELM_VERSION }}
- name: Install and validate tool versions
run: |
scripts/install-yq.sh ${{ env.YQ_VERSION }}
helm version
yq -V
- name: Update chart dependencies
run: |
scripts/update-helm-deps.sh
- name: Compute release chart version
id: compute_next_version
run: |
DATE_TIME=$(date '+%Y%m%d%H%M%S')
RELEASE_VERSION=$(echo $(yq e '.version' charts/k8ssandra/Chart.yaml) | sed "s/-.*/-${DATE_TIME}-${GITHUB_SHA::8}/")
echo "Release version is: $RELEASE_VERSION"
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV
echo "::set-output name=RELEASE_VERSION::${RELEASE_VERSION}"
- name: Update Helm chart version
run: |
yq eval ".version |= \"${RELEASE_VERSION}\"" charts/k8ssandra/Chart.yaml -i
cat charts/k8ssandra/Chart.yaml
- name: Create working directory and copy charts
run: |
mkdir -p build/$RELEASE_VERSION
cp -rv charts/* build/$RELEASE_VERSION/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-integ-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-integ-
- name: Update k8ssandra-tools cleaner tag
run: |
yq eval ".cleaner.image.tag |= \"${RELEASE_VERSION}\"" charts/k8ssandra/values.yaml -i
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: cmd/k8ssandra-client/Dockerfile
push: true
tags: k8ssandra/k8ssandra-tools:latest, k8ssandra/k8ssandra-tools:${{ steps.compute_next_version.outputs.RELEASE_VERSION }}
platforms: linux/amd64
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Generate package archives
run: |
ls | while read c; do
if [[ -d $c ]]; then
helm package $c
fi
done
working-directory: build/${{ steps.compute_next_version.outputs.RELEASE_VERSION }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
# Helm Release
- uses: google-github-actions/setup-gcloud@v0
with:
version: '318.0.0'
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- name: Download current index from Google Cloud
env:
GCP_HELM_BUCKET_NAME: ${{ secrets.GCP_HELM_BUCKET_NAME }}
run: gsutil cp gs://$GCP_HELM_BUCKET_NAME/stable/index.yaml ./
working-directory: build/${{ steps.compute_next_version.outputs.RELEASE_VERSION }}
- name: Regenerate Helm index
env:
GCP_HELM_BUCKET_NAME: ${{ secrets.GCP_HELM_BUCKET_NAME }}
run: helm repo index . --merge index.yaml --url "https://$GCP_HELM_BUCKET_NAME/stable/"
working-directory: build/${{ steps.compute_next_version.outputs.RELEASE_VERSION }}
- name: Upload packages and index
env:
GCP_HELM_BUCKET_NAME: ${{ secrets.GCP_HELM_BUCKET_NAME }}
run: |
gsutil cp ./*.tgz gs://$GCP_HELM_BUCKET_NAME/stable/
gsutil cp ./index.yaml gs://$GCP_HELM_BUCKET_NAME/stable/
working-directory: build/${{ steps.compute_next_version.outputs.RELEASE_VERSION }}
# GitHub Release
- name: Upload chart package to GitHub Release
uses: fnkr/github-action-ghr@v1
if: github.event_name == 'release' && github.event.action == 'published'
env:
GHR_PATH: build/${{ steps.compute_next_version.outputs.RELEASE_VERSION }}/k8ssandra-${{ env.RELEASE_VERSION }}.tgz
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}