Refactor to use GHA test matrix

This commit is contained in:
Laurent Indermuehle 2023-03-23 15:20:28 +01:00
parent 17a87c9fdf
commit 96efd41acc
No known key found for this signature in database
GPG key ID: 93FA944C9F34DD09
2 changed files with 168 additions and 284 deletions

View file

@ -28,47 +28,66 @@ def extract_matrix(workflow_yaml):
return matrix
# def is_exclude(exclude_list, test_suite):
# test_is_excluded = False
# for excl in exclude_list:
# match = 0
def is_exclude(exclude_list, test_suite):
test_is_excluded = False
for excl in exclude_list:
match = 0
# if 'ansible' in excl:
# if excl.get('ansible') == test_suite[0]:
# match += 1
if 'ansible' in excl:
if excl.get('ansible') == test_suite.get('ansible'):
match += 1
# if 'db_engine_version' in excl:
# if excl.get('db_engine_version') == test_suite[1]:
# match += 1
if 'db_engine_name' in excl:
if excl.get('db_engine_name') == test_suite.get('db_engine_name'):
match += 1
# if 'python' in excl:
# if excl.get('python') == test_suite[2]:
# match += 1
if 'db_engine_version' in excl:
if excl.get('db_engine_version') == test_suite.get('db_engine_version'):
match += 1
# if 'connector' in excl:
# if excl.get('connector') == test_suite[3]:
# match += 1
if 'python' in excl:
if excl.get('python') == test_suite.get('python'):
match += 1
# if match > 1:
# test_is_excluded = True
if 'connector_name' in excl:
if excl.get('connector_name') == test_suite.get('connector_name'):
match += 1
# return test_is_excluded
if 'connector_version' in excl:
if excl.get('connector_version') == test_suite.get('connector_version'):
match += 1
if match > 1:
test_is_excluded = True
return test_is_excluded
return test_is_excluded
def main():
workflow_yaml = read_github_workflow_file()
tests_matrix_yaml = extract_matrix(workflow_yaml)
# matrix = []
# exclude_list = tests_matrix_yaml.get('exclude')
# for ansible in tests_matrix_yaml.get('ansible'):
# for db_engine in tests_matrix_yaml.get('db_engine_version'):
# for python in tests_matrix_yaml.get('python'):
# for connector in tests_matrix_yaml.get('connector'):
# if not is_exclude(exclude_list, (ansible, db_engine, python, connector)):
# matrix.append((ansible, db_engine, python, connector))
matrix = []
exclude_list = tests_matrix_yaml.get('exclude')
for ansible in tests_matrix_yaml.get('ansible'):
for db_engine_name in tests_matrix_yaml.get('db_engine_name'):
for db_engine_version in tests_matrix_yaml.get('db_engine_version'):
for python in tests_matrix_yaml.get('python'):
for connector_name in tests_matrix_yaml.get('connector_name'):
for connector_version in tests_matrix_yaml.get('connector_version'):
test_suite = {
'ansible': ansible,
'db_engine_name': db_engine_name,
'db_engine_version': db_engine_version,
'python': python,
'connector_name': connector_name,
'connector_version': connector_version
}
if not is_exclude(exclude_list, test_suite):
matrix.append(test_suite)
for tests in tests_matrix_yaml.get('include'):
for tests in matrix:
a = tests.get('ansible')
dn = tests.get('db_engine_name')
dv = tests.get('db_engine_version')