Skip to content

Commit

Permalink
Fix GitHub workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
infertux committed Sep 9, 2024
1 parent c1c184a commit 3d86702
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 30 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/zeyple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,12 +28,12 @@ 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
sudo gem install --no-document fpm
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade tox
- name: Test
run: python -m pytest tests/
run: tox
- name: Build deb package
run: ./fpm/create
- name: End to end test using deb package
Expand Down
7 changes: 3 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 tox`
* Fedora: `yum install python3-devel gpgme-devel tox`

## Testing

Expand Down
9 changes: 0 additions & 9 deletions requirements.txt

This file was deleted.

14 changes: 8 additions & 6 deletions tests/test_zeyple.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -22,6 +22,7 @@
TEST_EXPIRED_ID = 'ED97E21F1C7F1AC6'
TEST_EXPIRED_EMAIL = '[email protected]'


class ZeypleTest(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.mkdtemp()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"""
Expand Down
13 changes: 9 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ skip_missing_interpreters = True
skipsdist = True

[testenv]
deps = -rrequirements.txt
deps =
mock
pycodestyle
pytest
pytest-cov
setenv =
PYTHONPATH = {toxinidir}
PYTHONPATH = {toxinidir}:/usr/lib/python3.12/site-packages/:/usr/lib/python3/dist-packages/
list_dependencies_command = python -m pip list
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

0 comments on commit 3d86702

Please sign in to comment.