Repository: easybuilders/easybuild-framework

Issue:
GitHub integration check falsely reports gist creation issues
I'm getting the following when running `eb --check-github` with a personal access token that really has the proper `gists` permission:
```
Checking status of GitHub integration...

Making sure we're online...OK

* GitHub user...bedroge => OK
* GitHub token...ghp..MW0 (len: 40) => OK (validated)
* git command...OK ("git version 2.31.1; ")
* GitPython module...OK (GitPython version 3.1.18)
The authenticity of host 'github.com (140.82.121.3)' can't be established.
ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
* push access to bedroge/easybuild-easyconfigs repo @ GitHub...OK
* creating gists...FAIL (gist_url: https://gist.github.com/bedroge/6e0503bc018f7de1a7d63f3e994b0c71)
* location to Git working dirs... OK (/home1/p251204/easybuild)

One or more checks FAILed, GitHub configuration not fully complete!
See http://easybuild.readthedocs.org/en/latest/Integration_with_GitHub.html#configuration for help.

Status of GitHub integration:
* --from-pr: OK
* --new-pr: OK
* --review-pr: OK
* --update-pr: OK
* --upload-test-report: not supported
```

@branfosj just confirmed he's seeing the same issue. Interestingly, things seem to work fine anyway (it uploaded this test report right after running the above command: https://github.com/easybuilders/easybuild-easyconfigs/pull/17610#issuecomment-1486770600), so it looks like there's something wrong with this check.


Discussion:
We match on
```py
re.match('https://gist.github.com/[0-9a-f]+$', gist_url)
```

However, the gist_url now includes github username: https://gist.github.com/branfosj/b4087b3584dd92133f3bbc1d995759b6
Changing it to
```py
re.match('https://gist.github.com/%s/[0-9a-f]+$' % github_user, gist_url):
```

seems to solve the issue.

Resolving patch:
diff --git a/easybuild/tools/github.py b/easybuild/tools/github.py
--- 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/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)
@@ -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


Test patch:
diff --git a/test/framework/github.py b/test/framework/github.py
--- 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/%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",
         ])