-
Notifications
You must be signed in to change notification settings - Fork 174
524 lines (448 loc) · 17.7 KB
/
unit-tests.yaml
File metadata and controls
524 lines (448 loc) · 17.7 KB
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
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
name: Unit Tests
on:
push:
tags:
- '*'
branches:
- master
- release-*
pull_request:
types:
- opened
- reopened
- synchronize
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
go:
strategy:
fail-fast: false
matrix:
gotags: [ 'GOTAGS=""', 'GOTAGS=release' ]
runs-on: ubuntu-latest
outputs:
new-jiras: ${{ steps.junit2jira.outputs.new-jiras }}
# Stable version ldflags for test caching: Go's test cache keys include
# link ActionID which includes -X ldflags. Fixed BUILD_TAG/SHORTCOMMIT
# prevent per-commit cache misses.
env:
BUILD_TAG: 0.0.0
SHORTCOMMIT: "0000000"
container:
image: quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3@sha256:39fd328dcc903b7d8a2f3eb6d9e5ddbf79569227a5667296b4b927f74c11b32a # ratchet:quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3
volumes:
- /usr:/mnt/usr
- /opt:/mnt/opt
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
with:
fetch-depth: 0
- uses: ./.github/actions/job-preamble
with:
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
free-disk-space: 30
- name: Cache Go dependencies
uses: ./.github/actions/cache-go-dependencies
with:
key-suffix: ${{ matrix.gotags }}
- name: Go Unit Tests
run: ${{ matrix.gotags }} make go-unit-tests
- uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # ratchet:codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: go-unit-tests
- name: Generate junit report
if: always()
run: make generate-junit-reports
- name: Publish Test Report
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # ratchet:test-summary/action@v2
if: always()
with:
paths: 'junit-reports/report.xml'
- name: Go Integration Unit Tests
run: ${{ matrix.gotags }} make integration-unit-tests
- name: Go Operator Integration Tests
run: ${{ matrix.gotags }} make -C operator/ test-integration
- name: Go Operator Helm Tests
run: ${{ matrix.gotags }} make -C operator/ test-helm
- name: Generate junit report
if: always()
run: make generate-junit-reports
- name: Publish Test Report
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # ratchet:test-summary/action@v2
if: always()
with:
paths: 'junit-reports/report.xml'
- name: Report test failures to Jira
if: (!cancelled())
id: junit2jira
uses: ./.github/actions/junit2jira
with:
create-jiras: ${{ github.event_name == 'push' }}
jira-user: ${{ secrets.JIRA_USER }}
jira-token: ${{ secrets.JIRA_TOKEN }}
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
directory: 'junit-reports'
go-postgres:
strategy:
fail-fast: false
matrix:
gotags: [ 'GOTAGS=""', 'GOTAGS=release' ]
pg: [ '15' ]
runs-on: ubuntu-latest
outputs:
new-jiras: ${{ steps.junit2jira.outputs.new-jiras }}
# Stable version ldflags for test caching: Go's test cache keys include
# link ActionID which includes -X ldflags. Fixed BUILD_TAG/SHORTCOMMIT
# prevent per-commit cache misses.
env:
BUILD_TAG: 0.0.0
SHORTCOMMIT: "0000000"
container:
image: quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3@sha256:39fd328dcc903b7d8a2f3eb6d9e5ddbf79569227a5667296b4b927f74c11b32a # ratchet:quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3
volumes:
- /usr:/mnt/usr
- /opt:/mnt/opt
steps:
- name: Set Postgres version
run: |
echo "/usr/pgsql-${{ matrix.pg }}/bin" >> "${GITHUB_PATH}"
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
with:
fetch-depth: 0
- uses: ./.github/actions/job-preamble
with:
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
- name: Run Postgres
run: |
su postgres -c 'initdb -D /tmp/data'
su postgres -c 'pg_ctl -D /tmp/data start'
- name: Cache Go dependencies
uses: ./.github/actions/cache-go-dependencies
with:
key-suffix: ${{ matrix.gotags }}
- name: Is Postgres ready
run: pg_isready -h 127.0.0.1
- name: Go Unit Tests
run: ${{ matrix.gotags }} make go-postgres-unit-tests
- uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # ratchet:codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: go-unit-tests
- name: Generate junit report
if: always()
run: make generate-junit-reports
- name: Publish Test Report
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # ratchet:test-summary/action@v2
if: always()
with:
paths: 'junit-reports/report.xml'
- name: Report junit failures in jira
if: (!cancelled())
id: junit2jira
uses: ./.github/actions/junit2jira
with:
create-jiras: ${{ github.event_name == 'push' }}
jira-user: ${{ secrets.JIRA_USER }}
jira-token: ${{ secrets.JIRA_TOKEN }}
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
directory: 'junit-reports'
go-bench:
runs-on: ubuntu-latest
container:
image: quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3@sha256:39fd328dcc903b7d8a2f3eb6d9e5ddbf79569227a5667296b4b927f74c11b32a # ratchet:quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3
volumes:
- /usr:/mnt/usr
- /opt:/mnt/opt
steps:
- name: Set Postgres version
run: |
echo "/usr/pgsql-15/bin" >> "${GITHUB_PATH}"
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
with:
fetch-depth: 0
- uses: ./.github/actions/job-preamble
with:
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
- name: Run Postgres
run: |
su postgres -c 'initdb -D /tmp/data'
su postgres -c 'pg_ctl -D /tmp/data start'
- name: Cache Go dependencies
uses: ./.github/actions/cache-go-dependencies
- name: Is Postgres ready
run: pg_isready -h 127.0.0.1
- name: Go Bench Tests
run: make go-postgres-bench-tests
- name: Generate junit report
if: always()
run: make generate-junit-reports
- name: Publish Test Report
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # ratchet:test-summary/action@v2
if: always()
with:
paths: 'junit-reports/report.xml'
# Do not create junit report for bench tests:
# https://github.com/jstemmer/go-junit-report/issues/174
ui:
runs-on: ubuntu-latest
outputs:
new-jiras: ${{ steps.junit2jira.outputs.new-jiras }}
container:
image: quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3@sha256:39fd328dcc903b7d8a2f3eb6d9e5ddbf79569227a5667296b4b927f74c11b32a # ratchet:quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
- uses: ./.github/actions/job-preamble
with:
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
- name: Cache UI dependencies
uses: ./.github/actions/cache-ui-dependencies
- name: UI Unit Tests
run: make ui-test
- name: Publish Test Report
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # ratchet:test-summary/action@v2
if: always()
with:
paths: 'ui/apps/platform/test-results/reports/*.xml'
- name: Report junit failures in jira
if: (!cancelled())
id: junit2jira
uses: ./.github/actions/junit2jira
with:
create-jiras: ${{ github.event_name == 'push' }}
jira-user: ${{ secrets.JIRA_USER }}
jira-token: ${{ secrets.JIRA_TOKEN }}
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
directory: 'ui/apps/platform/test-results/reports'
ui-component:
runs-on: ubuntu-latest
outputs:
new-jiras: ${{ steps.junit2jira.outputs.new-jiras }}
container:
image: quay.io/stackrox-io/apollo-ci:stackrox-ui-test-0.5.3@sha256:705f968134de21fb7e00d591177c3f331118e97acd17e474ecee6e0f39972326 # ratchet:quay.io/stackrox-io/apollo-ci:stackrox-ui-test-0.5.3
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
- uses: ./.github/actions/job-preamble
with:
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
- name: Cache UI dependencies
uses: ./.github/actions/cache-ui-dependencies
- name: UI Component Tests
run: make ui-component-tests
- name: Upload Cypress test result artifacts
uses: ./.github/actions/upload-artifact-with-retry
if: always()
with:
name: Cypress test results
path: ui/apps/platform/cypress/test-results/
- name: Publish Test Report
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # ratchet:test-summary/action@v2
if: always()
with:
paths: 'ui/apps/platform/cypress/test-results/reports/**/*.xml'
- name: Report junit failures in jira
if: (!cancelled())
id: junit2jira
uses: ./.github/actions/junit2jira
with:
create-jiras: ${{ github.event_name == 'push' }}
jira-user: ${{ secrets.JIRA_USER }}
jira-token: ${{ secrets.JIRA_TOKEN }}
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
directory: 'ui/apps/platform/cypress/test-results/reports'
local-roxctl-tests:
runs-on: ubuntu-latest
outputs:
new-jiras: ${{ steps.junit2jira.outputs.new-jiras }}
container:
image: quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3@sha256:39fd328dcc903b7d8a2f3eb6d9e5ddbf79569227a5667296b4b927f74c11b32a # ratchet:quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3
volumes:
- /usr:/mnt/usr
- /opt:/mnt/opt
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/actions/job-preamble
with:
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
- name: Cache Go dependencies
uses: ./.github/actions/cache-go-dependencies
- uses: ./.github/actions/handle-tagged-build
- name: Local roxctl tests
run: ./scripts/ci/jobs/local-roxctl-tests.sh
- name: Publish Test Report
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # ratchet:test-summary/action@v2
if: always()
with:
paths: 'roxctl-test-output/*.xml'
- name: Report junit failures in jira
if: (!cancelled())
id: junit2jira
uses: ./.github/actions/junit2jira
with:
create-jiras: ${{ github.event_name == 'push' }}
jira-user: ${{ secrets.JIRA_USER }}
jira-token: ${{ secrets.JIRA_TOKEN }}
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
directory: 'roxctl-test-output'
shell-unit-tests:
runs-on: ubuntu-latest
outputs:
new-jiras: ${{ steps.junit2jira.outputs.new-jiras }}
container:
image: quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3@sha256:39fd328dcc903b7d8a2f3eb6d9e5ddbf79569227a5667296b4b927f74c11b32a # ratchet:quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/actions/job-preamble
with:
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
- name: Shell Unit Tests
run: make shell-unit-tests
- name: Publish Test Report
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # ratchet:test-summary/action@v2
if: always()
with:
paths: 'shell-test-output/*.xml'
- name: Report junit failures in jira
if: (!cancelled())
id: junit2jira
uses: ./.github/actions/junit2jira
with:
create-jiras: ${{ github.event_name == 'push' }}
jira-user: ${{ secrets.JIRA_USER }}
jira-token: ${{ secrets.JIRA_TOKEN }}
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
directory: 'shell-test-output'
openshift-ci-unit-tests:
runs-on: ubuntu-latest
container:
image: quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3@sha256:39fd328dcc903b7d8a2f3eb6d9e5ddbf79569227a5667296b4b927f74c11b32a # ratchet:quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/actions/job-preamble
with:
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
- name: OpenShift CI Wrapper Unit Tests
run: make -C .openshift-ci test
sensor-integration-tests:
env:
KUBECONFIG: "/tmp/kubeconfig"
# Stable version ldflags for test caching (see go job comment).
BUILD_TAG: 0.0.0
SHORTCOMMIT: "0000000"
runs-on: ubuntu-latest
outputs:
new-jiras: ${{ steps.junit2jira.outputs.new-jiras }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # ratchet:actions/setup-go@v6
with:
go-version-file: go.mod
cache: false
- uses: ./.github/actions/job-preamble
with:
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
- name: Cache Go dependencies
uses: ./.github/actions/cache-go-dependencies
- name: Login to Quay.io
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # ratchet:docker/login-action@v4
with:
registry: quay.io
username: ${{ secrets.QUAY_RHACS_ENG_RO_USERNAME }}
password: ${{ secrets.QUAY_RHACS_ENG_RO_PASSWORD }}
- name: Create k8s Kind Cluster
uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc # ratchet:helm/kind-action@v1
with:
kubeconfig: "${{ env.KUBECONFIG }}"
- name: Load test images into Kind
run: |
source scripts/lib.sh
# Read images from prefetch list (single source of truth)
while IFS= read -r image; do
# Skip empty lines and comments
[[ -z "$image" || "$image" =~ ^# ]] && continue
echo "Loading $image into Kind..."
# Pull directly inside Kind node to avoid docker save/import issues with multi-arch
# This bypasses the problematic "kind load docker-image" which uses --all-platforms
# GitHub Actions runners are linux/amd64, so we only need that platform
# Use --user flag to pass quay.io credentials to ctr
retry 5 true docker exec chart-testing-control-plane ctr -n k8s.io images pull \
--user "${{ secrets.QUAY_RHACS_ENG_RO_USERNAME }}:${{ secrets.QUAY_RHACS_ENG_RO_PASSWORD }}" \
--platform linux/amd64 \
"$image"
done < sensor/tests/images-to-prefetch.txt
- name: Run sensor integration tests
run: make sensor-integration-test
- name: Generate junit report
if: always()
run: make generate-junit-reports
- name: Publish Test Report
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # ratchet:test-summary/action@v2
if: always()
with:
paths: 'junit-reports/report.xml'
- name: Report junit failures in jira
if: (!cancelled())
id: junit2jira
uses: ./.github/actions/junit2jira
with:
create-jiras: ${{ github.event_name == 'push' }}
jira-user: ${{ secrets.JIRA_USER }}
jira-token: ${{ secrets.JIRA_TOKEN }}
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
directory: 'junit-reports'
slack-on-unit-tests-failure:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_CI_INTEGRATION_TESTING_WEBHOOK: ${{ secrets.SLACK_CI_INTEGRATION_TESTING_WEBHOOK }}
TEST_FAILURES_NOTIFY_WEBHOOK: ${{ secrets.TEST_FAILURES_NOTIFY_WEBHOOK }}
if: |
failure() && (
github.event_name == 'push' ||
contains(github.event.pull_request.labels.*.name, 'ci-test-github-action-slack-messages')
)
name: Post failure message to Slack
runs-on: ubuntu-latest
needs:
- go
- go-bench
- go-postgres
- local-roxctl-tests
- openshift-ci-unit-tests
- sensor-integration-tests
- shell-unit-tests
- ui
- ui-component
permissions:
actions: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
- name: Slack message
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
mention_author: ${{ needs.go.outputs.new-jiras || needs.go-postgres.outputs.new-jiras || needs.local-roxctl-tests.outputs.new-jiras || needs.ui.outputs.new-jiras || needs.go.outputs.new-jiras || needs.shell-unit-tests.outputs.new-jiras || needs.sensor-integration-tests.outputs.new-jiras }}
run: |
source scripts/ci/lib.sh
slack_workflow_failure