diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c2f7a24 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Release + +on: + push: + tags: + - '*' + +jobs: + build: + if: github.repository == 'jazzband/django-floppyforms' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + python -m pip install -U pip + python -m pip install -U setuptools twine wheel + + - name: Build package + run: | + python setup.py --version + python setup.py sdist --format=gztar bdist_wheel + twine check dist/* + + - name: Upload packages to Jazzband + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + user: jazzband + password: ${{ secrets.JAZZBAND_RELEASE_KEY }} + repository_url: https://jazzband.co/projects/django-floppyforms/upload diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..bf1207f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,53 @@ +name: Test + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 5 + matrix: + python-version: ['3.6', '3.7', '3.8', '3.9'] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install GIS dependencies + run: | + sudo apt-get -q -y update + sudo apt-get -q -y install binutils gdal-bin libproj-dev libgeos-c1v5 + + - 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') }}-${{ hashFiles('**/tox.ini') }} + restore-keys: | + ${{ matrix.python-version }}-v1- + + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade tox tox-gh-actions + + - name: Tox tests + run: | + tox -v + + - name: Upload coverage + uses: codecov/codecov-action@v1 + with: + name: Python ${{ matrix.python-version }} diff --git a/.gitignore b/.gitignore index 803b1f0..7a12274 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ __pycache__ .mypy_cache # PyCharm IDE files .idea/ +coverage.xml diff --git a/README.rst b/README.rst index ef0def1..52c4c92 100644 --- a/README.rst +++ b/README.rst @@ -5,9 +5,13 @@ django-floppyforms :target: https://jazzband.co/ :alt: Jazzband -.. image:: https://api.travis-ci.org/jazzband/django-floppyforms.png - :alt: Build Status - :target: https://travis-ci.org/jazzband/django-floppyforms +.. image:: https://github.com/jazzband/django-floppyforms/workflows/Test/badge.svg + :target: https://github.com/jazzband/django-floppyforms/actions + :alt: GitHub Actions + +.. image:: https://codecov.io/gh/jazzband/django-floppyforms/branch/master/graph/badge.svg + :target: https://codecov.io/gh/jazzband/django-floppyforms + :alt: Coverage Full control of form rendering in the templates. diff --git a/runtests.py b/runtests.py deleted file mode 100644 index e11cb43..0000000 --- a/runtests.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python -import argparse -import logging - -import os, sys - -log = logging.getLogger(__name__) - - -os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' - - -# Adding current directory to ``sys.path``. -parent = os.path.dirname(os.path.abspath(__file__)) -sys.path.insert(0, parent) - - -def runtests(*argv): - argv = list(argv) or [ - 'floppyforms', - 'tests', - ] - opts = argparser.parse_args(argv) - - is_py38 = sys.version_info.major == 3 and sys.version_info.minor == 8 - if is_py38: - log.warning("Coverage is currently broken in Python 3.8, coveragfe option ignored") - use_coverage = False - else: - use_coverage = opts.coverage - if use_coverage: - from coverage import coverage - test_coverage = coverage( - branch=True, - source=['floppyforms']) - test_coverage.start() - - # Run tests. - from django.core.management import execute_from_command_line - execute_from_command_line([sys.argv[0], 'test'] + opts.appname) - - if use_coverage: - test_coverage.stop() - - # Report coverage to commandline. - test_coverage.report(file=sys.stdout) - - -argparser = argparse.ArgumentParser(description='Process some integers.') -argparser.add_argument('appname', nargs='*') -argparser.add_argument('--no-coverage', dest='coverage', action='store_const', - const=False, default=True, help='Do not collect coverage data.') - - -if __name__ == '__main__': - runtests(*sys.argv[1:]) diff --git a/requirements/tests.txt b/tests/requirements.txt similarity index 66% rename from requirements/tests.txt rename to tests/requirements.txt index 3bf023f..e139179 100644 --- a/requirements/tests.txt +++ b/tests/requirements.txt @@ -1,6 +1,6 @@ argparse -coverage<6.0 +coverage flake8 django-discover-runner Pillow -pip <= 21 +pip diff --git a/tox.ini b/tox.ini index 00e6205..9380912 100644 --- a/tox.ini +++ b/tox.ini @@ -1,19 +1,29 @@ [tox] minversion = 1.8 envlist = - docs, - flake8, - py36-{22, 30}, - py37-{22, 30}, + docs + checks + py36-{22, 30} + py37-{22, 30} py38-{22, 30} + py39-{22, 30} + +[gh-actions] +python = + 3.6: py36 + 3.7: py37, docs, checks + 3.8: py38 + 3.9: py39 [testenv] deps = - 111: Django >= 1.11, < 2.0 22: Django >= 2.2, < 3.0 30: Django >= 3.0, < 4.0 - -r{toxinidir}/requirements/tests.txt -commands = python runtests.py + -r{toxinidir}/tests/requirements.txt +commands = + coverage run --source=floppyforms --branch {envbindir}/django-admin test --pythonpath=./ --settings=tests.settings + coverage report -m + coverage xml [testenv:docs] changedir = docs @@ -28,4 +38,4 @@ deps = readme_renderer commands = flake8 floppyforms - python setup.py check -r -s \ No newline at end of file + python setup.py check -r -s