fix: updated the unit tests workflow to simplify job names and read test paths from a separate file (#29472)
This commit is contained in:
@@ -2,24 +2,25 @@ import sys
|
||||
import os
|
||||
import yaml
|
||||
import argparse
|
||||
import json
|
||||
|
||||
|
||||
def get_all_unit_test_modules():
|
||||
unit_tests_yml = f'{os.getcwd()}/.github/workflows/unit-tests.yml'
|
||||
with open(unit_tests_yml) as file:
|
||||
unit_test_workflow_yaml = yaml.safe_load(file)
|
||||
def get_all_unit_test_shards():
|
||||
unit_tests_json = f'{os.getcwd()}/.github/workflows/unit-test-shards.json'
|
||||
with open(unit_tests_json) as file:
|
||||
unit_test_workflow_shards = json.loads(file.read())
|
||||
|
||||
return unit_test_workflow_yaml['jobs']['run-tests']['strategy']['matrix']['test_module']
|
||||
return unit_test_workflow_shards
|
||||
|
||||
|
||||
def get_modules_except_cms():
|
||||
all_unit_test_modules = get_all_unit_test_modules()
|
||||
return [module for module in all_unit_test_modules if not module.startswith('cms')]
|
||||
all_unit_test_shards = get_all_unit_test_shards()
|
||||
return [paths for shard_name, paths in all_unit_test_shards.items() if not paths.startswith('cms')]
|
||||
|
||||
|
||||
def get_cms_modules():
|
||||
all_unit_test_modules = get_all_unit_test_modules()
|
||||
return [module for module in all_unit_test_modules if module.startswith('cms')]
|
||||
all_unit_test_shards = get_all_unit_test_shards()
|
||||
return [paths for shard_name, paths in all_unit_test_shards.items() if paths.startswith('cms')]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
27
scripts/unit_test_shards_parser.py
Normal file
27
scripts/unit_test_shards_parser.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
import json
|
||||
|
||||
|
||||
def get_test_paths_for_shard(shard_name):
|
||||
unit_tests_json = f'{os.getcwd()}/.github/workflows/unit-test-shards.json'
|
||||
with open(unit_tests_json) as file:
|
||||
unit_test_workflow_shards = json.loads(file.read())
|
||||
|
||||
if shard_name not in unit_test_workflow_shards:
|
||||
sys.stdout.write("Error, invalid shard name provided. please provide a valid shard name as specified in unit-test-shards.json")
|
||||
|
||||
return unit_test_workflow_shards.get(shard_name)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--shard-name", action="store", default="")
|
||||
argument = parser.parse_args()
|
||||
|
||||
if not argument.shard_name:
|
||||
sys.stdout.write("Error, no shard name provided. please provide a valid shard name as specified in unit-test-shards.json")
|
||||
|
||||
unit_test_paths = get_test_paths_for_shard(argument.shard_name)
|
||||
sys.stdout.write(unit_test_paths)
|
||||
Reference in New Issue
Block a user