Skip to content

Commit 8dee633

Browse files
authored
Merge pull request #3103 from boegel/pr_branch
add support for --new-branch-github, --new-pr-from-branch, --sync-branch-with-develop, --update-branch-github
2 parents 74a4c03 + 5e6c561 commit 8dee633

File tree

6 files changed

+405
-81
lines changed

6 files changed

+405
-81
lines changed

easybuild/framework/easyconfig/easyconfig.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ def __init__(self, path, extra_options=None, build_specs=None, validate=True, hi
410410
if rawtxt is None:
411411
self.path = path
412412
self.rawtxt = read_file(path)
413-
self.log.debug("Raw contents from supplied easyconfig file %s: %s" % (path, self.rawtxt))
413+
self.log.debug("Raw contents from supplied easyconfig file %s: %s", path, self.rawtxt)
414414
else:
415415
self.rawtxt = rawtxt
416416
self.log.debug("Supplied raw easyconfig contents: %s" % self.rawtxt)
@@ -606,7 +606,7 @@ def parse(self):
606606
type(self.build_specs))
607607
self.log.debug("Obtained specs dict %s" % arg_specs)
608608

609-
self.log.info("Parsing easyconfig file %s with rawcontent: %s" % (self.path, self.rawtxt))
609+
self.log.info("Parsing easyconfig file %s with rawcontent: %s", self.path, self.rawtxt)
610610
self.parser.set_specifications(arg_specs)
611611
local_vars = self.parser.get_config_dict()
612612
self.log.debug("Parsed easyconfig as a dictionary: %s" % local_vars)

easybuild/main.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@
5757
from easybuild.tools.containers.common import containerize
5858
from easybuild.tools.docs import list_software
5959
from easybuild.tools.filetools import adjust_permissions, cleanup, write_file
60-
from easybuild.tools.github import check_github, find_easybuild_easyconfig, install_github_token
61-
from easybuild.tools.github import close_pr, list_prs, new_pr, merge_pr, sync_pr_with_develop, update_pr
60+
from easybuild.tools.github import check_github, close_pr, new_branch_github, find_easybuild_easyconfig
61+
from easybuild.tools.github import install_github_token, list_prs, new_pr, new_pr_from_branch, merge_pr
62+
from easybuild.tools.github import sync_branch_with_develop, sync_pr_with_develop, update_branch, update_pr
6263
from easybuild.tools.hooks import START, END, load_hooks, run_hook
6364
from easybuild.tools.modules import modules_tool
6465
from easybuild.tools.options import set_up_configuration, use_color
@@ -293,7 +294,9 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None):
293294
categorized_paths = categorize_files_by_type(orig_paths)
294295

295296
# command line options that do not require any easyconfigs to be specified
296-
pr_options = options.new_pr or options.preview_pr or options.sync_pr_with_develop or options.update_pr
297+
pr_options = options.new_branch_github or options.new_pr or options.new_pr_from_branch or options.preview_pr
298+
pr_options = pr_options or options.sync_branch_with_develop or options.sync_pr_with_develop
299+
pr_options = pr_options or options.update_branch_github or options.update_pr
297300
no_ec_opts = [options.aggregate_regtest, options.regtest, pr_options, search_query]
298301

299302
# determine paths to easyconfigs
@@ -306,16 +309,15 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None):
306309
if determined_paths:
307310
# transform paths into tuples, use 'False' to indicate the corresponding easyconfig files were not generated
308311
paths = [(p, False) for p in determined_paths]
312+
elif 'name' in build_specs:
313+
# try to obtain or generate an easyconfig file via build specifications if a software name is provided
314+
paths = find_easyconfigs_by_specs(build_specs, robot_path, try_to_generate, testing=testing)
315+
elif any(no_ec_opts):
316+
paths = determined_paths
309317
else:
310-
if 'name' in build_specs:
311-
# try to obtain or generate an easyconfig file via build specifications if a software name is provided
312-
paths = find_easyconfigs_by_specs(build_specs, robot_path, try_to_generate, testing=testing)
313-
elif any(no_ec_opts):
314-
paths = determined_paths
315-
else:
316-
print_error(("Please provide one or multiple easyconfig files, or use software build "
317-
"options to make EasyBuild search for easyconfigs"),
318-
log=_log, opt_parser=eb_go.parser, exit_on_error=not testing)
318+
print_error("Please provide one or multiple easyconfig files, or use software build " +
319+
"options to make EasyBuild search for easyconfigs",
320+
log=_log, opt_parser=eb_go.parser, exit_on_error=not testing)
319321
_log.debug("Paths: %s", paths)
320322

