Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix --check-github as gist url now includes username #4231

Merged
merged 3 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions easybuild/tools/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/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)
Expand Down Expand Up @@ -2126,7 +2128,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
Expand Down
10 changes: 5 additions & 5 deletions test/framework/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/%s/DRY_RUN for a full test report.'" % GITHUB_TEST_ACCOUNT,
]
for pattern in patterns:
regex = re.compile(pattern, re.M)
Expand All @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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",
])
Expand Down