From edee22204da6585d0f41b26cd355f1581cc0df1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20F=C3=A9lizard?= Date: Thu, 29 Aug 2024 07:02:17 +0000 Subject: [PATCH] Fix GitHub workflow --- .github/workflows/zeyple.yml | 13 ++++++------- CONTRIBUTING.md | 7 +++---- requirements.txt | 9 --------- tests/test_zeyple.py | 14 ++++++++------ tox.ini | 12 +++++++++--- 5 files changed, 26 insertions(+), 29 deletions(-) delete mode 100644 requirements.txt diff --git a/.github/workflows/zeyple.yml b/.github/workflows/zeyple.yml index 0070995..b9f0310 100644 --- a/.github/workflows/zeyple.yml +++ b/.github/workflows/zeyple.yml @@ -13,13 +13,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [2.7, 3.7] + python-version: [3.11, 3.12] fail-fast: false steps: - name: Checkout repository - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -28,12 +28,11 @@ jobs: sudo apt-get install debconf-utils sudo debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Local only'" sudo debconf-set-selections <<< "postfix postfix/mailname string localhost" - sudo apt-get install -y mailutils ruby ruby-dev rubygems build-essential sudo gnupg python-gpg libgpgme-dev swig - python -m pip install --upgrade pip - pip install -r requirements_gpg.txt + sudo apt-get install -y mailutils ruby ruby-dev rubygems build-essential sudo gnupg python3-gpg libgpgme-dev tox sudo gem install --no-document fpm + python -m pip install --upgrade pip - name: Test - run: python -m pytest tests/ + run: tox - name: Build deb package run: ./fpm/create - name: End to end test using deb package diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0dec8d8..b9a4b93 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,10 +12,9 @@ If you want to contribute, please: You will need the following development dependencies. * Packages: - * Arch Linux: `pacman -S python-gpgme` - * Debian/Ubuntu: `apt-get install libgpgme-dev` - * Fedora: `yum install gpgme-devel python-devel python3-devel` -* Python eggs: `pip install -r requirements.txt` + * Arch Linux: `pacman -S python-gpgme python-tox` + * Debian/Ubuntu: `apt-get install python3-gpg libgpgme-dev tox` + * Fedora: `yum install python3-devel gpgme-devel tox` ## Testing diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 04b367f..0000000 --- a/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -pygpgme -six>=1.12.0 -pytest>=4.1.0 -pytest-cov>=2.6.1 -mock>=2.0.0 -coverage>=4.5.2 -tox>=3.6.1 -pycodestyle>=2.4.0 -pylint>=1.6.4 diff --git a/tests/test_zeyple.py b/tests/test_zeyple.py index 72d0f6e..6e6a0b9 100644 --- a/tests/test_zeyple.py +++ b/tests/test_zeyple.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from six.moves.configparser import ConfigParser +from configparser import ConfigParser from textwrap import dedent from unittest.mock import Mock from zeyple import zeyple @@ -22,6 +22,7 @@ TEST_EXPIRED_ID = 'ED97E21F1C7F1AC6' TEST_EXPIRED_EMAIL = 'test_expired@zeyple.example.com' + class ZeypleTest(unittest.TestCase): def setUp(self): self.tmpdir = tempfile.mkdtemp() @@ -71,18 +72,19 @@ def assertValidMimeMessage(self, cipher_message, mime_message): plain_payload = cipher_message.get_payload() encrypted_envelope = plain_payload[1] - assert encrypted_envelope["Content-Type"] == 'application/octet-stream; name="encrypted.asc"' + assert (encrypted_envelope["Content-Type"] == + 'application/octet-stream; name="encrypted.asc"') encrypted_payload = encrypted_envelope.get_payload().encode('utf-8') decrypted_envelope = self.decrypt(encrypted_payload).decode('utf-8').strip() - boundary = re.match(r'.+boundary="([^"]+)"', decrypted_envelope, re.MULTILINE | re.DOTALL).group(1) + boundary = re.match(r'.+boundary="([^"]+)"', + decrypted_envelope, re.MULTILINE | re.DOTALL).group(1) # replace auto-generated boundary with one we know mime_message = mime_message.replace("BOUNDARY", boundary) prefix = dedent("""\ - Content-Type: multipart/mixed; boundary=\"""" + \ - boundary + """\" + Content-Type: multipart/mixed; boundary=\"""" + boundary + """\" """) mime_message = prefix + mime_message @@ -237,7 +239,7 @@ def test_process_message_with_complex_message(self): with open(filename, 'r') as test_file: contents = test_file.read() - self.zeyple.process_message(contents, [TEST1_EMAIL]) # should not raise + self.zeyple.process_message(contents, [TEST1_EMAIL]) # should not raise def test_force_encryption(self): """Tries to encrypt without key""" diff --git a/tox.ini b/tox.ini index 3796438..e308ea7 100644 --- a/tox.ini +++ b/tox.ini @@ -4,9 +4,15 @@ skip_missing_interpreters = True skipsdist = True [testenv] -deps = -rrequirements.txt +deps = + mock + pycodestyle + pytest + pytest-cov + setuptools +sitepackages = True setenv = PYTHONPATH = {toxinidir} commands = - pycodestyle --show-pep8 zeyple - py.test {posargs:--cov-report=html --cov=zeyple/} + python -m pytest --cov=zeyple/ --cov-report=html + pycodestyle --show-pep8 --max-line-length=100