22
22
# # run every night at midnight
23
23
# - cron: '0 0 * * *'
24
24
25
+ env :
26
+ COLUMNS : ' 120'
27
+
28
+ # Tell StackStorm that we are indeed in CI mode, using our CI-provider agnostic var.
29
+ ST2_CI : ' true'
30
+
31
+ # GitHub Actions uses the 'runner' user, so use that instead of stanley.
32
+ ST2TESTS_SYSTEM_USER : ' runner'
33
+
34
+ # This is the host:port provided by services.redis
35
+ ST2TESTS_REDIS_HOST : ' 127.0.0.1'
36
+ ST2TESTS_REDIS_PORT : ' 6379'
37
+
25
38
jobs :
26
39
pants-plugins-tests :
27
40
name : ' Pants Plugins Tests (pants runs: pytest) - Python ${{ matrix.python.version-short }}'
63
76
ports :
64
77
- 6379:6379/tcp
65
78
66
- env :
67
- COLUMNS : ' 120'
68
-
69
79
steps :
70
80
- name : Checkout repository
71
81
uses : actions/checkout@v4
@@ -99,11 +109,6 @@ jobs:
99
109
gha-cache-key : cache0-py${{ matrix.python.version }}
100
110
101
111
- name : Test pants-plugins
102
- env :
103
- # Github Actions uses the 'runner' user, so use that instead of stanley.
104
- ST2TESTS_SYSTEM_USER : ' runner'
105
- ST2TESTS_REDIS_HOST : ' 127.0.0.1'
106
- ST2TESTS_REDIS_PORT : ' 6379'
107
112
run : |
108
113
pants test pants-plugins/::
109
114
@@ -161,9 +166,6 @@ jobs:
161
166
ports :
162
167
- 6379:6379/tcp
163
168
164
- env :
165
- COLUMNS : ' 120'
166
-
167
169
steps :
168
170
- name : Checkout repository
169
171
uses : actions/checkout@v4
@@ -197,11 +199,6 @@ jobs:
197
199
gha-cache-key : cache0-py${{ matrix.python.version }}
198
200
199
201
- name : Unit Tests
200
- env :
201
- # Github Actions uses the 'runner' user, so use that instead of stanley.
202
- ST2TESTS_SYSTEM_USER : ' runner'
203
- ST2TESTS_REDIS_HOST : ' 127.0.0.1'
204
- ST2TESTS_REDIS_PORT : ' 6379'
205
202
run : >
206
203
pants
207
204
--python-bootstrap-search-path=[]
@@ -257,9 +254,6 @@ jobs:
257
254
ports :
258
255
- 6379:6379/tcp
259
256
260
- env :
261
- COLUMNS : ' 120'
262
-
263
257
steps :
264
258
- name : Checkout repository
265
259
uses : actions/checkout@v4
@@ -293,11 +287,6 @@ jobs:
293
287
gha-cache-key : cache0-py${{ matrix.python.version }}
294
288
295
289
- name : Pack Tests
296
- env :
297
- # Github Actions uses the 'runner' user, so use that instead of stanley.
298
- ST2TESTS_SYSTEM_USER : ' runner'
299
- ST2TESTS_REDIS_HOST : ' 127.0.0.1'
300
- ST2TESTS_REDIS_PORT : ' 6379'
301
290
run : >
302
291
pants
303
292
--python-bootstrap-search-path=[]
@@ -312,7 +301,243 @@ jobs:
312
301
path : .pants.d/pants.log
313
302
if : always() # We want the log even on failures.
314
303
315
- # integration-tests: TODO: run integration tests
304
+ integration-tests :
305
+ name : ' Integration Tests (pants runs: pytest) - Python ${{ matrix.python.version-short }}'
306
+ runs-on : ubuntu-20.04
307
+ strategy :
308
+ fail-fast : false
309
+ matrix :
310
+ # NOTE: We need to use full Python version as part of Python deps cache key otherwise
311
+ # setup virtualenv step will fail.
312
+ python :
313
+ - {version-short: '3.8', version: '3.8.10'}
314
+ - {version-short: '3.9', version: '3.9.14'}
315
+
316
+ services :
317
+ mongo :
318
+ image : mongo:7.0
319
+ ports :
320
+ - 27017:27017
321
+
322
+ # In GHA, these services are started first before the code is checked out.
323
+ # We use bitnami images to facilitate reconfiguring RabbitMQ during integration tests.
324
+ # We rely on custom config and SSL certs that are in the repo.
325
+ # Many images require config in env vars (which we can't change during the test job)
326
+ # or they require config in entrypoint args (which we can't override for GHA services)
327
+ # bitnami builds ways to get config files from mounted volumes.
328
+ rabbitmq :
329
+ image : bitnami/rabbitmq:3.8
330
+ volumes :
331
+ - /home/runner/rabbitmq_conf:/bitnami/conf # RABBITMQ_MOUNTED_CONF_DIR
332
+ env :
333
+ # tell bitnami/rabbitmq to enable this by default
334
+ RABBITMQ_PLUGINS : rabbitmq_management
335
+ RABBITMQ_USERNAME : guest
336
+ RABBITMQ_PASSWORD : guest
337
+ RABBITMQ_LOGS : ' -'
338
+ # bitnami's default relative limit was too high
339
+ RABBITMQ_DISK_FREE_ABSOLUTE_LIMIT : 50MB
340
+
341
+ # These are strictly docker options, not entrypoint args (GHA restriction)
342
+ options : >-
343
+ --name rabbitmq
344
+ ports :
345
+ # These 6 ports are exposed by bitnami/rabbitmq (see https://www.rabbitmq.com/networking.html#ports)
346
+ # host_port:container_port/protocol
347
+ - 5671:5671/tcp # AMQP SSL port
348
+ - 5672:5672/tcp # AMQP standard port
349
+ - 15672:15672/tcp # Management: HTTP, CLI
350
+ # - 15671:15671/tcp # Management: SSL port
351
+ # - 25672:25672/tcp # inter-node or CLI
352
+ # - 4369:4369/tcp # epmd
353
+
354
+ redis :
355
+ # Docker Hub image
356
+ image : redis
357
+ # Set health checks to wait until redis has started
358
+ options : >-
359
+ --name "redis"
360
+ --health-cmd "redis-cli ping"
361
+ --health-interval 10s
362
+ --health-timeout 5s
363
+ --health-retries 5
364
+ ports :
365
+ - 6379:6379/tcp
366
+
367
+ steps :
368
+ - name : Checkout repository
369
+ uses : actions/checkout@v4
370
+ with :
371
+ # a test uses a submodule, and pants needs access to it to calculate deps.
372
+ submodules : ' recursive'
373
+ # sadly, the submodule will only have fetch-depth=1, which is what we want
374
+ # for st2.git, but not for the submodules. We still want actions/checkout
375
+ # to do the initial checkout, however, so that it adds auth for fetching
376
+ # in the submodule.
377
+
378
+ - name : Fetch repository submodules
379
+ run : |
380
+ git submodule status
381
+ git submodule foreach 'git fetch --all --tags'
382
+ git submodule foreach 'git tag'
383
+
384
+ - name : ' Set up Python (${{ matrix.python.version }})'
385
+ id : python
386
+ uses : actions/setup-python@v5
387
+ with :
388
+ python-version : ' ${{ matrix.python.version }}'
389
+
390
+ - name : Cache and Install APT Dependencies
391
+ uses : ./.github/actions/apt-packages
392
+
393
+ - name : Initialize Pants and its GHA caches
394
+ uses : ./.github/actions/init-pants
395
+ with :
396
+ # To ignore a bad cache, bump the cache* integer.
397
+ gha-cache-key : cache0-py${{ matrix.python.version }}
398
+
399
+ # This is only required for st2common/tests/integration/test_rabbitmq_ssl_listener.py
400
+ - name : Reconfigure RabbitMQ
401
+ # bitnami image allows (see bitnami/rabbitmq readme):
402
+ # Here we're copying a rabbitmq.config file which won't do anything.
403
+ # We need to switch to custom.conf or advanced.config.
404
+ timeout-minutes : 2 # may die if rabbitmq fails to start
405
+ run : |
406
+ ./scripts/github/configure-rabbitmq.sh
407
+
408
+ - name : Integration Tests
409
+ run : >
410
+ pants
411
+ --python-bootstrap-search-path=[]
412
+ --python-bootstrap-search-path=${{ steps.python.outputs.python-path }}
413
+ --tag=integration
414
+ --tag=-st2cluster
415
+ test '::'
416
+
417
+ - name : Upload pants log
418
+ uses : actions/upload-artifact@v4
419
+ with :
420
+ name : pants-log-py${{ matrix.python.version }}-integration-tests
421
+ path : .pants.d/pants.log
422
+ if : always() # We want the log even on failures.
423
+
424
+ integration-st2cluster-tests :
425
+ name : ' Integration Tests (Full Cluster)- Python ${{ matrix.python.version-short }}'
426
+ runs-on : ubuntu-20.04
427
+ strategy :
428
+ fail-fast : false
429
+ matrix :
430
+ # NOTE: We need to use full Python version as part of Python deps cache key otherwise
431
+ # setup virtualenv step will fail.
432
+ python :
433
+ - {version-short: '3.8', version: '3.8.10'}
434
+ - {version-short: '3.9', version: '3.9.14'}
435
+
436
+ services :
437
+ mongo :
438
+ image : mongo:7.0
439
+ ports :
440
+ - 27017:27017
441
+
442
+ rabbitmq :
443
+ image : rabbitmq:3.8-management
444
+ options : >-
445
+ --name rabbitmq
446
+ ports :
447
+ - 5671:5671/tcp # AMQP SSL port
448
+ - 5672:5672/tcp # AMQP standard port
449
+ - 15672:15672/tcp # Management: HTTP, CLI
450
+
451
+ redis :
452
+ # Docker Hub image
453
+ image : redis
454
+ # Set health checks to wait until redis has started
455
+ options : >-
456
+ --name "redis"
457
+ --health-cmd "redis-cli ping"
458
+ --health-interval 10s
459
+ --health-timeout 5s
460
+ --health-retries 5
461
+ ports :
462
+ - 6379:6379/tcp
463
+
464
+ steps :
465
+ - name : Checkout repository
466
+ uses : actions/checkout@v4
467
+ with :
468
+ # a test uses a submodule, and pants needs access to it to calculate deps.
469
+ submodules : ' recursive'
470
+ # sadly, the submodule will only have fetch-depth=1, which is what we want
471
+ # for st2.git, but not for the submodules. We still want actions/checkout
472
+ # to do the initial checkout, however, so that it adds auth for fetching
473
+ # in the submodule.
474
+
475
+ - name : Fetch repository submodules
476
+ run : |
477
+ git submodule status
478
+ git submodule foreach 'git fetch --all --tags'
479
+ git submodule foreach 'git tag'
480
+
481
+ - name : ' Set up Python (${{ matrix.python.version }})'
482
+ id : python
483
+ uses : actions/setup-python@v5
484
+ with :
485
+ python-version : ' ${{ matrix.python.version }}'
486
+
487
+ - name : Cache and Install APT Dependencies
488
+ uses : ./.github/actions/apt-packages
489
+
490
+ - name : Initialize Pants and its GHA caches
491
+ uses : ./.github/actions/init-pants
492
+ with :
493
+ # To ignore a bad cache, bump the cache* integer.
494
+ gha-cache-key : cache0-py${{ matrix.python.version }}
495
+
496
+ - name : Export virtualenv to run Dev ST2 Cluster
497
+ run : >
498
+ pants
499
+ --python-bootstrap-search-path=[]
500
+ --python-bootstrap-search-path=${{ steps.python.outputs.python-path }}
501
+ export
502
+ --resolve=st2
503
+
504
+ - name : Launch Dev ST2 Cluster
505
+ env :
506
+ VIRTUALENV_DIR : ./dist/export/python/virtualenvs/st2/${{ steps.python.outputs.python-version }}
507
+ run : |
508
+ sudo -E ./scripts/github/prepare-integration.sh
509
+
510
+ - name : Integration Tests
511
+ env :
512
+ ST2_CI_RUN_ORQUESTA_PAUSE_RESUME_TESTS : ' true'
513
+ run : >
514
+ pants
515
+ --python-bootstrap-search-path=[]
516
+ --python-bootstrap-search-path=${{ steps.python.outputs.python-path }}
517
+ --tag=integration
518
+ --tag=st2cluster
519
+ test '::'
520
+
521
+ - name : Compress Service Logs Before upload
522
+ if : ${{ failure() }}
523
+ run : |
524
+ ./tools/launchdev.sh stop # stop st2 before collecting logs
525
+ tar cvzpf logs.tar.gz logs/*
526
+
527
+ - name : Upload StackStorm services Logs
528
+ if : ${{ failure() }}
529
+ uses : actions/upload-artifact@v4
530
+ with :
531
+ name : logs-py${{ matrix.python-version }}-st2cluster-integration-tests
532
+ path : logs.tar.gz
533
+ retention-days : 7
534
+
535
+ - name : Upload pants log
536
+ uses : actions/upload-artifact@v4
537
+ with :
538
+ name : pants-log-py${{ matrix.python.version }}-st2cluster-integration-tests
539
+ path : .pants.d/pants.log
540
+ if : always() # We want the log even on failures.
316
541
317
542
set_merge_ok :
318
543
name : Set Merge OK (Tests)
@@ -321,7 +546,8 @@ jobs:
321
546
- pants-plugins-tests
322
547
- unit-tests
323
548
- pack-tests
324
- # - integration-tests
549
+ - integration-tests
550
+ - integration-st2cluster-tests
325
551
outputs :
326
552
merge_ok : ${{ steps.set_merge_ok.outputs.merge_ok }}
327
553
runs-on : ubuntu-latest
0 commit comments