Skip to content

Commit 9df1589

Browse files
kei-nanGuyAv46
andauthored
Group Tests When Running In Github CI (#236)
* initial commit * Add message and depth parameters to all Query assertions (#237) * add depth and message for Query, and some related fixes * remove unused import * CI update (#238) * split nightly from generic CI * version bump actions * update poetry lock * remove usage of pkg_resources * bump poetry version * update toml and poetry lock again * fix whitespace * Rename nightly-build job to build in biweekly.yml * support version on python 3.7 * run CI on older and newer python version * add old versions back and lock poetry * fix run * another attempt * another attempt * another attempt * another attempt * another attempt * another attempt * another attempt * fix poetry lock * CI improvement * improve comment and concurrency group * add failure notification * Improve waitCluster (#239) * refactor to use cluster slots to ensure agreement * expose to Env * wait for both OK and same topo * minor improvements * print rltest args * code review comments * code review comments * fixes * small fix * remove redundant function call * Apply suggestions from code review Co-authored-by: GuyAv46 <47632673+GuyAv46@users.noreply.github.com> --------- Co-authored-by: GuyAv46 <47632673+GuyAv46@users.noreply.github.com>
1 parent 78fd6a0 commit 9df1589

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

RLTest/__main__.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from multiprocessing import Process, Queue, set_start_method
1616

1717
from RLTest.env import Env, TestAssertionFailure, Defaults
18-
from RLTest.utils import Colors, fix_modules, fix_modulesArgs
18+
from RLTest.utils import Colors, fix_modules, fix_modulesArgs, is_github_actions
1919
from RLTest.loader import TestLoader
2020
from RLTest.Enterprise import binaryrepo
2121
from RLTest import debuggers
@@ -553,6 +553,9 @@ def __init__(self):
553553
self.testsFailed = {}
554554
self.currEnv = None
555555
self.loader = TestLoader()
556+
557+
# For GitHub Actions grouping - track if we have an open group
558+
self.github_actions_group_open = False if is_github_actions() else None
556559
if self.args.test is not None:
557560
self.loader.load_spec(self.args.test)
558561
if self.args.tests_file is not None:
@@ -769,6 +772,18 @@ def _runTest(self, test, numberOfAssertionFailed=0, prefix='', before=lambda x=N
769772
numFailed += 1 # exception should be counted as failure
770773
return numFailed
771774

775+
def _openGitHubActionsTestsGroup(self):
776+
"""Open a GitHub Actions group wrapping all tests"""
777+
if self.github_actions_group_open is False:
778+
print('::group::📋 Test Execution')
779+
self.github_actions_group_open = True
780+
781+
def _closeGitHubActionsTestsGroup(self):
782+
"""Close the GitHub Actions tests group if one is open"""
783+
if self.github_actions_group_open is True:
784+
print('::endgroup::')
785+
self.github_actions_group_open = False
786+
772787
def printSkip(self, name):
773788
print('%s:\r\n\t%s' % (Colors.Cyan(name), Colors.Green('[SKIP]')))
774789

@@ -799,6 +814,7 @@ def killEnvWithSegFault(self):
799814
else:
800815
self.stopEnvWithSegFault()
801816

817+
# return number of tests done, and if all passed
802818
def run_single_test(self, test, on_timeout_func):
803819
done = 0
804820
with TestTimeLimit(self.args.test_timeout, on_timeout_func) as timeout_handler:
@@ -955,6 +971,8 @@ def on_timeout():
955971

956972
results = Queue()
957973
summary = Queue()
974+
# Open group for all tests at the start (parallel execution)
975+
self._openGitHubActionsTestsGroup()
958976
if self.parallelism == 1:
959977
run_jobs_main_thread(jobs)
960978
else :
@@ -996,6 +1014,10 @@ def on_timeout():
9961014

9971015
endTime = time.time()
9981016

1017+
# Close group after all tests complete (parallel execution)
1018+
self._closeGitHubActionsTestsGroup()
1019+
1020+
# Summary goes outside the group
9991021
print(Colors.Bold('\nTest Took: %d sec' % (endTime - startTime)))
10001022
print(Colors.Bold('Total Tests Run: %d, Total Tests Failed: %d, Total Tests Passed: %d' % (done, self.getFailedTestsCount(), done - self.getFailedTestsCount())))
10011023
if self.testsFailed:

RLTest/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
import redis
77
import itertools
88

9+
10+
def is_github_actions():
11+
"""Check if running in GitHub Actions environment"""
12+
return os.getenv('GITHUB_ACTIONS', '') != ''
13+
14+
915
def wait_for_conn(conn, proc, retries=20, command='PING', shouldBe=True):
1016
"""Wait until a given Redis connection is ready"""
1117
err1 = ''

0 commit comments

Comments
 (0)