Skip to content

Commit 3a09a37

Browse files
authored
Merge pull request easybuilders#4216 from boegel/fix_skip_github_tests
fix typo in condition guarding installation of GitHub token in CI workflow to run unit tests + fix broken tests related to GitHub integration features
2 parents 5ec768e + 9eb5902 commit 3a09a37

File tree

3 files changed

+46
-42
lines changed

3 files changed

+46
-42
lines changed

.github/workflows/unit_tests.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,16 @@ jobs:
120120
121121
- name: install GitHub token (if available)
122122
env:
123-
# see https://github.com/<username>/easybuild-framework/settings/secrets
124-
GITHUB_TOKEN: ${{secrets.TEST_GITHUB_TOKEN}}
123+
# token (owned by @boegelbot) with gist permissions (required for some of the tests for GitHub integration);
124+
# this token is not available in pull requests, so tests that require it are skipped in PRs,
125+
# and are only run after the PR gets merged
126+
GITHUB_TOKEN: ${{secrets.CI_UNIT_TESTS_GITHUB_TOKEN}}
125127
run: |
126128
# don't install GitHub token when testing with Lmod 7.x or non-Lmod module tools,
127129
# and only when testing with Lua as module syntax,
128130
# to avoid hitting GitHub rate limit;
129131
# tests that require a GitHub token are skipped automatically when no GitHub token is available
130-
if [[ ! "${{matrix.modules_tool}}" =~ 'Lmod-7' ]] && [[ ! "${{matrix.modules_tool}}" =~ 'modules-' ]] && [[ "${{matrix.modules_syntax}}" == 'Lua' ]]; then
132+
if [[ ! "${{matrix.modules_tool}}" =~ 'Lmod-7' ]] && [[ ! "${{matrix.modules_tool}}" =~ 'modules-' ]] && [[ "${{matrix.module_syntax}}" == 'Lua' ]]; then
131133
if [ ! -z $GITHUB_TOKEN ]; then
132134
if [ "x${{matrix.python}}" == 'x2.6' ];
133135
then SET_KEYRING="keyring.set_keyring(keyring.backends.file.PlaintextKeyring())";

test/framework/github.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def test_github_reasons_for_closing(self):
266266
}
267267
init_config(build_options=build_options)
268268

269-
pr_data, _ = gh.fetch_pr_data(1844, repo_owner, repo_name, GITHUB_TEST_ACCOUNT, full=True)
269+
pr_data, _ = gh.fetch_pr_data(16080, repo_owner, repo_name, GITHUB_TEST_ACCOUNT, full=True)
270270

271271
self.mock_stdout(True)
272272
self.mock_stderr(True)
@@ -278,12 +278,12 @@ def test_github_reasons_for_closing(self):
278278
self.mock_stderr(False)
279279

280280
self.assertIsInstance(res, list)
281-
self.assertEqual(stderr.strip(), "WARNING: Using easyconfigs from closed PR #1844")
281+
self.assertEqual(stderr.strip(), "WARNING: Using easyconfigs from closed PR #16080")
282282
patterns = [
283283
"Status of last commit is SUCCESS",
284284
"Last comment on",
285285
"No activity since",
286-
"* QEMU-2.4.0",
286+
"* c-ares-1.18.1",
287287
]
288288
for pattern in patterns:
289289
self.assertIn(pattern, stdout)
@@ -633,46 +633,47 @@ def test_github_det_commit_status(self):
633633
print("Skipping test_det_commit_status, no GitHub token available?")
634634
return
635635

636-
# ancient commit, from Jenkins era
636+
# ancient commit, from Jenkins era, no commit status available anymore
637637
commit_sha = 'ec5d6f7191676a86a18404616691796a352c5f1d'
638638
res = gh.det_commit_status('easybuilders', 'easybuild-easyconfigs', commit_sha, GITHUB_TEST_ACCOUNT)
639-
self.assertEqual(res, 'success')
639+
self.assertEqual(res, None)
640640

641-
# commit with failing tests from Travis CI era (no GitHub Actions yet)
642-
commit_sha = 'd0c62556caaa78944722dc84bbb1072bf9688f74'
641+
# ancient commit with passing tests from Travis CI era (no GitHub Actions yet),
642+
# no commit status available anymore
643+
commit_sha = '21354990e4e6b4ca169b93d563091db4c6b2693e'
643644
res = gh.det_commit_status('easybuilders', 'easybuild-easyconfigs', commit_sha, GITHUB_TEST_ACCOUNT)
644-
self.assertEqual(res, 'failure')
645+
self.assertEqual(res, None)
645646

