generated from konveyor/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 12
449 lines (418 loc) · 17.3 KB
/
global-ci-bundle.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
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
name: Konveyor CI via Operator Bundle
on:
workflow_call:
inputs:
artifact:
description: |
The name of the artifact storing custom images to be used during the CI run. All
images stored in the artifact will be automatically loaded.
type: string
required: false
operator_bundle:
description: image uri for operator-bundle (ie. quay.io/<namespace>/<image-name>:<tag>). Must be pullable.
type: string
required: false
default: ""
oauth_proxy:
description: image uri for oauth_proxy (ie. quay.io/<namespace>/<image-name>:<tag>)
type: string
required: false
default: ""
tackle_hub:
description: image uri for tackle-hub (ie. quay.io/<namespace>/<image-name>:<tag>)
type: string
required: false
default: ""
tackle_postgres:
description: image uri for tackle-postgres (ie. quay.io/<namespace>/<image-name>:<tag>)
type: string
required: false
default: ""
keycloak_sso:
description: image uri for keycloak_sso image (ie. quay.io/<namespace>/<image-name>:<tag>)
type: string
required: false
default: ""
keycloak_init:
description: image uri for keycloak_init image (ie. quay.io/<namespace>/<image-name>:<tag>)
type: string
required: false
default: ""
tackle_ui:
description: image uri for tackle-ui (ie. quay.io/<namespace>/<image-name>:<tag>)
type: string
required: false
default: ""
addon_analyzer:
description: image uri for analyzer addon (ie. quay.io/<namespace>/<image-name>:<tag>)
type: string
required: false
default: ""
addon_discovery:
description: image uri for discovery addon (ie. quay.io/<namespace>/<image-name>:<tag>)
type: string
required: false
default: ""
namespace:
description: |
Namespace for the konveyor install.
type: string
required: false
default: ""
tackle_cr:
description: |
Full JSON encoded string representing the Tackle resource to be created.
type: string
required: false
default: '{"kind":"Tackle","apiVersion":"tackle.konveyor.io/v1alpha1","metadata":{"name":"tackle"},"spec":{"image_pull_policy":"IfNotPresent","analyzer_container_memory":0,"analyzer_container_cpu":0,"feature_auth_required":false}}'
run_api_tests:
description: |
A flag that determines whether the API tests should be run or not
type: boolean
required: false
default: true
run_ui_tests:
description: |
A flag that determines whether the UI tests should be run or not
type: boolean
required: false
# TODO: Swap to true once these are passing consistently
default: false
api_tests_ref:
description: |
The branch or PR of the go-konveyor-tests repository to clone.
For a pull request, the reference format would be "refs/pull/${PR_NUMBER}/merge".
For a branch, the reference format would just be the branch name.
This input can be set automatically on a pull request by adding a string of the format:
Go tests PR: 140
replacing "140" with the appropriate PR number. This will make it easier to coordinate changes
that require updating the global tests as well.
required: false
type: string
default: main
api_hub_tests_ref:
description: |
The branch or PR of the Hub API tests from tackle2-hub repository to clone.
For a pull request, the reference format would be "refs/pull/${PR_NUMBER}/merge".
For a branch, the reference format would just be the branch name.
required: false
type: string
default: main
ui_tests_ref:
description: |
The branch or PR of the tackle-ui-tests repository to clone.
For a pull request, the reference format would be "refs/pull/${PR_NUMBER}/merge".
For a branch, the reference format would just be the branch name.
This input can be set automatically on a pull request by adding a string of the format:
UI tests PR: 140
replacing "140" with the appropriate PR number. This will make it easier to coordinate changes
that require updating the global tests as well.
required: false
type: string
default: main
workflow_dispatch:
inputs:
operator_bundle:
description: image uri for operator-bundle (ie. quay.io/<namespace>/<image-name>:<tag>). Must be pullable.
type: string
required: false
default: "quay.io/konveyor/tackle2-operator-bundle:latest"
namespace:
description: |
Namespace for the konveyor install.
type: string
required: false
default: ""
tackle_cr:
description: |
Full JSON encoded string representing the Tackle resource to be created.
type: string
required: false
default: '{"kind":"Tackle","apiVersion":"tackle.konveyor.io/v1alpha1","metadata":{"name":"tackle"},"spec":{"image_pull_policy":"IfNotPresent","analyzer_container_memory":0,"analyzer_container_cpu":0,"feature_auth_required":false}}'
run_api_tests:
description: |
A flag that determines whether the API tests should be run or not
type: boolean
required: false
default: true
run_ui_tests:
description: |
A flag that determines whether the UI tests should be run or not
type: boolean
required: false
# TODO: Swap to true once these are passing consistently
default: false
api_tests_ref:
description: |
The branch or PR of the go-konveyor-tests repository to clone.
For a pull request, the reference format would be "refs/pull/${PR_NUMBER}/merge".
For a branch, the reference format would just be the branch name.
This input can be set automatically on a pull request by adding a string of the format:
Go tests PR: 140
replacing "140" with the appropriate PR number. This will make it easier to coordinate changes
that require updating the global tests as well.
required: false
type: string
default: main
ui_tests_ref:
description: |
The branch or PR of the tackle-ui-tests repository to clone.
For a pull request, the reference format would be "refs/pull/${PR_NUMBER}/merge".
For a branch, the reference format would just be the branch name.
This input can be set automatically on a pull request by adding a string of the format:
UI tests PR: 140
replacing "140" with the appropriate PR number. This will make it easier to coordinate changes
that require updating the global tests as well.
required: false
type: string
default: main
env:
operator_bundle: ttl.sh/konveyor-operator-bundle-${{ github.sha }}:2h
jobs:
check-images:
runs-on: ubuntu-latest
steps:
- name: Check operator image exists
if: ${{ inputs.operator_bundle != '' }}
env:
PROXY: ${{ inputs.oauth_proxy }}
HUB: ${{ inputs.tackle_hub }}
POSTGRES: ${{ inputs.tackle_postgres }}
SSO: ${{ inputs.keycloak_sso }}
INIT: ${{ inputs.keycloak_init }}
UI: ${{ inputs.tackle_ui }}
ANALYZER: ${{ inputs.addon_analyzer }}
DISCOVERY: ${{ inputs.addon_discovery }}
run: |
docker manifest inspect ${{ inputs.operator_bundle }}
# My cheap way to check if any other image is set
if [ -n "${PROXY}${HUB}${POSTGRES}${SSO}${INIT}${UI}${ANALYZER}${DISCOVERY}" ]; then
echo "::warning:: operator_bundle takes precendent over any other image specified!"
echo "::warning:: consider removing the image and setting it on the Tackle CR."
fi
- name: Check oauth_proxy image exists
if: ${{ inputs.oauth_proxy != '' }}
run: docker manifest inspect ${{ inputs.oauth_proxy }}
- name: Check tackle_hub image exists
if: ${{ inputs.tackle_hub != '' }}
run: docker manifest inspect ${{ inputs.tackle_hub }}
- name: Check tackle_postgres image exists
if: ${{ inputs.tackle_postgres != '' }}
run: docker manifest inspect ${{ inputs.tackle_postgres }}
- name: Check keycloak_sso image exists
if: ${{ inputs.keycloak_sso != '' }}
run: docker manifest inspect ${{ inputs.keycloak_sso }}
- name: Check keycloak_init image exists
if: ${{ inputs.keycloak_init != '' }}
run: docker manifest inspect ${{ inputs.keycloak_init }}
- name: Check tackle_ui image exists
if: ${{ inputs.tackle_ui != '' }}
run: docker manifest inspect ${{ inputs.tackle_ui }}
- name: Check addon_analyzer image exists
if: ${{ inputs.addon_analyzer != '' }}
run: docker manifest inspect ${{ inputs.addon_analyzer }}
- name: Check addon_discovery image exists
if: ${{ inputs.addon_discovery != '' }}
run: docker manifest inspect ${{ inputs.addon_discovery }}
e2e-api-integration-tests:
needs: check-images
runs-on: ubuntu-latest
if: ${{ inputs.run_api_tests }}
steps:
- name: Extract pull request number from inputs or PR description
env:
body: ${{ github.event.pull_request.body }}
run: |
PULL_REQUEST_NUMBER=$(echo ${body} | grep -oP '[A|a][P|p][I|i] [T|t]ests [P|p][R|r]:\s*\K\d+' || true)
[ -z "$PULL_REQUEST_NUMBER" ] \
&& GOLANG_TESTS_REF=${{ inputs.api_tests_ref }} \
|| GOLANG_TESTS_REF=refs/pull/$PULL_REQUEST_NUMBER/merge
echo "GOLANG_TESTS_REF=${GOLANG_TESTS_REF}" >>"$GITHUB_ENV"
echo "Using GOLANG_TESTS_REF \`${GOLANG_TESTS_REF}\`" >>"$GITHUB_STEP_SUMMARY"
- name: Checkout golang api tests repo
uses: actions/checkout@v4
with:
repository: konveyor/go-konveyor-tests
path: go-konveyor-tests
ref: "${{ env.GOLANG_TESTS_REF }}"
# TODO Should DRY this
- name: set up docker buildx
if: ${{ inputs.artifact != '' }}
uses: docker/setup-buildx-action@v2
- name: Download artifact
if: ${{ inputs.artifact != '' }}
uses: actions/download-artifact@v3
with:
name: ${{ inputs.artifact }}
path: /tmp/images
- name: Start minikube
uses: konveyor/tackle2-operator/.github/actions/start-minikube@main
with:
memory: 'max'
cpus: 'max'
- name: Load images
if: ${{ inputs.artifact != '' }}
run: |
export SHELL=/bin/bash
eval $(minikube -p minikube docker-env)
for image in $(ls /tmp/images/*.tar); do
docker load --input ${image}
; done
- name: Make bundle
if: ${{ inputs.operator_bundle == '' }}
uses: konveyor/tackle2-operator/.github/actions/make-bundle@main
with:
operator_bundle: ${{ env.operator_bundle }}
oauth_proxy: ${{ inputs.oauth_proxy }}
tackle_hub: ${{ inputs.tackle_hub }}
tackle_postgres: ${{ inputs.tackle_postgres }}
keycloak_sso: ${{ inputs.keycloak_sso }}
keycloak_init: ${{ inputs.keycloak_init }}
tackle_ui: ${{ inputs.tackle_ui }}
addon_analyzer: ${{ inputs.addon_analyzer }}
addon_discovery: ${{ inputs.addon_discovery }}
- name: Push bundle
if: ${{ inputs.operator_bundle == '' }}
run: docker push ${operator_bundle}
- name: Install konveyor
uses: konveyor/tackle2-operator/.github/actions/install-konveyor@main
with:
bundle_image: ${{ inputs.operator_bundle == '' && env.operator_bundle || inputs.operator_bundle }}
namespace: ${{ inputs.namespace }}
tackle_cr: ${{ inputs.tackle_cr }}
# end DRY
- uses: actions/setup-go@v4
with:
go-version: 1.18
- name: Install test dependencies
run: |
go install github.com/onsi/ginkgo/v2/ginkgo
working-directory: go-konveyor-tests
- name: Build and run golang API tests
env:
DEBUG: 1
run: |
export HUB_BASE_URL="http://$(minikube ip)/hub"
export HUB_TESTS_REF="${{ inputs.api_hub_tests_ref }}"
make test-tier0 test-tier1
working-directory: go-konveyor-tests
e2e-ui-integration-tests:
needs: check-images
if: ${{ inputs.run_ui_tests }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# TODO: Support cypress-split in main tackle-ui-test project
# split: [0, 1, 2, 3, 4, 5, 6, 7, 8]
tier: [tier1, tier2, tier3]
steps:
- name: Extract pull request number from inputs or PR description
env:
body: ${{ github.event.pull_request.body }}
run: |
PULL_REQUEST_NUMBER=$(echo ${body} | grep -oP '[U|u][I|i] [T|t]ests [P|p][R|r]: \K\d+' || true)
[ -z "$PULL_REQUEST_NUMBER" ] \
&& UI_TESTS_REF=${{ inputs.ui_tests_ref }} \
|| UI_TESTS_REF=refs/pull/$PULL_REQUEST_NUMBER/merge
echo "UI_TESTS_REF=${UI_TESTS_REF}" >>"$GITHUB_ENV"
echo "Using UI_TESTS_REF \`${UI_TESTS_REF}\`" >>"$GITHUB_STEP_SUMMARY"
- name: Checkout ui tests repo
uses: actions/checkout@v4
with:
repository: konveyor/tackle-ui-tests
path: tackle-ui-tests
ref: "${{ env.UI_TESTS_REF }}"
# TODO Should DRY this
- name: set up docker buildx
if: ${{ inputs.artifact != '' }}
uses: docker/setup-buildx-action@v2
- name: Download artifact
if: ${{ inputs.artifact != '' }}
uses: actions/download-artifact@v3
with:
name: ${{ inputs.artifact }}
path: /tmp/images
- name: Start minikube
uses: konveyor/tackle2-operator/.github/actions/start-minikube@main
with:
memory: 'max'
cpus: 'max'
- name: Load images
if: ${{ inputs.artifact != '' }}
run: |
export SHELL=/bin/bash
eval $(minikube -p minikube docker-env)
for image in $(ls /tmp/images/*.tar); do
docker load --input ${image}
; done
- name: Make bundle
if: ${{ inputs.operator_bundle == '' }}
uses: konveyor/tackle2-operator/.github/actions/make-bundle@main
with:
operator_bundle: ${{ env.operator_bundle }}
oauth_proxy: ${{ inputs.oauth_proxy }}
tackle_hub: ${{ inputs.tackle_hub }}
tackle_postgres: ${{ inputs.tackle_postgres }}
keycloak_sso: ${{ inputs.keycloak_sso }}
keycloak_init: ${{ inputs.keycloak_init }}
tackle_ui: ${{ inputs.tackle_ui }}
addon_analyzer: ${{ inputs.addon_analyzer }}
addon_discovery: ${{ inputs.addon_discovery }}
- name: Push bundle
if: ${{ inputs.operator_bundle == '' }}
run: docker push ${operator_bundle}
- name: Install konveyor
uses: konveyor/tackle2-operator/.github/actions/install-konveyor@main
with:
bundle_image: ${{ inputs.operator_bundle == '' && env.operator_bundle || inputs.operator_bundle }}
namespace: ${{ inputs.namespace }}
tackle_cr: ${{ inputs.tackle_cr }}
# end DRY
- name: Wait for Ingress and expose UI service
run: |
external_ip=""
echo $external_ip;
while [[ -z $external_ip ]]
do
echo "Waiting for end point..."
external_ip=$(kubectl get ingress tackle --template="{{range.status.loadBalancer.ingress}}{{.ip}}{{end}}" -n konveyor-tackle);[[ -z $external_ip ]] &&
echo $external_ip;
sleep 10;
done
echo "End point ready:" &&
echo $external_ip;
echo "UI_URL=https://$(minikube ip)" >>$GITHUB_ENV
- name: Run login tests
uses: cypress-io/github-action@v5
env:
CYPRESS_user: admin
CYPRESS_pass: password
CYPRESS_tackleUrl: "${{ env.UI_URL }}"
with:
working-directory: tackle-ui-tests
spec: "cypress/e2e/tests/login.test.ts"
- name: Run UI tests
uses: cypress-io/github-action@v5
env:
CYPRESS_INCLUDE_TAGS: "@${{ matrix.tier }}"
CYPRESS_user: "admin"
CYPRESS_pass: "Dog8code"
CYPRESS_tackleUrl: "${{ env.UI_URL }}"
CYPRESS_git_user: "fakeuser"
CYPRESS_git_password: "${{ secrets.GITHUB_TOKEN }}"
CYPRESS_git_key: "${{ secrets.GITHUB_TOKEN }}"
# TODO: Support cypress-split in main tackle-ui-test project
# CYPRESS_split: "${{ strategy.job-total }}"
# CYPRESS_splitIndex: "${{ strategy.job-index }}"
with:
working-directory: tackle-ui-tests
spec: "**/*.test.ts"
- name: Upload cypress report data as artifact
uses: actions/upload-artifact@v3
if: always()
with:
name: tackle-ui-test-reports-${{ matrix.tier }}
path: |
tackle-ui-tests/cypress/reports
tackle-ui-tests/cypress/screenshots