-
Notifications
You must be signed in to change notification settings - Fork 215
404 lines (352 loc) · 12.2 KB
/
systest.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
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
name: System tests
on:
# Allow manually triggering this workflow
workflow_dispatch:
inputs:
test_name:
description: "Test to run"
default: "."
log_level:
description: "Log level"
default: "debug"
push:
branches:
- staging
- trying
env:
GCLOUD_KEY: ${{ secrets.GCLOUD_KEY }}
PROJECT_NAME: ${{ secrets.PROJECT_NAME }}
CLUSTER_NAME: ${{ secrets.CLUSTER_NAME }}
CLUSTER_ZONE: ${{ secrets.CLUSTER_ZONE }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
ES_USER: ${{ secrets.ES_USER }}
ES_PASS: ${{ secrets.ES_PASS }}
MAIN_ES_IP: ${{ secrets.MAIN_ES_IP }}
TD_QUEUE_NAME: ${{ secrets.TD_QUEUE_NAME }}
TD_QUEUE_ZONE: ${{ secrets.TD_QUEUE_ZONE }}
DUMP_QUEUE_NAME: ${{ secrets.DUMP_QUEUE_NAME }}
DUMP_QUEUE_ZONE: ${{ secrets.DUMP_QUEUE_ZONE }}
CI_CLUSTER_NAME: ${{ secrets.CI_CLUSTER_NAME }}
CI_GCP_CREDENTIALS: ${{ secrets.CI_GCP_CREDENTIALS }}
CI_GCP_PROJECT_ID: ${{ secrets.CI_GCP_PROJECT_ID }}
CI_REGION_NAME: ${{ secrets.CI_REGION_NAME }}
USE_GKE_GCLOUD_AUTH_PLUGIN: True
concurrency:
group: ${{ github.base_ref == 'staging' && 'smci-staging' || format('smci-{0}-{1}', github.workflow, github.ref) }}
cancel-in-progress: ${{ github.base_ref == 'staging' && false || true }}
jobs:
filter-changes:
runs-on: ubuntu-22.04
outputs:
nondocchanges: ${{ steps.filter.outputs.nondoc }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
nondoc:
- '!**/*.md'
build-docker-images:
runs-on: ubuntu-22.04
if: ${{ needs.filter-changes.outputs.nondocchanges == 'true' }}
needs:
- filter-changes
timeout-minutes: 20
permissions:
contents: 'read'
id-token: 'write'
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.GH_ACTION_PRIVATE_KEY }}
- name: Setup gcloud authentication
uses: google-github-actions/auth@v2
with:
project_id: ${{ secrets.GCP_WI_PROJECT_ID }}
workload_identity_provider: ${{ secrets.GCP_WI_PROVIDER_SA }}
service_account: ${{ secrets.GCP_WI_SA }}
token_format: access_token
- name: Configure gcloud
uses: google-github-actions/setup-gcloud@v2
with:
version: "469.0.0"
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: extractions/netrc@v2
with:
machine: github.com
username: ${{ secrets.GH_ACTION_TOKEN_USER }}
password: ${{ secrets.GH_ACTION_TOKEN }}
if: vars.GOPRIVATE
- name: Push go-spacemesh build to docker hub
run: make dockerpush
- name: Push go-bootstrapper build to docker hub
run: make dockerpush-bs
- name: Get commit hash
id: vars
shell: bash
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- uses: extractions/netrc@v2
with:
machine: github.com
username: ${{ secrets.GH_ACTION_TOKEN_USER }}
password: ${{ secrets.GH_ACTION_TOKEN }}
if: vars.GOPRIVATE
- name: Build tests docker image
run: make -C systest docker
- name: Push tests docker images
run: make -C systest push
provision-gke-cluster:
runs-on: ubuntu-22.04
if: ${{ needs.filter-changes.outputs.nondocchanges == 'true' }}
needs:
- filter-changes
timeout-minutes: 20
permissions:
contents: 'read'
id-token: 'write'
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.GH_ACTION_PRIVATE_KEY }}
- name: Setup gcloud authentication
uses: google-github-actions/auth@v2
with:
project_id: ${{ secrets.GCP_WI_PROJECT_ID }}
workload_identity_provider: ${{ secrets.GCP_WI_PROVIDER_SA }}
service_account: ${{ secrets.GCP_WI_SA }}
token_format: access_token
- name: Configure gcloud
uses: google-github-actions/setup-gcloud@v2
with:
version: "469.0.0"
- name: Create Node Pool
id: nodepool-create
run: |
NODE_POOL_NAME="systemtest-${{ github.run_id }}"
echo "nodepool-name=${NODE_POOL_NAME}" >> $GITHUB_OUTPUT
gcloud container node-pools create $NODE_POOL_NAME \
--cluster ${{ secrets.CI_CLUSTER_NAME }} \
--num-nodes 2 \
--preemptible \
--location ${{ secrets.CI_REGION_NAME }} \
--machine-type ${{ secrets.CI_NODE_MACHINE_TYPE }} \
--disk-type pd-ssd \
--disk-size 300GB \
--image-type COS_CONTAINERD \
--enable-autorepair \
--no-enable-autoupgrade \
--node-labels env=dev,cluster=${{ secrets.CI_CLUSTER_NAME }},pipeline-id=${{ github.run_id }} \
--metadata disable-legacy-endpoints=true \
--service-account ${{ secrets.CI_GKE_NODEPOOL_SA }} \
--project ${{ secrets.CI_GCP_PROJECT_ID }} \
--quiet
echo "Node pool created: $NODE_POOL_NAME"
systest-gke:
runs-on: ubuntu-22.04
if: ${{ needs.filter-changes.outputs.nondocchanges == 'true' }}
needs:
- filter-changes
- provision-gke-cluster
timeout-minutes: 70
permissions:
contents: 'read'
id-token: 'write'
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.GH_ACTION_PRIVATE_KEY }}
- name: Setup kubectl
id: install
uses: azure/setup-kubectl@v4
with:
version: "v1.27.16"
- name: Setup gcloud authentication
uses: google-github-actions/auth@v2
with:
project_id: ${{ secrets.GCP_WI_PROJECT_ID }}
workload_identity_provider: ${{ secrets.GCP_WI_PROVIDER_SA }}
service_account: ${{ secrets.GCP_WI_SA }}
token_format: access_token
- name: Configure gcloud
uses: google-github-actions/setup-gcloud@v2
with:
version: "469.0.0"
- name: Configure gke authentication plugin
run: gcloud components install gke-gcloud-auth-plugin --quiet
- name: Configure kubectl
run: gcloud container clusters get-credentials ${{ secrets.CI_CLUSTER_NAME }} --region ${{ secrets.CI_REGION_NAME }} --project ${{ secrets.CI_GCP_PROJECT_ID }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: extractions/netrc@v2
with:
machine: github.com
username: ${{ secrets.GH_ACTION_TOKEN_USER }}
password: ${{ secrets.GH_ACTION_TOKEN }}
if: vars.GOPRIVATE
- name: Get commit hash
id: vars
shell: bash
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- uses: extractions/netrc@v2
with:
machine: github.com
username: ${{ secrets.GH_ACTION_TOKEN_USER }}
password: ${{ secrets.GH_ACTION_TOKEN }}
if: vars.GOPRIVATE
- name: set up go
uses: actions/setup-go@v5
with:
check-latest: true
go-version-file: "go.mod"
- name: Run tests
env:
test_id: systest-${{ steps.vars.outputs.sha_short }}
storage: premium-rwo=10Gi
node_selector: pipeline-id=${{ github.run_id }}
size: 20
bootstrap: 4m
level: ${{ inputs.log_level }}
clusters: 4
norbac: 1
run: make -C systest run test_name=${{ inputs.test_name }}
- name: Delete pod
if: always()
env:
test_id: systest-${{ steps.vars.outputs.sha_short }}
run: make -C systest clean
delete-gke-cluster-pool:
runs-on: ubuntu-22.04
if: always()
needs:
- filter-changes
- provision-gke-cluster
- systest-gke
timeout-minutes: 20
permissions:
contents: 'read'
id-token: 'write'
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.GH_ACTION_PRIVATE_KEY }}
- name: Setup gcloud authentication
uses: google-github-actions/auth@v2
with:
project_id: ${{ secrets.GCP_WI_PROJECT_ID }}
workload_identity_provider: ${{ secrets.GCP_WI_PROVIDER_SA }}
service_account: ${{ secrets.GCP_WI_SA }}
token_format: access_token
- name: Configure gcloud
uses: google-github-actions/setup-gcloud@v2
with:
version: "469.0.0"
- name: Delete Node Pool
run: |
NODE_POOL_NAME="systemtest-${{ github.run_id }}"
gcloud container node-pools delete $NODE_POOL_NAME \
--cluster ${{ secrets.CI_CLUSTER_NAME }} \
--location ${{ secrets.CI_REGION_NAME }} \
--project ${{ secrets.CI_GCP_PROJECT_ID }} \
--quiet
echo "Node pool deleted: $NODE_POOL_NAME"
systest-dedicated-cluster:
runs-on: ubuntu-22.04
if: ${{ needs.filter-changes.outputs.nondocchanges == 'true' }}
needs:
- filter-changes
- build-docker-images
timeout-minutes: 70
continue-on-error: true
permissions:
contents: 'read'
id-token: 'write'
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.GH_ACTION_PRIVATE_KEY }}
- name: Setup kubectl
id: install
uses: azure/setup-kubectl@v4
with:
version: "v1.27.16"
- name: Save cluster kubeconfig
run: |
mkdir -p ${{ github.workspace }}/.kube
echo "${{ secrets.CI_KUBECONFIG }}" | base64 -d > ${{ github.workspace }}/.kube/config
echo "KUBECONFIG=${{ github.workspace }}/.kube/config" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: extractions/netrc@v2
with:
machine: github.com
username: ${{ secrets.GH_ACTION_TOKEN_USER }}
password: ${{ secrets.GH_ACTION_TOKEN }}
if: vars.GOPRIVATE
- name: Get commit hash
id: vars
shell: bash
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- uses: extractions/netrc@v2
with:
machine: github.com
username: ${{ secrets.GH_ACTION_TOKEN_USER }}
password: ${{ secrets.GH_ACTION_TOKEN }}
if: vars.GOPRIVATE
- name: set up go
uses: actions/setup-go@v5
with:
check-latest: true
go-version-file: "go.mod"
- name: Run tests
env:
test_id: systest-${{ steps.vars.outputs.sha_short }}
storage: premium-rwo=10Gi
node_selector: pipeline-id=${{ github.run_id }}
size: 20
bootstrap: 4m
level: ${{ inputs.log_level }}
clusters: 4
norbac: 1
run: make -C systest run test_name=${{ inputs.test_name }}
- name: Delete pod
if: always()
env:
test_id: systest-${{ steps.vars.outputs.sha_short }}
run: make -C systest clean
systest-status:
if: always()
needs:
- filter-changes
- systest-gke
- systest-dedicated-cluster
runs-on: ubuntu-22.04
env:
# short-circuit success if no non-doc files were modified
status: ${{ (needs.filter-changes.outputs.nondocchanges == 'false' || needs.systest-gke.result == 'success' || needs.systest-dedicated-cluster.result == 'success') && 'success' || 'failure' }}
steps:
# print a single, clean status update to slack
- uses: act10ns/slack@v2
name: Slack notification
# skip if the secret is not accessible
if: env.SLACK_WEBHOOK_URL
with:
status: ${{ env.status }}
- name: Mark the job as succeeded
if: env.status == 'success'
run: exit 0
- name: Mark the job as failed
if: env.status != 'success'
run: exit 1