646-
# commit with passing tests from Travis CI era (no GitHub Actions yet)
647-
commit_sha = '21354990e4e6b4ca169b93d563091db4c6b2693e'
647+
# ancient commit tested by both Travis CI and GitHub Actions, no commit status available anymore
648+
commit_sha = '1fba8ac835d62e78cdc7988b08f4409a1570cef1'
648649
res = gh.det_commit_status('easybuilders', 'easybuild-easyconfigs', commit_sha, GITHUB_TEST_ACCOUNT)
649-
self.assertEqual(res, 'success')
650+
self.assertEqual(res, None)
650651

651-
# commit with failing tests, tested by both Travis CI and GitHub Actions
652-
commit_sha = '3a596de93dd95b651b0d1503562d888409364a96'
652+
# old commit only tested by GitHub Actions, no commit status available anymore
653+
commit_sha = 'd7130683f02fe8284df3557f0b2fd3947c2ea153'
653654
res = gh.det_commit_status('easybuilders', 'easybuild-easyconfigs', commit_sha, GITHUB_TEST_ACCOUNT)
654-
self.assertEqual(res, 'failure')
655+
self.assertEqual(res, None)
655656

656-
# commit with passing tests, tested by both Travis CI and GitHub Actions
657-
commit_sha = '1fba8ac835d62e78cdc7988b08f4409a1570cef1'
657+
# commit in test repo where no CI is running at all, no None as result
658+
commit_sha = '8456f867b03aa001fd5a6fe5a0c4300145c065dc'
659+
res = gh.det_commit_status('easybuilders', GITHUB_REPO, commit_sha, GITHUB_TEST_ACCOUNT)
660+
self.assertEqual(res, None)
661+
662+
# recent commit (2023-04-11) with cancelled checks (GitHub Actions only)
663+
commit_sha = 'c074f0bb3110c27d9969c3d0b19dde3eca868bd4'
658664
res = gh.det_commit_status('easybuilders', 'easybuild-easyconfigs', commit_sha, GITHUB_TEST_ACCOUNT)
659-
self.assertEqual(res, 'success')
665+
self.assertEqual(res, 'cancelled')
660666

661-
# commit with failing tests, only tested by GitHub Actions
662-
commit_sha = 'd7130683f02fe8284df3557f0b2fd3947c2ea153'
667+
# recent commit (2023-04-10) with failing checks (GitHub Actions only)
668+
commit_sha = '1b4a45c62d7deaf19125756c46dc8f011fef66e1'
663669
res = gh.det_commit_status('easybuilders', 'easybuild-easyconfigs', commit_sha, GITHUB_TEST_ACCOUNT)
664670
self.assertEqual(res, 'failure')
665671

666-
# commit with passing tests, only tested by GitHub Actions
667-
commit_sha = 'e6df09700a1b90c63b4f760eda4b590ee1a9c2fd'
672+
# recent commit (2023-04-10) with successful checks (GitHub Actions only)
673+
commit_sha = '56812a347acbaaa87f229fe319425020fe399647'
668674
res = gh.det_commit_status('easybuilders', 'easybuild-easyconfigs', commit_sha, GITHUB_TEST_ACCOUNT)
669675
self.assertEqual(res, 'success')
670676

671-
# commit in test repo where no CI is running at all
672-
commit_sha = '8456f867b03aa001fd5a6fe5a0c4300145c065dc'
673-
res = gh.det_commit_status('easybuilders', GITHUB_REPO, commit_sha, GITHUB_TEST_ACCOUNT)
674-
self.assertEqual(res, None)
675-
676677
def test_github_check_pr_eligible_to_merge(self):
677678
"""Test check_pr_eligible_to_merge function"""
678679
def run_check(expected_result=False):

test/framework/options.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4453,7 +4453,7 @@ def test_github_new_update_pr(self):
44534453
]
44544454
self._assert_regexs(regexs, txt, assert_true=False)
44554455

4456-
def test_new_pr_warning_missing_patch(self):
4456+
def test_github_new_pr_warning_missing_patch(self):
44574457
"""Test warning printed by --new-pr (dry run only) when a specified patch file could not be found."""
44584458

44594459
if self.github_token is None:
@@ -4678,7 +4678,7 @@ def test_github_new_pr_dependencies(self):
46784678

