Skip to content

Commit 032a77d

Browse files
authored
Merge pull request #3966 from branfosj/20220219115343_new_pr_BZXhcwUlrm
Only check for patches when using --new-pr if easyconfigs repository is target
2 parents f5ea74a + 7802570 commit 032a77d

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

easybuild/tools/github.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,13 +1783,15 @@ def new_pr(paths, ecs, title=None, descr=None, commit_msg=None):
17831783
res = new_branch_github(paths, ecs, commit_msg=commit_msg)
17841784
file_info, deleted_paths, _, branch_name, diff_stat, pr_target_repo = res
17851785

1786-
for ec, ec_path in zip(file_info['ecs'], file_info['paths_in_repo']):
1787-
for patch in ec.asdict()['patches']:
1788-
if isinstance(patch, tuple):
1789-
patch = patch[0]
1790-
if patch not in paths['patch_files'] and not os.path.isfile(os.path.join(os.path.dirname(ec_path), patch)):
1791-
print_warning("new patch file %s, referenced by %s, is not included in this PR" %
1792-
(patch, ec.filename()))
1786+
if pr_target_repo == GITHUB_EASYCONFIGS_REPO:
1787+
for ec, ec_path in zip(file_info['ecs'], file_info['paths_in_repo']):
1788+
for patch in ec.asdict()['patches']:
1789+
if isinstance(patch, tuple):
1790+
patch = patch[0]
1791+
if patch not in paths['patch_files'] and not os.path.isfile(os.path.join(os.path.dirname(ec_path),
1792+
patch)):
1793+
print_warning("new patch file %s, referenced by %s, is not included in this PR" %
1794+
(patch, ec.filename()))
17931795

17941796
new_pr_from_branch(branch_name, title=title, descr=descr, pr_target_repo=pr_target_repo,
17951797
pr_metadata=(file_info, deleted_paths, diff_stat), commit_msg=commit_msg)

test/framework/options.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4568,6 +4568,37 @@ def test_github_new_pr_dependencies(self):
45684568

45694569
self._assert_regexs(regexs, txt)
45704570

4571+
def test_new_pr_easyblock(self):
4572+
"""
4573+
Test using --new-pr to open an easyblocks PR
4574+
"""
4575+
4576+
if self.github_token is None:
4577+
print("Skipping test_new_pr_easyblock, no GitHub token available?")
4578+
return
4579+
4580+
topdir = os.path.dirname(os.path.abspath(__file__))
4581+
toy_eb = os.path.join(topdir, 'sandbox', 'easybuild', 'easyblocks', 't', 'toy.py')
4582+
self.assertTrue(os.path.exists(toy_eb))
4583+
4584+
args = [
4585+
'--github-user=%s' % GITHUB_TEST_ACCOUNT,
4586+
'--new-pr',
4587+
toy_eb,
4588+
'-D',
4589+
]
4590+
txt, _ = self._run_mock_eb(args, do_build=True, raise_error=True, testing=False)
4591+
4592+
patterns = [
4593+
r'target: easybuilders/easybuild-easyblocks:develop',
4594+
r'from: easybuild_test/easybuild-easyblocks:[0-9]+_new_pr_toy',
4595+
r'title: "new easyblock for toy"',
4596+
r'easybuild/easyblocks/t/toy.py',
4597+
]
4598+
for pattern in patterns:
4599+
regex = re.compile(pattern)
4600+
self.assertTrue(regex.search(txt), "Pattern '%s' should be found in: %s" % (regex.pattern, txt))
4601+
45714602
def test_github_merge_pr(self):
45724603
"""
45734604
Test use of --merge-pr (dry run)"""

0 commit comments

Comments
 (0)