forked from kubeshop/helm-charts
-
Notifications
You must be signed in to change notification settings - Fork 0
241 lines (208 loc) · 11.8 KB
/
helm-deploy-testkube-charts-develop.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
name: Releasing Testkube Helm charts to Develop k8s Cluster on Repository Dispatch
concurrency: develop_cluster
on:
repository_dispatch:
types:
[
trigger-workflow-api-develop,
trigger-workflow-dashboard-develop,
trigger-workflow-operator-develop,
]
env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER_NAME: ${{ secrets.GKE_CLUSTER_NAME_DEVELOP }}
GKE_ZONE: ${{ secrets.GKE_ZONE_DEVELOP }}
DEPLOYMENT_NAME: testkube
ENV: develop
jobs:
release_charts_if_image_updated:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.client_payload.ref }}
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
- run: |-
gcloud --quiet auth configure-docker
- uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e
with:
cluster_name: ${{ env.GKE_CLUSTER_NAME }}
location: ${{ env.GKE_ZONE }}
credentials: ${{ secrets.GKE_SA_KEY }}
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.10.0
- name: Modify executors.json file if any executor Docker image was updated
if: ${{ github.event.client_payload.image_tag_api}}
run: |
#pull the latest changes in case other GH workflow altered executors.json file
git pull origin develop
export image_tag=${{ github.event.client_payload.image_tag_api }}
export executor_names="artillery curl cypress ginkgo gradle init jmeter jmeterd k6 kubepug maven playwright postman scraper soapui tracetest zap logs-sidecar"
for executor_name in $executor_names; do
sed -i "s/\(\"image\":.*$executor_name.*:\)[^\"]*\(\"\)/\1$image_tag\2/" ./charts/testkube-api/executors.json
done
cat ./charts/testkube-api/executors.json
- name: Commit executors.json
if: ${{ github.event.client_payload.image_tag_api}}
run: |
git config user.name "kubeshop-bot"
git config user.email "[email protected]"
if [[ $(git status --porcelain ./charts/testkube-api/executors.json) ]]; then
git add ./charts/testkube-api/executors.json
git commit -m "Update executors.json"
git push --force origin develop
else
echo "Executors' image tags were not updated"
fi
- name: Installing repositories
run: |
helm repo add bitnami https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami
- name: Get image tag of Testkube APi, Dashboard, Operator
id: vars
run: |
echo ::set-output name=api_image_tag::$(kubectl get deployment testkube-api-server -o=jsonpath='{$.spec.template.spec.containers[:1].image}' -n ${{ env.DEPLOYMENT_NAME }} | awk -F':' '{print $2}') || exit 1
echo ::set-output name=operator_image_tag::$(kubectl get deployment testkube-operator-controller-manager -o=jsonpath='{$.spec.template.spec.containers[1].image}' -n ${{ env.DEPLOYMENT_NAME }} | awk -F':' '{print $2}') || exit 1
echo ::set-output name=dashboard_image_tag::$(kubectl get deployment testkube-dashboard -o=jsonpath='{$.spec.template.spec.containers[:1].image}' -n ${{ env.DEPLOYMENT_NAME }} | awk -F':' '{print $2}') || exit 1
- name: Deploy if Testkube API image is updated
if: ${{ github.event.client_payload.image_tag_api }}
run: |
helm dependency update ./charts/testkube
helm upgrade --debug --install --atomic --timeout 180s ${{ env.DEPLOYMENT_NAME }} ./charts/testkube --namespace ${{ env.DEPLOYMENT_NAME }} --create-namespace --values ./charts/testkube/values-${{ env.ENV }}.yaml --set testkube-api.image.tag=${{ github.event.client_payload.image_tag_api }} --set testkube-operator.image.tag=${{ steps.vars.outputs.operator_image_tag }} --set testkube-dashboard.image.tag=${{ steps.vars.outputs.dashboard_image_tag }} --set mongodb.livenessProbe.enabled=false --set mongodb.readinessProbe.enabled=false
- name: Deploy if Testkube Dashboard image is updated
if: ${{ github.event.client_payload.image_tag_dashboard }}
run: |
helm dependency update ./charts/testkube
helm upgrade --debug --install --atomic --timeout 180s ${{ env.DEPLOYMENT_NAME }} ./charts/testkube --namespace ${{ env.DEPLOYMENT_NAME }} --create-namespace --values ./charts/testkube/values-${{ env.ENV }}.yaml --set testkube-dashboard.image.tag=${{ github.event.client_payload.image_tag_dashboard }} --set testkube-operator.image.tag=${{ steps.vars.outputs.operator_image_tag }} --set testkube-api.image.tag=${{ steps.vars.outputs.api_image_tag }} --set mongodb.livenessProbe.enabled=false --set mongodb.readinessProbe.enabled=false
- name: Deploy if Testkube Operator image is updated
if: ${{ github.event.client_payload.image_tag_operator }}
run: |
helm dependency update ./charts/testkube
helm upgrade --debug --install --atomic --timeout 180s ${{ env.DEPLOYMENT_NAME }} ./charts/testkube --namespace ${{ env.DEPLOYMENT_NAME }} --create-namespace --values ./charts/testkube/values-${{ env.ENV }}.yaml --set testkube-operator.image.tag=${{ github.event.client_payload.image_tag_operator }} --set testkube-dashboard.image.tag=${{ steps.vars.outputs.dashboard_image_tag }} --set testkube-api.image.tag=${{ steps.vars.outputs.api_image_tag }} --set mongodb.livenessProbe.enabled=false --set mongodb.readinessProbe.enabled=false
notify_slack_if_deploy_succeeds:
runs-on: ubuntu-latest
needs: release_charts_if_image_updated
steps:
- name: Slack Notification if the helm release deployment to ${{ env.ENV }} GKS succeeded.
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: testkube-logs
SLACK_COLOR: ${{ needs.release_charts_if_image_updated.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 ${{ env.GKE_CLUSTER_NAME }} GKE :party_blob:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> TestKube"
notify_slack_if_deploy_failed:
runs-on: ubuntu-latest
needs: release_charts_if_image_updated
if: always() && (needs.release_charts_if_image_updated.result == 'failure')
steps:
- name: Slack Notification if the helm release deployment to ${{ env.ENV }} GKS failed.
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: testkube-logs
SLACK_COLOR: ${{ needs.release_charts_if_image_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 to deploy into ${{ env.GKE_CLUSTER_NAME }} GKE! :boom:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> TestKube"
test_suite_run:
name: test suite for GKE cluster
runs-on: ubuntu-latest
needs: release_charts_if_image_updated
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 }}
location: ${{ env.GKE_ZONE }}
credentials: ${{ secrets.GKE_SA_KEY }}
- name: Install testkube kubectl plugin and disable telemetry
run: bash <(curl -sSLf https://get.testkube.io) beta && kubectl testkube disable telemetry
- name: Checkout tests from main Testkube repo
uses: actions/checkout@v3
with:
repository: kubeshop/testkube
path: testkube-repo
- name: Executor tests - delete/create/schedule all executor tests
working-directory: ./testkube-repo
run: chmod +x ./test/scripts/executor-tests/run.sh && ./test/scripts/executor-tests/run.sh -d -c -s # (delete, create, schedule) - don't execute
- name: (Re)create 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
kubectl testkube create test -f ./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 tests
run: kubectl testkube run test sanity -f --git-branch develop
- name: (Re)create Dashboard E2E tests (from CRD)
working-directory: ./testkube-repo
run: |-
# enabling debug mode
set -x
kubectl -n testkube delete test dashboard-e2e-tests --ignore-not-found=true
kubectl apply -f ./test/dashboard-e2e/crd/crd.yaml -ntestkube
- name: (Re)create staging testsuite
working-directory: ./testkube-repo
run: |-
# enabling debug mode
set -x
kubectl -n testkube delete testsuite staging-testsuite --ignore-not-found=true
kubectl testkube create testsuite -f ./test/suites/staging-testsuite.json --name staging-testsuite
- name: Run staging testsuite
run: kubectl testkube run testsuite staging-testsuite -f --git-branch develop
notify_slack_if_test_suite_succeeds:
runs-on: ubuntu-latest
needs: test_suite_run
steps:
- name: Slack Notification if the test suite run on ${{ env.ENV }} GKE succeeded.
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: testkube-logs
SLACK_COLOR: ${{ needs.test_suite_run.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 ${{ env.GKE_CLUSTER_NAME }} 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
if: always() && (needs.test_suite_run.result == 'failure')
steps:
- name: Slack Notification if the test suite run on ${{ env.ENV }} GKE failed.
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: testkube-logs
SLACK_COLOR: ${{ needs.test_suite_run.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 ${{ env.GKE_CLUSTER_NAME }} GKE! :boom:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> TestKube"