321323
# run regtest
@@ -385,14 +387,21 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None):
385387
# creating/updating PRs
386388
if pr_options:
387389
if options.new_pr:
388-
new_pr(categorized_paths, ordered_ecs, title=options.pr_title, descr=options.pr_descr,
389-
commit_msg=options.pr_commit_msg)
390+
new_pr(categorized_paths, ordered_ecs)
391+
elif options.new_branch_github:
392+
new_branch_github(categorized_paths, ordered_ecs)
393+
elif options.new_pr_from_branch:
394+
new_pr_from_branch(options.new_pr_from_branch)
390395
elif options.preview_pr:
391396
print(review_pr(paths=determined_paths, colored=use_color(options.color)))
397+
elif options.sync_branch_with_develop:
398+
sync_branch_with_develop(options.sync_branch_with_develop)
392399
elif options.sync_pr_with_develop:
393400
sync_pr_with_develop(options.sync_pr_with_develop)
401+
elif options.update_branch_github:
402+
update_branch(options.update_branch_github, categorized_paths, ordered_ecs)
394403
elif options.update_pr:
395-
update_pr(options.update_pr, categorized_paths, ordered_ecs, commit_msg=options.pr_commit_msg)
404+
update_pr(options.update_pr, categorized_paths, ordered_ecs)
396405
else:
397406
raise EasyBuildError("Unknown PR option!")
398407

easybuild/tools/config.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,12 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
191191
'package_tool_options',
192192
'parallel',
193193
'pr_branch_name',
194+
'pr_commit_msg',
195+
'pr_descr',
194196
'pr_target_account',
195197
'pr_target_branch',
196198
'pr_target_repo',
199+
'pr_title',
197200
'rpath_filter',
198201
'regtest_output_dir',
199202
'silence_deprecation_warnings',
@@ -439,17 +442,21 @@ def init_build_options(build_options=None, cmdline_options=None):
439442
cmdline_options.force = True
440443
retain_all_deps = True
441444

442-
if cmdline_options.new_pr or cmdline_options.update_pr:
443-
_log.info("Retaining all dependencies of specified easyconfigs to create/update pull request")
445+
new_update_opt = cmdline_options.new_branch_github or cmdline_options.new_pr
446+
new_update_opt = new_update_opt or cmdline_options.update_branch_github or cmdline_options.update_pr
447+
448+
if new_update_opt:
449+
_log.info("Retaining all dependencies of specified easyconfigs to create/update branch or pull request")
444450
retain_all_deps = True
445451

446452
auto_ignore_osdeps_options = [cmdline_options.check_conflicts, cmdline_options.check_contrib,
447453
cmdline_options.check_style, cmdline_options.containerize,
448454
cmdline_options.dep_graph, cmdline_options.dry_run,
449455
cmdline_options.dry_run_short, cmdline_options.dump_env_script,
450456
cmdline_options.extended_dry_run, cmdline_options.fix_deprecated_easyconfigs,
451-
cmdline_options.missing_modules, cmdline_options.new_pr,
452-
cmdline_options.preview_pr, cmdline_options.update_pr]
457+
cmdline_options.missing_modules, cmdline_options.new_branch_github,
458+
cmdline_options.new_pr, cmdline_options.preview_pr,
459+
cmdline_options.update_branch_github, cmdline_options.update_pr]
453460
if any(auto_ignore_osdeps_options):
454461
_log.info("Auto-enabling ignoring of OS dependencies")
455462
cmdline_options.ignore_osdeps = True

0 commit comments

Comments
 (0)