46794679
self._assert_regexs(regexs, txt)
46804680

4681-
def test_new_pr_easyblock(self):
4681+
def test_github_new_pr_easyblock(self):
46824682
"""
46834683
Test using --new-pr to open an easyblocks PR
46844684
"""
@@ -4751,14 +4751,15 @@ def test_github_merge_pr(self):
47514751

47524752
expected_stdout = '\n'.join([
47534753
"Checking eligibility of easybuilders/easybuild-easyconfigs PR #4781 for merging...",
4754-
"* test suite passes: OK",
47554754
"* last test report is successful: OK",
47564755
"* no pending change requests: OK",
47574756
"* milestone is set: OK (3.3.1)",
47584757
"* mergeable state is clean: PR is already merged",
47594758
])
47604759
expected_stderr = '\n'.join([
47614760
"* targets some_branch branch: FAILED; found 'develop' => not eligible for merging!",
4761+
# since commit status for old PRs is no longer available, so test suite check fails
4762+
"* test suite passes: (status: None) => not eligible for merging!",
47624763
"* approved review: MISSING => not eligible for merging!",
47634764
'',
47644765
"WARNING: Review indicates this PR should not be merged (use -f/--force to do so anyway)",
@@ -4768,24 +4769,24 @@ def test_github_merge_pr(self):
47684769

47694770
# full eligible merged PR, default target branch
47704771
del args[-1]
4771-
args[1] = '4832'
4772+
args[1] = '17065'
47724773

47734774
stdout, stderr = self._run_mock_eb(args, do_build=True, raise_error=True, testing=False)
47744775

47754776
expected_stdout = '\n'.join([
4776-
"Checking eligibility of easybuilders/easybuild-easyconfigs PR #4832 for merging...",
4777+
"Checking eligibility of easybuilders/easybuild-easyconfigs PR #17065 for merging...",
47774778
"* targets develop branch: OK",
47784779
"* test suite passes: OK",
47794780
"* last test report is successful: OK",
47804781
"* no pending change requests: OK",
4781-
"* approved review: OK (by wpoely86)",
4782-
"* milestone is set: OK (3.3.1)",
4782+
"* approved review: OK (by SebastianAchilles)",
4783+
"* milestone is set: OK (4.7.1)",
47834784
"* mergeable state is clean: PR is already merged",
47844785
'',
47854786
"Review OK, merging pull request!",
47864787
'',
4787-
"[DRY RUN] Adding comment to easybuild-easyconfigs issue #4832: 'Going in, thanks @boegel!'",
4788-
"[DRY RUN] Merged easybuilders/easybuild-easyconfigs pull request #4832",
4788+
"[DRY RUN] Adding comment to easybuild-easyconfigs issue #17065: 'Going in, thanks @boegel!'",
4789+
"[DRY RUN] Merged easybuilders/easybuild-easyconfigs pull request #17065",
47894790
])
47904791
expected_stderr = ''
47914792
self.assertEqual(stderr.strip(), expected_stderr)
@@ -4794,20 +4795,20 @@ def test_github_merge_pr(self):
47944795
# --merge-pr also works on easyblocks (& framework) PRs
47954796
args = [
47964797
'--merge-pr',
4797-
'1206',
4798+
'2805',
47984799
'--pr-target-repo=easybuild-easyblocks',
47994800
'-D',
48004801
'--github-user=%s' % GITHUB_TEST_ACCOUNT,
48014802
]
48024803
stdout, stderr = self._run_mock_eb(args, do_build=True, raise_error=True, testing=False)
48034804
self.assertEqual(stderr.strip(), '')
48044805
expected_stdout = '\n'.join([
4805-
"Checking eligibility of easybuilders/easybuild-easyblocks PR #1206 for merging...",
4806+
"Checking eligibility of easybuilders/easybuild-easyblocks PR #2805 for merging...",
48064807
"* targets develop branch: OK",
48074808
"* test suite passes: OK",
48084809
"* no pending change requests: OK",
4809-
"* approved review: OK (by migueldiascosta)",
4810-
"* milestone is set: OK (3.3.1)",
4810+
"* approved review: OK (by ocaisa)",
4811+
"* milestone is set: OK (4.6.2)",
48114812
"* mergeable state is clean: PR is already merged",
48124813
'',
48134814
"Review OK, merging pull request!",

0 commit comments

Comments
 (0)