Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for coverage tool and new circle config #4076

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 21 additions & 6 deletions tools/coverage-tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ def matrix_expand(loc_dict_tuple_list):
product = itertools.product(*groups)
product = list(product)
for subs in product:
data = copy.deepcopy(containing_dict)
toxenv = data["toxenv"]
for k, v in subs:
data = copy.deepcopy(containing_dict)
toxenv = data["toxenv"]
replace = f"<<matrix.{k}>>"
assert replace in toxenv, f"Cant find {replace} in {toxenv}"
toxenv = toxenv.replace(replace, v)
data["toxenv"] = toxenv
ret.append((location, data))
toxenv = toxenv.replace(replace, str(v))
data["toxenv"] = toxenv
ret.append((location, data))
else:
ret.append((location, containing_dict))
return ret
Expand Down Expand Up @@ -121,6 +121,20 @@ def parallelism_expand(cov_list, par_dict):
return ret


def augment_circle_config(data: dict):
"""pytest jobs have implicit toxenv."""
data = copy.deepcopy(data)
jobs = data.get("workflows", {}).get("main", {}).get("jobs")
special_job_name = "pytest"
for job in jobs:
special_job = job.get(special_job_name)
if special_job:
special_job[
"toxenv"
] = "py<<matrix.python_version_major>><<matrix.python_version_minor>>,covercircle"
return data


def coverage_tasks(args: argparse.Namespace):

ci_fname = args.circleci_yaml
Expand All @@ -130,7 +144,8 @@ def coverage_tasks(args: argparse.Namespace):

parallelism = find_list_of_key_locations_and_dicts(data, "parallelism")
parallelism_defaults = filter(find_parallelism_defaults, parallelism)
toxenv = find_list_of_key_locations_and_dicts(data, "toxenv")
augmented_data = augment_circle_config(data)
toxenv = find_list_of_key_locations_and_dicts(augmented_data, "toxenv")
toxenv_cov = filter(lambda x: "covercircle" in x[1]["toxenv"], toxenv)
toxenv_cov_matrix = matrix_expand(toxenv_cov)
par_default_dict = create_parallelism_defaults_dict(parallelism_defaults)
Expand Down