From 97e78012583cc1ba67f27d5ce323b68545114345 Mon Sep 17 00:00:00 2001 From: Simon Branford <4967+branfosj@users.noreply.github.com> Date: Tue, 28 Mar 2023 13:50:57 +0100 Subject: [PATCH 1/3] fix --check-github as gist url now includes username --- easybuild/tools/github.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/tools/github.py b/easybuild/tools/github.py index 40ffb0a704..b948ec0f4a 100644 --- a/easybuild/tools/github.py +++ b/easybuild/tools/github.py @@ -2126,7 +2126,7 @@ def check_github(): except Exception as err: _log.warning("Exception occurred when trying to create & delete gist: %s", err) - if gist_url and re.match('https://gist.github.com/[0-9a-f]+$', gist_url): + if gist_url and re.match('https://gist.github.com/%s/[0-9a-f]+$' % github_user, gist_url): check_res = "OK" else: check_res = "FAIL (gist_url: %s)" % gist_url From 9f8447414b39ece866b6ce7553799d06c2d08764 Mon Sep 17 00:00:00 2001 From: Simon Branford <4967+branfosj@users.noreply.github.com> Date: Tue, 28 Mar 2023 19:50:17 +0100 Subject: [PATCH 2/3] also update the dry run and test --- easybuild/tools/github.py | 2 +- test/framework/github.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/easybuild/tools/github.py b/easybuild/tools/github.py index b948ec0f4a..0d9da1f6ee 100644 --- a/easybuild/tools/github.py +++ b/easybuild/tools/github.py @@ -589,7 +589,7 @@ def create_gist(txt, fn, descr=None, github_user=None, github_token=None): } if dry_run: - status, data = HTTP_STATUS_CREATED, {'html_url': 'https://gist.github.com/DRY_RUN'} + status, data = HTTP_STATUS_CREATED, {'html_url': 'https://gist.github.com/username/DRY_RUN'} else: g = RestClient(GITHUB_API_URL, username=github_user, token=github_token) status, data = g.gists.post(body=body) diff --git a/test/framework/github.py b/test/framework/github.py index 4a1e88298e..bfd7afb419 100644 --- a/test/framework/github.py +++ b/test/framework/github.py @@ -1113,7 +1113,7 @@ def test_github_pr_test_report(self): patterns = [ r"^\[DRY RUN\] Adding comment to easybuild-easyconfigs issue #1234: 'Test report by @easybuild_test", - r"^See https://gist.github.com/DRY_RUN for a full test report.'", + r"^See https://gist.github.com/username/DRY_RUN for a full test report.'", ] for pattern in patterns: regex = re.compile(pattern, re.M) From 8a589f52d0799f1eb052453bef85cf276d6cbada Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Wed, 29 Mar 2023 20:27:34 +0200 Subject: [PATCH 3/3] use actual GitHub user name in dry run gist URL + more fixes for gist URLs in tests for GitHub integration --- easybuild/tools/github.py | 4 +++- test/framework/github.py | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/easybuild/tools/github.py b/easybuild/tools/github.py index 0d9da1f6ee..bc3a6b3e27 100644 --- a/easybuild/tools/github.py +++ b/easybuild/tools/github.py @@ -589,7 +589,9 @@ def create_gist(txt, fn, descr=None, github_user=None, github_token=None): } if dry_run: - status, data = HTTP_STATUS_CREATED, {'html_url': 'https://gist.github.com/username/DRY_RUN'} + if github_user is None: + github_user = 'username' + status, data = HTTP_STATUS_CREATED, {'html_url': 'https://gist.github.com/%s/DRY_RUN' % github_user} else: g = RestClient(GITHUB_API_URL, username=github_user, token=github_token) status, data = g.gists.post(body=body) diff --git a/test/framework/github.py b/test/framework/github.py index bfd7afb419..9df53736e4 100644 --- a/test/framework/github.py +++ b/test/framework/github.py @@ -1113,7 +1113,7 @@ def test_github_pr_test_report(self): patterns = [ r"^\[DRY RUN\] Adding comment to easybuild-easyconfigs issue #1234: 'Test report by @easybuild_test", - r"^See https://gist.github.com/username/DRY_RUN for a full test report.'", + r"^See https://gist.github.com/%s/DRY_RUN for a full test report.'" % GITHUB_TEST_ACCOUNT, ] for pattern in patterns: regex = re.compile(pattern, re.M) @@ -1130,7 +1130,7 @@ def test_github_pr_test_report(self): patterns = [ r"^\[DRY RUN\] Adding comment to easybuild-easyblocks issue #1234: 'Test report by @easybuild_test", - r"^See https://gist.github.com/DRY_RUN for a full test report.'", + r"^See https://gist.github.com/%s/DRY_RUN for a full test report.'" % GITHUB_TEST_ACCOUNT, ] for pattern in patterns: regex = re.compile(pattern, re.M) @@ -1150,7 +1150,7 @@ def test_github_pr_test_report(self): patterns = [ r"^\[DRY RUN\] Adding comment to easybuild-easyconfigs issue #1234: 'Test report by @easybuild_test", - r"^See https://gist.github.com/DRY_RUN for a full test report.'", + r"^See https://gist.github.com/%s/DRY_RUN for a full test report.'" % GITHUB_TEST_ACCOUNT, r"Using easyblocks from PR\(s\) https://github.com/easybuilders/easybuild-easyblocks/pull/6789", ] for pattern in patterns: @@ -1192,13 +1192,13 @@ def test_github_create_test_report(self): # mock create_gist function, we don't want to actually create a gist every time we run this test... def fake_create_gist(*args, **kwargs): - return 'https://gist.github.com/test' + return 'https://gist.github.com/%s/test' % GITHUB_TEST_ACCOUNT easybuild.tools.testing.create_gist = fake_create_gist res = create_test_report("just a test", ecs_with_res, init_session_state, pr_nrs=[123], gist_log=True) - patterns.insert(2, "https://gist.github.com/test") + patterns.insert(2, "https://gist.github.com/%s/test" % GITHUB_TEST_ACCOUNT) patterns.extend([ "https://github.com/easybuilders/easybuild-easyconfigs/pull/123", ])