From df1efc5c73dd626ba9c5a7dca0e0cbe5cb8caf7f Mon Sep 17 00:00:00 2001 From: PSala Date: Mon, 12 Aug 2024 14:17:45 +0200 Subject: [PATCH 1/5] Update tests --- fabtools/tests/test_files.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fabtools/tests/test_files.py b/fabtools/tests/test_files.py index 3cc20417..289d105b 100644 --- a/fabtools/tests/test_files.py +++ b/fabtools/tests/test_files.py @@ -34,31 +34,31 @@ def test_verify_remote_true(self, is_file, md5sum, put, umask, owner, mode): used to work out whether the file is different. """ is_file.return_value = True - md5sum.return_value = hashlib.md5('This is a test').hexdigest() + md5sum.return_value = hashlib.md5('This is a test'.encode()).hexdigest() self._file(contents='This is a test', verify_remote=True) self.assertTrue(is_file.called) self.assertTrue(md5sum.called) def test_temp_dir(self, is_file, md5sum, put, umask, owner, mode): owner.return_value = 'root' - umask.return_value = '0002' - mode.return_value = '0664' + umask.return_value = '{}'.format(oct(eval('0o002'))) + mode.return_value = '{}'.format(oct(eval('0o664'))) from fabtools import require require.file('/var/tmp/foo', source=__file__, use_sudo=True, temp_dir='/somewhere') put.assert_called_with(__file__, '/var/tmp/foo', use_sudo=True, temp_dir='/somewhere') def test_home_as_temp_dir(self, is_file, md5sum, put, umask, owner, mode): owner.return_value = 'root' - umask.return_value = '0002' - mode.return_value = '0664' + umask.return_value = '{}'.format(oct(eval('0o002'))) + mode.return_value = '{}'.format(oct(eval('0o664'))) from fabtools import require require.file('/var/tmp/foo', source=__file__, use_sudo=True, temp_dir='') put.assert_called_with(__file__, '/var/tmp/foo', use_sudo=True, temp_dir='') def test_default_temp_dir(self, is_file, md5sum, put, umask, owner, mode): owner.return_value = 'root' - umask.return_value = '0002' - mode.return_value = '0664' + umask.return_value = '{}'.format(oct(eval('0o002'))) + mode.return_value = '{}'.format(oct(eval('0o664'))) from fabtools import require require.file('/var/tmp/foo', source=__file__, use_sudo=True) put.assert_called_with(__file__, '/var/tmp/foo', use_sudo=True, temp_dir='/tmp') From a518f6b50aa0c2f0a71e004fa82a0ae98756a45d Mon Sep 17 00:00:00 2001 From: PSala Date: Mon, 12 Aug 2024 14:18:20 +0200 Subject: [PATCH 2/5] Use o ocatal formad and fix urlparse compat --- fabtools/openvz/contextmanager.py | 4 ++-- fabtools/require/files.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fabtools/openvz/contextmanager.py b/fabtools/openvz/contextmanager.py index 3b199632..0d026101 100644 --- a/fabtools/openvz/contextmanager.py +++ b/fabtools/openvz/contextmanager.py @@ -158,8 +158,8 @@ def put_guest(self, local_path, remote_path, use_sudo, mirror_local_mode, # Handle modes if necessary if (local_is_path and mirror_local_mode) or (mode is not None): lmode = os.stat(local_path).st_mode if mirror_local_mode else mode - lmode = lmode & 07777 - rmode = rattrs.st_mode & 07777 + lmode = lmode & 0o7777 + rmode = rattrs.st_mode & 0o7777 if lmode != rmode: with hide('everything'): sudo('chmod %o \"%s\"' % (lmode, remote_path)) diff --git a/fabtools/require/files.py b/fabtools/require/files.py index a4443868..2b33cab0 100644 --- a/fabtools/require/files.py +++ b/fabtools/require/files.py @@ -9,7 +9,7 @@ from pipes import quote from tempfile import mkstemp -from urlparse import urlparse +from six.moves.urllib_parse import urlparse import hashlib import os @@ -191,7 +191,7 @@ def file(path=None, contents=None, source=None, url=None, md5=None, # Ensure correct mode if use_sudo and mode is None: - mode = oct(0666 & ~int(umask(use_sudo=True), base=8)) + mode = oct(0o666 & ~int(umask(use_sudo=True), base=8)) if mode and _mode(path, use_sudo) != mode: func('chmod %(mode)s "%(path)s"' % locals()) From 6b0b379d1e96d571d65505c8af3a6248110d56f3 Mon Sep 17 00:00:00 2001 From: PSala Date: Mon, 12 Aug 2024 14:24:34 +0200 Subject: [PATCH 3/5] Add workflow --- .github/workflows/run_tests.yml | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/run_tests.yml diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml new file mode 100644 index 00000000..068f181a --- /dev/null +++ b/.github/workflows/run_tests.yml @@ -0,0 +1,46 @@ +name: GISCExFabtools + +on: + push: + branches: [ git_clone_branch ] + pull_request: + branches: [ git_clone_branch ] + +jobs: + run-tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["2.7", "3.10", "3.11", "3.12"] + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + if: matrix.python-version != '2.7' + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Python 2 + if: matrix.python-version == '2.7' + run: | + sudo apt update + sudo apt install python2 python-pip + sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1 + sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2 + printf '1\n' | sudo update-alternatives --config python + cd /usr/bin + sudo ln -s /usr/bin/pip2 ./pip + + - name: Upgrade pip + run: | + pip install --upgrade pip setuptools wheel + + - name: Install package + run: | + pip install -e . + + - name: Run test + run: | + python -m unittest discover -v \ No newline at end of file From da93f5458c7ad7fa2f7bb82d09a46ff2638dd148 Mon Sep 17 00:00:00 2001 From: PSala Date: Mon, 12 Aug 2024 14:28:47 +0200 Subject: [PATCH 4/5] Fix fabric requirement --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7c9258c6..d3310efa 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ def run_tests(self): url='http://fabtools.readthedocs.org/', license='BSD', install_requires=[ - "fabric>=1.7.0", + "fabric>=1.7.0,<2.0", ], setup_requires=[], tests_require=[ From b2e3494acaee654fb5c6f1bf745faab36806b561 Mon Sep 17 00:00:00 2001 From: PSala Date: Mon, 12 Aug 2024 14:35:18 +0200 Subject: [PATCH 5/5] Update ci --- .github/workflows/run_tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 068f181a..3045c629 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -39,6 +39,8 @@ jobs: - name: Install package run: | + pip install pytest + pip install mock pip install -e . - name: Run test