Commit 8db7237f authored by Mitar's avatar Mitar

Support for running in parallel.

parent dc99a41e
......@@ -35,8 +35,10 @@ validate_devel:
validate_all:
stage: test
parallel: 10
script:
- python3 ./run_validation.py --clean --all
- python3 ./run_validation.py --clean --all --parallel-index "$CI_NODE_INDEX" --parallel-total "$CI_NODE_TOTAL"
only:
refs:
......
......@@ -115,6 +115,14 @@ parser.add_argument(
'-c', '--clean', action='store_true',
help="remove existing Docker images before downloading new ones"
)
parser.add_argument(
'--parallel-index', metavar='I', type=int, action='store',
help="index of a job when running multiple jobs in parallel"
)
parser.add_argument(
'--parallel-total', metavar='N', type=int, action='store',
help="total number of jobs when running multiple jobs in parallel"
)
group = parser.add_mutually_exclusive_group()
group.add_argument(
'-a', '--all', action='store_true',
......@@ -125,6 +133,8 @@ arguments = parser.parse_args()
if (arguments.username and not arguments.password) or (not arguments.username and arguments.password):
parser.error("both --username and --password are required, or none")
if (arguments.parallel_index is not None and arguments.parallel_total is None) or (arguments.parallel_index is None and arguments.parallel_total is not None):
parser.error("both --parallel-index and --parallel-total are required, or none")
docker_client = docker.from_env()
......@@ -926,8 +936,14 @@ for file_path in files_changed:
traceback.print_exc()
sys.stdout.flush()
installations_to_validate = list(installations.items())
print(">>> There are {installations_to_validate} installations to validate.".format(installations_to_validate=len(installations_to_validate)), flush=True)
if arguments.parallel_total:
installations_to_validate = installations_to_validate[arguments.parallel_index::arguments.parallel_total]
print(">>> Running in parallel, validating only {installations_to_validate}.".format(installations_to_validate=len(installations_to_validate)), flush=True)
for (interface_version, installation), annotations in installations.items():
for (interface_version, installation), annotations in installations_to_validate:
# We validate in "validate_file" that "python_path" and "version" exist.
primitive_names = ['{interface_version}/{python_path}/{version}'.format(interface_version=interface_version, python_path=annotation['python_path'], version=annotation['version']) for annotation in annotations]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment