From ee9ca65c57a384fe5e1cfb453c3a30546dfe2c95 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Wed, 28 Jul 2021 14:34:32 +0200 Subject: [PATCH 1/4] Really remove support code for Python < 2.7 --- .github/workflows/unit_tests.yml | 6 +++--- easybuild/tools/systemtools.py | 1 - test/framework/repository.py | 6 +----- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 1072bf421d..6fb76814cf 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -101,12 +101,12 @@ jobs: # and are only run after the PR gets merged GITHUB_TOKEN: ${{secrets.CI_UNIT_TESTS_GITHUB_TOKEN}} run: | - # only install GitHub token when testing with Lmod 8.x + Python 3.6 or 3.9, to avoid hitting GitHub rate limit; + # only install GitHub token when testing with Lmod 8.x + Python 3.6 or 3.9, to avoid hitting GitHub rate limit # tests that require a GitHub token are skipped automatically when no GitHub token is available if [[ "${{matrix.modules_tool}}" =~ 'Lmod-8' ]] && [[ "${{matrix.python}}" =~ 3.[69] ]]; then if [ ! -z $GITHUB_TOKEN ]; then - SET_KEYRING="import keyrings.alt.file; keyring.set_keyring(keyrings.alt.file.PlaintextKeyring())"; - python -c "import keyring; $SET_KEYRING; keyring.set_password('github_token', 'easybuild_test', '$GITHUB_TOKEN')"; + SET_KEYRING="import keyrings.alt.file; keyring.set_keyring(keyrings.alt.file.PlaintextKeyring())" + python -c "import keyring; $SET_KEYRING; keyring.set_password('github_token', 'easybuild_test', '$GITHUB_TOKEN')" fi echo "GitHub token installed!" else diff --git a/easybuild/tools/systemtools.py b/easybuild/tools/systemtools.py index b4e1c254da..2fdd9c4ba8 100644 --- a/easybuild/tools/systemtools.py +++ b/easybuild/tools/systemtools.py @@ -736,7 +736,6 @@ def get_os_name(): # platform.linux_distribution was removed in Python 3.8, # see https://docs.python.org/2/library/platform.html#platform.linux_distribution if hasattr(platform, 'linux_distribution'): - # platform.linux_distribution is more useful, but only available since Python 2.6 # this allows to differentiate between Fedora, CentOS, RHEL and Scientific Linux (Rocks is just CentOS) with warnings.catch_warnings(): warnings.simplefilter("ignore", category=PendingDeprecationWarning) diff --git a/test/framework/repository.py b/test/framework/repository.py index 808f9fd43c..728039bf62 100644 --- a/test/framework/repository.py +++ b/test/framework/repository.py @@ -129,11 +129,7 @@ def test_svnrepo(self): self.assertExists(os.path.join(repo.wc, 'trunk', 'README.md')) shutil.rmtree(repo.wc) - # this test is disabled because it fails in Travis as a result of bitbucket disabling TLS 1.0/1.1 - # we can consider re-enabling it when moving to a more recent Ubuntu version in the Travis config - # (which implies dropping support for Python 2.6) - # cfr. https://github.com/easybuilders/easybuild-framework/pull/2678 - def DISABLED_test_hgrepo(self): + def test_hgrepo(self): """Test using HgRepository.""" # only run this test if pysvn Python module is available try: From e2dea1fb16d422ab22986f34feb1dc46364fec8a Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Wed, 28 Jul 2021 14:37:14 +0200 Subject: [PATCH 2/4] Use OrderedDict from collections not py2vs3 This is from the python installation since 2.7 --- easybuild/framework/easyconfig/easyconfig.py | 2 +- easybuild/tools/py2vs3/py3.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/easybuild/framework/easyconfig/easyconfig.py b/easybuild/framework/easyconfig/easyconfig.py index 772057fa6b..ae678f0269 100644 --- a/easybuild/framework/easyconfig/easyconfig.py +++ b/easybuild/framework/easyconfig/easyconfig.py @@ -46,8 +46,8 @@ import functools import os import re -from contextlib import contextmanager from collections import OrderedDict +from contextlib import contextmanager import easybuild.tools.filetools as filetools from easybuild.base import fancylogger diff --git a/easybuild/tools/py2vs3/py3.py b/easybuild/tools/py2vs3/py3.py index a01cb64d39..2f29f0fd54 100644 --- a/easybuild/tools/py2vs3/py3.py +++ b/easybuild/tools/py2vs3/py3.py @@ -36,7 +36,6 @@ import json import sys import urllib.request as std_urllib # noqa -from collections import OrderedDict # noqa from collections.abc import Mapping # noqa from functools import cmp_to_key from importlib.util import spec_from_file_location, module_from_spec From 71b7b214acc9d0be643509e8f8979bd2421972c2 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Wed, 28 Jul 2021 15:38:08 +0200 Subject: [PATCH 3/4] Remove outdated Mercurial test --- test/framework/repository.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/test/framework/repository.py b/test/framework/repository.py index 728039bf62..b45d5d7165 100644 --- a/test/framework/repository.py +++ b/test/framework/repository.py @@ -40,7 +40,6 @@ from easybuild.tools.filetools import read_file from easybuild.tools.repository.filerepo import FileRepository from easybuild.tools.repository.gitrepo import GitRepository -from easybuild.tools.repository.hgrepo import HgRepository from easybuild.tools.repository.svnrepo import SvnRepository from easybuild.tools.repository.repository import init_repository from easybuild.tools.run import run_shell_cmd @@ -129,23 +128,6 @@ def test_svnrepo(self): self.assertExists(os.path.join(repo.wc, 'trunk', 'README.md')) shutil.rmtree(repo.wc) - def test_hgrepo(self): - """Test using HgRepository.""" - # only run this test if pysvn Python module is available - try: - import hglib # noqa - except ImportError: - print("(skipping HgRepository test)") - return - - # GitHub also supports SVN - test_repo_url = 'https://kehoste@bitbucket.org/kehoste/testrepository' - - repo = HgRepository(test_repo_url) - repo.init() - self.assertExists(os.path.join(repo.wc, 'README')) - shutil.rmtree(repo.wc) - def test_init_repository(self): """Test use of init_repository function.""" repo = init_repository('FileRepository', self.path) From 6b4e7ba4a3704a390aee1c95057ef07d6a762103 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Tue, 3 Aug 2021 16:34:51 +0200 Subject: [PATCH 4/4] Simplify ignore patterns --- .github/workflows/unit_tests.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 6fb76814cf..5bf29eb164 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -187,7 +187,17 @@ jobs: # run test suite python -O -m test.framework.suite 2>&1 | tee test_framework_suite.log # try and make sure output of running tests is clean (no printed messages/warnings) - IGNORE_PATTERNS="no GitHub token available|skipping SvnRepository test|requires Lmod as modules tool|stty: 'standard input': Inappropriate ioctl for device|CryptographyDeprecationWarning: Python 3.[56]|from cryptography.* import |CryptographyDeprecationWarning: Python 2|Blowfish|GC3Pie not available, skipping test|CryptographyDeprecationWarning: TripleDES has been moved|algorithms.TripleDES" + IGNORE_PATTERNS="no GitHub token available" + IGNORE_PATTERNS+="|skipping SvnRepository test" + IGNORE_PATTERNS+="|requires Lmod as modules tool" + IGNORE_PATTERNS+="|stty: 'standard input': Inappropriate ioctl for device" + IGNORE_PATTERNS+="|CryptographyDeprecationWarning: Python 3.[56]" + IGNORE_PATTERNS+="|from cryptography.* import " + IGNORE_PATTERNS+="|CryptographyDeprecationWarning: Python 2" + IGNORE_PATTERNS+="|Blowfish" + IGNORE_PATTERNS+="|GC3Pie not available, skipping test" + IGNORE_PATTERNS+="|CryptographyDeprecationWarning: TripleDES has been moved" + IGNORE_PATTERNS+="|algorithms.TripleDES" # '|| true' is needed to avoid that GitHub Actions stops the job on non-zero exit of grep (i.e. when there are no matches) PRINTED_MSG=$(egrep -v "${IGNORE_PATTERNS}" test_framework_suite.log | grep '\.\n*[A-Za-z]' || true) test "x$PRINTED_MSG" = "x" || (echo "ERROR: Found printed messages in output of test suite" && echo "${PRINTED_MSG}" && exit 1)