Add GitHub Actions test workflow.

This commit is contained in:
Jannis Leidel 2020-12-22 21:38:14 +01:00
parent 384e7c5b13
commit f33511375f
No known key found for this signature in database
GPG key ID: C795956FB489DCA9
6 changed files with 137 additions and 133 deletions

52
.github/workflows/test.yml vendored Normal file
View file

@ -0,0 +1,52 @@
name: Test
on: [push, pull_request]
jobs:
build:
name: build (Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 5
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9']
django-version: ['2.2', '3.0', '3.1', 'master']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ matrix.python-version }}-v1-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox tox-gh-actions
- name: Tox tests
run: |
tox -v
env:
DJANGO: ${{ matrix.django-version }}
- name: Upload coverage
uses: codecov/codecov-action@v1
with:
name: Python ${{ matrix.python-version }}

View file

@ -6,7 +6,7 @@ force_grid_wrap=0
line_length=88
combine_as_imports=True
# List sections with django and
# List sections with django and
known_django=django
known_downloadview=django_downloadview

View file

@ -92,12 +92,6 @@ demo:
runserver: demo
demo runserver
#: release - Tag and push to PyPI.
.PHONY: release
release:
$(TOX) -e release
.PHONY: black
black:
$(BLACK) demo tests django_downloadview

View file

@ -2,6 +2,7 @@
"""django-downloadview documentation build configuration file."""
import os
import re
from pkg_resources import get_distribution
# Minimal Django settings. Required to use sphinx.ext.autodoc, because
# django-downloadview depends on Django...
@ -45,14 +46,11 @@ author_slug = re.sub(r"([\w_.-]+)", "-", author)
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
configuration_dir = os.path.dirname(__file__)
documentation_dir = configuration_dir
version_file = os.path.normpath(os.path.join(documentation_dir, "../VERSION"))
# The full version, including alpha/beta/rc tags.
release = open(version_file).read().strip()
release = get_distribution("django-downloadview").version
# The short X.Y version.
version = ".".join(release.split(".")[0:1])
version = '.'.join(release.split('.')[:2])
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

150
setup.py
View file

@ -1,98 +1,64 @@
#!/usr/bin/env python
"""Python packaging."""
# -*- coding: utf-8 -*-
import os
import sys
from setuptools import setup
from setuptools.command.test import test as TestCommand
class Tox(TestCommand):
"""Test command that runs tox."""
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
import tox # import here, cause outside the eggs aren't loaded.
errno = tox.cmdline(self.test_args)
sys.exit(errno)
#: Absolute path to directory containing setup.py file.
here = os.path.abspath(os.path.dirname(__file__))
NAME = "django-downloadview"
DESCRIPTION = "Serve files with Django and reverse-proxies."
README = open(os.path.join(here, "README.rst")).read()
VERSION = open(os.path.join(here, "VERSION")).read().strip()
AUTHOR = "Benoît Bryon"
EMAIL = "benoit@marmelune.net"
LICENSE = "BSD"
URL = "https://{name}.readthedocs.io/".format(name=NAME)
CLASSIFIERS = [
"Development Status :: 5 - Production/Stable",
"Framework :: Django",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
]
KEYWORDS = [
"file",
"stream",
"download",
"FileField",
"ImageField",
"x-accel",
"x-accel-redirect",
"x-sendfile",
"sendfile",
"mod_xsendfile",
"offload",
]
PACKAGES = [NAME.replace("-", "_")]
REQUIREMENTS = [
# BEGIN requirements
"Django>=1.11",
"requests",
"setuptools",
# END requirements
]
ENTRY_POINTS = {}
SETUP_REQUIREMENTS = ["setuptools"]
TEST_REQUIREMENTS = ["tox"]
CMDCLASS = {"test": Tox}
EXTRA_REQUIREMENTS = {
"test": TEST_REQUIREMENTS,
}
if __name__ == "__main__": # Don't run setup() when we import this module.
setup(
name=NAME,
version=VERSION,
description=DESCRIPTION,
long_description=README,
classifiers=CLASSIFIERS,
keywords=" ".join(KEYWORDS),
author=AUTHOR,
author_email=EMAIL,
url=URL,
license=LICENSE,
packages=PACKAGES,
include_package_data=True,
zip_safe=False,
install_requires=REQUIREMENTS,
entry_points=ENTRY_POINTS,
tests_require=TEST_REQUIREMENTS,
cmdclass=CMDCLASS,
setup_requires=SETUP_REQUIREMENTS,
extras_require=EXTRA_REQUIREMENTS,
)
setup(
name="django-downloadview",
use_scm_version={"version_scheme": "post-release"},
setup_requires=["setuptools_scm"],
description="Serve files with Django and reverse-proxies.",
long_description=open(os.path.join(here, "README.rst")).read(),
long_description_content_type='text/x-rst',
classifiers=[
"Development Status :: 5 - Production/Stable",
"Framework :: Django",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
],
keywords=" ".join(
[
"file",
"stream",
"download",
"FileField",
"ImageField",
"x-accel",
"x-accel-redirect",
"x-sendfile",
"sendfile",
"mod_xsendfile",
"offload",
]
),
author="Benoît Bryon",
author_email="benoit@marmelune.net",
url="https://django-downloadview.readthedocs.io/",
license="BSD",
packages=[
"django_downloadview",
"django_downloadview.apache",
"django_downloadview.lighttpd",
"django_downloadview.nginx",
"django_downloadview.views",
],
include_package_data=True,
zip_safe=False,
install_requires=[
# BEGIN requirements
"Django>=1.11",
"requests",
"setuptools",
# END requirements
],
extras_require={
"test": ["tox"],
},
)
s

52
tox.ini
View file

@ -1,34 +1,39 @@
[tox]
envlist = py{36,37,38,39}-django{22,30,31},
flake8, sphinx, readme
envlist =
py{36,37,38,39}-dj{22,30,31}
lint
sphinx
readme
[travis]
python=
3.8: py38, flake8, sphinx, readme
[gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38, lint, sphinx, readme
3.9: py39
[testenv]
deps =
coverage
django22: Django>=2.2,<3.0
django30: Django>=3.0,<3.1
django31: Django>=3.1,<3.2
dj22: Django>=2.2,<3.0
dj30: Django>=3.0,<3.1
dj31: Django>=3.1,<3.2
nose
py27: mock
commands =
pip install -e .
pip install -e demo
python -Wd {envbindir}/demo test --cover-package=django_downloadview --cover-package=demoproject {posargs: tests demoproject}
pip freeze
[testenv:flake8]
[testenv:lint]
deps =
flake8
black
isort
black
isort
commands =
flake8 demo django_downloadview tests
black --check demo django_downloadview tests
isort --check-only --recursive demo django_downloadview tests
black --check demo django_downloadview tests
isort --check-only --recursive demo django_downloadview tests
[testenv:sphinx]
deps =
@ -40,22 +45,11 @@ whitelist_externals =
make
[testenv:readme]
deps =
docutils
pygments
description = Ensure README renders on PyPI
deps = twine
commands =
mkdir -p var/docs
rst2html.py --exit-status=2 README.rst var/docs/README.html
rst2html.py --exit-status=2 CONTRIBUTING.rst var/docs/CONTRIBUTING.html
whitelist_externals =
mkdir
[testenv:release]
deps =
wheel
zest.releaser
commands =
fullrelease
{envpython} setup.py -q sdist bdist_wheel
twine check dist/*
[flake8]
max-line-length = 88