Skip to content

Commit

Permalink
If specs are mentioned in the PR, ask to uninstall them before the build
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardkaindl committed Oct 31, 2024
1 parent f071aef commit d12e5d4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions cli/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,20 @@ def check_queue_file(args: argparse.Namespace) -> int:
return Success


def get_requested_specs_from_pr(args):
"""Get the specs requested in the PR comments."""

requested_specs = []
for reviews in args.pr["reviews"] + args.pr["comments"]:
body = reviews["body"]
match = re.search(r"--fail-fast ([^ `]+)", body, re.DOTALL)
if match:
requested_specs.append(match.group(1))
print(match.group(1))

return list(set(requested_specs))


def check_and_build(args: argparse.Namespace) -> ExitCode:
"""Check the PR changes and build the packages."""

Expand All @@ -1414,6 +1428,19 @@ def check_and_build(args: argparse.Namespace) -> ExitCode:
if args.download:
return check_all_downloads(specs_to_check)

requested_specs_from_pr = get_requested_specs_from_pr(args)
if requested_specs_from_pr:
print("Checking Specs requested in the PR comments to be uninstalled:")
installed, findings = find_already_installed(requested_specs_from_pr)
print("These specs are already installed:")
if installed:
print("These specs that are requested in the PR are already installed:")
print("\n".join(findings))
if args.uninstall:
if args.yes or input("Uninstall these requested specs? [y/n]: ").lower() == "y":
for spec in installed:
spack_uninstall_packages([spec])

# Check if specs are already installed and ask if they should be uninstalled.
# If the user agrees, uninstall the packages.
installed, _ = find_already_installed(specs_to_check)
Expand Down

0 comments on commit d12e5d4

Please sign in to comment.