Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start using github actions matrix to run tests instead of tox and add running mypy #30

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13.0-rc.1"]
django-version: ["django==4.2.*", "django==5.0.*", "django==5.1.*", "django==5.2.*"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
django-version: ["django==4.2.*", "django==5.0.*", "django==5.1.*"]
exclude:
- python-version: "3.12"
django-version: "django<4.2.8"
- python-version: "3.13.0-rc.1"
django-version: "django<5.2"
- python-version: "3.8"
django-version: "django==5.0.*"
- python-version: "3.8"
django-version: "django==5.1.*"
- python-version: "3.9"
django-version: "django==5.0.*"
- python-version: "3.9"
django-version: "django==5.1.*"

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -29,10 +34,16 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_test.txt
pip install ${{ matrix.django-version }}
echo ${{ matrix.django-version }} >> dj.txt
pip install -c dj.txt -r requirements_test.txt
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
make ruff-check
- name: Run Tox
run: tox
- name: MyPy
run: mypy django_mail_viewer
- name: Run Tests
run: |
coverage run --source django_mail_viewer runtests.py
coverage report
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM python:3.8-bookworm AS dev
ARG PYTHON_VERSION=3.8
ARG DEBIAN_DISTRO=bookworm
FROM python:${PYTHON_VERSION}-${DEBIAN_DISTRO} AS dev
# Dockerfile for running a test django installation
LABEL maintainer="Justin Michalicek <[email protected]>"
ENV PYTHONUNBUFFERED 1
Expand Down
2 changes: 1 addition & 1 deletion django_mail_viewer/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.2.0'
__version__ = "2.2.0"
14 changes: 4 additions & 10 deletions django_mail_viewer/backends/database/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import email.message
import email.utils
import json
from typing import TYPE_CHECKING, Any, Dict, List, Union
from typing import Any, Dict, List, Union

from django.db import models

Expand All @@ -12,7 +12,7 @@ class AbstractBaseEmailMessage(models.Model):
storage for the Message FileField. Once Django 3.1+ only is supported then a callable may be used
rendering this not really necessary.

To customize, subclass this and add a `FileField()` named `serialized_message_file` with the storage you would
To customize, subclass this and add a `FileField()` named `file_attachment` with the storage you would
like to use.
"""

Expand All @@ -30,17 +30,11 @@ class AbstractBaseEmailMessage(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

file_attachment: models.FileField

class Meta:
abstract = True

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

# methods here expect the concrete subclasses to implement the file_attachment field
# should only be necessary until django 2.2 support is dropped... I hope
if TYPE_CHECKING and not hasattr(self, "file_attachment"):
self.file_attachment = models.FileField(blank=True, default="", upload_to="mailviewer_attachments")

# I really only need/use get_filename(), get_content_type(), get_payload(), walk()
# returns Any due to failobj
def get(self, attr: str, failobj: Any = None) -> Any:
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[tool.mypy]
plugins = ["mypy_django_plugin.main"]
ignore_missing_imports = true
# for some reason this is not following the ignore of the settings file...
exclude = [
'migrations',
'test_project\/test_project\/settings\.py'
'test_project\/test_project\/settings\.py',
'docs',
]

[tool.django-stubs]
Expand Down
3 changes: 1 addition & 2 deletions requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ flake8
pytest
tox
tox-gh-actions
django-stubs
mypy
django-stubs[compatible-mypy]
typing-extensions
black
ruff
Expand Down
Empty file added test_project/__init__.py
Empty file.
40 changes: 0 additions & 40 deletions tox.ini

This file was deleted.

Loading