Skip to content

Commit

Permalink
Skip non-bool variants for now as we don't parse them yet
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardkaindl committed Oct 17, 2024
1 parent e0699d3 commit 83a1345
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
26 changes: 22 additions & 4 deletions build_pr_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,16 @@ def check_for_recipe(line, changed_files, changed_recipe, recipes):
changed_recipe[0] = ""


def add_bool_variant(variant, new_variants, line):
"""Check the variant default and add boolean variants to the list of new variants"""

default = re.search(r"default=(\w+)", line)
# Check the line for "default=False" or "default=True" and if it is a boolean variant:
if default and default.group(1) in ("True", "False"):
# add the variant to the list of new variants:
new_variants.append(variant.group(1))


# Of course, this diff parser is not perfect, and should be a class, but it's a start.
def get_specs_to_check(args) -> List[str]:
"""Check if the current branch is up-to-date with the remote branch.
Expand All @@ -580,6 +590,7 @@ def get_specs_to_check(args) -> List[str]:
next_line_is_version = False
next_line_is_variant = False
version_match = None
multiline_variant = None

# The most reliable way to get the PR diff is to use the GitHub CLI:
err, stdout, stderr = run(["gh", "pr", "diff"])
Expand All @@ -594,6 +605,7 @@ def get_specs_to_check(args) -> List[str]:
next_line_is_variant = False
default_versions = new_versions
version_match = None
multiline_variant = None
continue
if line[0] != "+":
continue
Expand All @@ -602,6 +614,12 @@ def get_specs_to_check(args) -> List[str]:
if not recipe[0]:
continue

if multiline_variant:
add_bool_variant(variant, new_variants, line)
if " )" in line:
multiline_variant = None
continue

# Get the list of new and changed versions from the PR diff:
version_start = re.search(r" version\($", line) # version(
if version_start:
Expand Down Expand Up @@ -636,12 +654,12 @@ def get_specs_to_check(args) -> List[str]:
continue
variant = re.search(r' variant\("([^"]+)", ', line) # variant("name",
if next_line_is_variant or variant:
next_line_is_variant = False
variant = variant or re.search(r'"([^"]+)"', line)
if variant:
variant_str = variant.group(1)
if variant_str not in ["cxxstd", "cuda"]:
new_variants.append(variant_str)
if next_line_is_variant:
multiline_variant = variant
next_line_is_variant = False
add_bool_variant(variant, new_variants, line)
continue

add_recipe_variant_version(specs, recipe, new_variants, new_versions, deprecated)
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ disable = [
]
# Maximum number of branch for function / method body.
# defaults to: max-branches=12
max-branches = 16
max-branches = 18

# Maximum number of locals for function / method body.
# defaults to: max-locals=15
max-locals = 22

# Maximum number of statements in function / method body.
# defaults to: max-statements=50
max-statements = 68
max-statements = 74

# Maximum number of lines in a module.
# defaults to: max-module-lines=1000
Expand Down

0 comments on commit 83a1345

Please sign in to comment.