-
Notifications
You must be signed in to change notification settings - Fork 55
484 lines (421 loc) · 18.2 KB
/
helm-releaser-testkube-main-chart-only.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
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
name: Releasing Testkube main helm chart
concurrency: demo_cluster
on:
push:
paths:
- "charts/testkube**"
- "scripts/main_chart_releaser.sh"
- "charts/testkube/values-demo.yaml"
- ".github/workflows/helm-releaser-testkube-main-chart-only.yaml"
- "!charts/testkube/Chart.yaml"
- "!charts/testkube-api/Chart.yaml"
- "!charts/testkube-dashboard/Chart.yaml"
- "!charts/testkube-operator/Chart.yaml"
- "!charts/testkube-api/executors.json"
branches:
- main
env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER_NAME_DEV: ${{ secrets.GKE_CLUSTER_NAME_DEV }} # Add your cluster name here.
GKE_ZONE_DEV: ${{ secrets.GKE_ZONE_DEV }} # Add your cluster zone here.
DEPLOYMENT_NAME: testkube # Add your deployment name here.
jobs:
release_charts:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Update main Chart.yaml
run: |
cd ./scripts
chmod +x main_chart_releaser.sh
./main_chart_releaser.sh --main-chart true
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.2.1
with:
charts_dir: charts
env:
CR_TOKEN: "${{ secrets.CI_BOT_TOKEN }}"
CR_SKIP_EXISTING: true
notify_slack_if_helm_chart_release_fails:
runs-on: ubuntu-latest
needs: release_charts
if: always() && (needs.release_charts.result == 'failure')
steps:
- name: Slack Notification if Helm Release action failed
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: testkube-logs
SLACK_COLOR: ${{ needs.release_charts.result }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_TITLE: Helm Chart release action failed :boom:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> TestKube"
refreshing_gh_pages:
needs: release_charts
runs-on: ubuntu-latest
steps:
- name: Triggering refresh for GH-pages to make just released charts available
run: |
curl -s --fail --request POST \
--url https://api.github.com/repos/kubeshop/helm-charts/pages/builds \
--header "Authorization: Bearer $USER_TOKEN"
env:
# You must create a personal token with repo access as GitHub does
# not yet support server-to-server page builds.
USER_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
checking_that_ghpages_updated:
needs: refreshing_gh_pages
runs-on: ubuntu-latest
steps:
- name: Making sure that they are abvailable now.
run: |
status=""
counter=0
while [[ $status != \"built\" ]]
do
status=$(curl -s \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/kubeshop/helm-charts/pages/builds/latest \
--header "Authorization: Bearer $USER_TOKEN" | jq .status)
echo "Checking latest GH pages build status --> $status"
sleep 5
counter=$(expr $counter + 1)
if [[ $status == \"errored\" ]] || [[ $counter == 120 ]]; then
echo "Something went wrong. Please check GH's pages issues."
exit 1
fi
done
env:
# You must create a personal token with repo access as GitHub does
# not yet support server-to-server page builds.
USER_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
notify_slack_if_release_succeeds:
runs-on: ubuntu-latest
needs: checking_that_ghpages_updated
steps:
- name: Slack Notification if the helm release pipeline succeeded.
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: testkube-logs
SLACK_COLOR: ${{ needs.checking_that_ghpages_updated.result }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_TITLE: Helm chart release succeed and GH pages got updated :party_blob:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> TestKube"
notify_slack_if_gh_pages_update_failed:
runs-on: ubuntu-latest
needs: checking_that_ghpages_updated
if: always() && (needs.checking_that_ghpages_updated.result == 'failure')
steps:
- name: Slack Notification if the helm release GH Pages failed.
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: testkube-logs
SLACK_COLOR: ${{ needs.checking_that_ghpages_updated.result }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_TITLE: Helm chart release failed on GH pages update! :boom:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> TestKube"
get_agent_version:
name: Pass Testkube OSS chart version to cloud-charts repo
needs: notify_slack_if_release_succeeds
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.10.0
- name: Get charts version
run: echo agent-version=$(helm show chart ./charts/testkube | grep -E "^version:" | awk '{print $2}') >> $GITHUB_ENV
- name: Repository dispatch
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.CI_BOT_TOKEN }}
repository: kubeshop/testkube-cloud-charts
event-type: trigger-workflow-testkube-agent-main
client-payload: '{"agentVersion": "${{ env.agent-version }}"}'
deploy-to-testkube-dev-gke:
name: Deploy
runs-on: ubuntu-latest
needs: notify_slack_if_release_succeeds
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
# Configure Docker to use the gcloud command-line tool as a credential
# helper for authentication
- run: |-
gcloud --quiet auth configure-docker
# Get the GKE credentials so we can deploy to the cluster
- uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e
with:
cluster_name: ${{ env.GKE_CLUSTER_NAME_DEV }}
location: ${{ env.GKE_ZONE_DEV }}
credentials: ${{ secrets.GKE_SA_KEY }}
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.10.0
- name: Installing repositories
run: |
helm repo add helm-charts https://kubeshop.github.io/helm-charts
helm repo add bitnami https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami
# Deploy the Docker image to the GKE cluster
- name: Deploy
run: |-
helm upgrade --install --atomic --timeout 180s testkube helm-charts/testkube --namespace testkube --create-namespace --values ./charts/testkube/values-demo.yaml --debug --set testkube-api.cliIngress.oauth.clientID=${{ secrets.TESTKUBE_DEMO_OAUTH_CLIENT_ID }} --set testkube-api.cliIngress.oauth.clientSecret=${{ secrets.TESTKUBE_DEMO_OAUTH_CLIENT_SECRET }} --set mongodb.livenessProbe.enabled=false --set mongodb.readinessProbe.enabled=false
notify_slack_if_deploy_dev_succeeds:
runs-on: ubuntu-latest
needs: deploy-to-testkube-dev-gke
steps:
- name: Slack Notification if the helm release deployment to DEV GKS succeeded.
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: testkube-logs
SLACK_COLOR: ${{ needs.deploy-to-testkube-dev-gke.result }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_TITLE: Helm chart release successfully deployed into ${{ secrets.GKE_CLUSTER_NAME_DEV }} GKE :party_blob:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> TestKube"
notify_slack_if_deploy_dev_failed:
runs-on: ubuntu-latest
needs: deploy-to-testkube-dev-gke
if: always() && (needs.deploy-to-testkube-dev-gke.result == 'failure')
steps:
- name: Slack Notification if the helm release deployment to DEV GKS failed.
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: testkube-logs
SLACK_COLOR: ${{ needs.deploy-to-testkube-dev-gke.result }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_TITLE: Helm chart release failed to deploy into ${{ secrets.GKE_CLUSTER_NAME_DEV }} GKE! :boom:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> TestKube"
update_release_notes:
needs: notify_slack_if_release_succeeds
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get Latest Tag
id: get_latest_tag
run: |
latest_tag=$(git describe --abbrev=0 --tags)
echo "::set-output name=latest_tag::${latest_tag}"
- name: Get Previous Tag
id: get_previous_tag
run: |
previous_tag=$(git describe --abbrev=0 --tags ${TAG}^)
echo "::set-output name=previous_tag::${previous_tag}"
env:
TAG: ${{ steps.get_latest_tag.outputs.latest_tag }}
- name: Generate Changelog
id: generate_changelog
env:
GH_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
run: |
#!/bin/bash
PREVIOUS_TAG=${{ steps.get_previous_tag.outputs.previous_tag }}
CURRENT_TAG=${{ steps.get_latest_tag.outputs.latest_tag }}
echo $PREVIOUS_TAG
echo $CURRENT_TAG
MERGED_PRS=$(git log --merges --pretty=format:"- %h: %s (#%b) (@%an)" $PREVIOUS_TAG..$CURRENT_TAG)
echo $MERGED_PRS
if [ -n "$MERGED_PRS" ]; then
echo "# Changelog" > CHANGELOG.md
FEATURE_PRS=""
FIX_PRS=""
OTHER_PRS=""
DOCS_PRS=""
while IFS= read -r pr; do
sha=$(echo "$pr" | awk '{print $1 " " $2}')
pr_number=$(echo "$pr" | awk -F'#' '{print "#" $2}' | awk '{print $1}')
pr_title=$(echo "$pr" | awk -F'[(]|[)]' '{sub(/^#/, "", $2); print $2}')
author=$(echo "$pr" | awk -F'[()]' '{print "(" $4 ")"}')
if [[ "$pr_title" == *"feat"* ]]; then
FEATURE_PRS+="\n ${sha} ${pr_title} ${pr_number} ${author}"
echo "New features"
echo $FEATURE_PRS
elif [[ "$pr_title" == *"fix"* ]]; then
FIX_PRS+="\n ${sha} ${pr_title} ${pr_number} ${author}"
echo "Bug fixes"
echo $FIX_PRS
elif [[ "$pr_title" == *"docs"* ]]; then
DOCS_PRS+="\n ${sha} ${pr_title} ${pr_number} ${author}"
echo "Documentation updates"
echo $DOCS_PRS
else
OTHER_PRS+="\n ${sha} ${pr_title} ${pr_number} ${author}"
echo "Other changes"
echo $OTHER_PRS
fi
done < <(echo "$MERGED_PRS")
if [ -n "$FEATURE_PRS" ]; then
echo "## Features" >> CHANGELOG.md
echo -e "$FEATURE_PRS" >> CHANGELOG.md
echo "" >> CHANGELOG.md
fi
if [ -n "$FIX_PRS" ]; then
echo "## Bug Fixes" >> CHANGELOG.md
echo -e "$FIX_PRS" >> CHANGELOG.md
echo "" >> CHANGELOG.md
fi
if [ -n "$DOCS_PRS" ]; then
echo "## Documentation Updates" >> CHANGELOG.md
echo -e "$DOCS_PRS" >> CHANGELOG.md
echo "" >> CHANGELOG.md
fi
if [ -n "$OTHER_PRS" ]; then
echo "## Other Changes" >> CHANGELOG.md
echo -e "$OTHER_PRS" >> CHANGELOG.md
echo "" >> CHANGELOG.md
fi
echo "Printing changelog"
cat CHANGELOG.md
echo "Updating release"
gh release edit $CURRENT_TAG --notes-file CHANGELOG.md
else
echo "No merged pull requests found. Adding commits"
COMMIT_CHANGELOG=$(git log --pretty=format:"- %s %h (@%an)" $PREVIOUS_TAG..$CURRENT_TAG)
echo "# Commit Changelog" > CHANGELOG.md
echo "" >> CHANGELOG.md
echo "${COMMIT_CHANGELOG}" >> CHANGELOG.md
gh release edit $CURRENT_TAG --notes-file CHANGELOG.md
fi
test_suite_run_dev:
name: test suite for DEV GKE.
runs-on: ubuntu-latest
needs: deploy-to-testkube-dev-gke
steps:
# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
# Configure Docker to use the gcloud command-line tool as a credential
# helper for authentication
- run: |-
gcloud --quiet auth configure-docker
# Get the GKE credentials so we can deploy to the cluster
- uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e
with:
cluster_name: ${{ env.GKE_CLUSTER_NAME_DEV }}
location: ${{ env.GKE_ZONE_DEV }}
credentials: ${{ secrets.GKE_SA_KEY }}
- name: Install testkube kubectl plugin
run: bash < <(curl -sSLf https://get.testkube.io )
- name: Disable telemetry (action)
id: disable_telemetry
uses: kubeshop/testkube-docker-action@v1
with:
command: disable
resource: telemetry
- name: Checkout tests from main Testkube repo
uses: actions/checkout@v3
with:
repository: kubeshop/testkube
path: testkube-repo
ref: main
- name: Executor tests - create/update and schedule all executor tests (with CLI)
working-directory: ./testkube-repo
run: chmod +x ./test/scripts/executor-tests/run.sh && ./test/scripts/executor-tests/run.sh -c -s # (create/update, schedule) - don't execute
- name: Delete Postman Sanity test (with CLI)
working-directory: ./testkube-repo
run: |-
# enabling debug mode
set -x
kubectl -n testkube delete test sanity --ignore-not-found=true
kubectl -n testkube delete secret sanity-secrets --ignore-not-found=true
- name: Create Postman Sanity test (action)
id: create_postman_sanity_test
uses: kubeshop/testkube-docker-action@v1
with:
command: create
resource: test
parameters: "-f ./testkube-repo/test/postman/TestKube-Sanity.postman_collection.json --name sanity --type postman/collection -v api_uri=http://testkube-api-server:8088 -v test_api_uri=http://testkube-api-server:8088 -v test_type=postman/collection -v test_name=fill-me -v execution_name=fill-me"
- name: Run Postman Sanity test (action)
id: run_postman_sanity_test
uses: kubeshop/testkube-docker-action@v1
with:
command: run
resource: test
parameters: "sanity -f"
- name: Create/update Dashboard E2E tests (from CRD)
working-directory: ./testkube-repo
run: |-
# enabling debug mode
set -x
kubectl apply -f ./test/dashboard-e2e/crd/crd.yaml -ntestkube
- name: (Re)create demo testsuite
working-directory: ./testkube-repo
run: |-
# enabling debug mode
set -x
kubectl -n testkube delete testsuite demo-testsuite --ignore-not-found=true
kubectl testkube create testsuite -f ./test/suites/demo-testsuite.json --name demo-testsuite
- name: Run demo testsuite (CLI)
run: kubectl testkube run testsuite demo-testsuite -f
notify_slack_if_test_suite_dev_succeeds:
runs-on: ubuntu-latest
needs: test_suite_run_dev
steps:
- name: Slack Notification if the test suite run on DEV GKS succeeded.
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: testkube-logs
SLACK_COLOR: ${{ needs.test_suite_run_dev.result }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_TITLE: Test suite successfully run against ${{ secrets.GKE_CLUSTER_NAME_DEV }} GKE :party_blob:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> TestKube"
notify_slack_if_test_suite_failed:
runs-on: ubuntu-latest
needs: test_suite_run_dev
if: always() && (needs.test_suite_run_dev.result == 'failure')
steps:
- name: Slack Notification if the test suite run on DEV GKS failed.
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: testkube-logs
SLACK_COLOR: ${{ needs.test_suite_run_dev.result }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_TITLE: Test suite FAILED to run on ${{ secrets.GKE_CLUSTER_NAME_DEV }} GKE! :boom:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> TestKube"