Merge pull request #169 from jazzband/gha

Add initial GitHub Actions workflow.
This commit is contained in:
Jannis Leidel 2020-11-25 21:47:50 +01:00 committed by GitHub
commit 98e7e24e3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 122 additions and 92 deletions

53
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,53 @@
name: Release
on:
push:
tags:
- '*'
jobs:
build:
if: github.repository == 'jazzband/django-analytical'
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: 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: release-${{ hashFiles('**/setup.py') }}
restore-keys: |
release-
- 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-analytical/upload

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

@ -0,0 +1,47 @@
name: Test
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 5
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
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
- name: Upload coverage
uses: codecov/codecov-action@v1
with:
name: Python ${{ matrix.python-version }}

View file

@ -1,55 +0,0 @@
os: linux
dist: xenial
language: python
python:
- 3.4
- 3.5
- 3.6
- 3.7
- 3.8
env:
- DJANGO=1.11
- DJANGO=2.2
- DJANGO=3.0
install:
- pip install tox-travis
script:
- tox
stages:
- lint
- test
- deploy
jobs:
allow_failures:
- env: TOXENV=bandit
exclude:
# Python/Django combinations that aren't officially supported
- { stage: test, python: 3.4, env: DJANGO=2.2 }
- { stage: test, python: 3.4, env: DJANGO=3.0 }
- { stage: test, python: 3.5, env: DJANGO=3.0 }
- { stage: test, python: 3.8, env: DJANGO=1.11 }
include:
- { stage: lint, python: 3.7, env: TOXENV=flake8 }
- { stage: lint, python: 3.7, env: TOXENV=bandit }
- { stage: lint, python: 3.7, env: TOXENV=readme }
- { stage: test, python: 2.7, env: DJANGO=1.11 }
- stage: deploy
if: tag is present
deploy:
provider: pypi
server: https://jazzband.co/projects/django-analytical/upload
distributions: sdist bdist_wheel
username: jazzband
password:
secure: JCr5hRjAeXuiISodCJf8HWd4BTJMpl2eiHI8NciPaSM9WwOOeUXxmlcP8+lWlXxgM4BYUC/O7Q90fkwj5x06n+z4oyJSEVerTvCDcpeZ68KMMG1tR1jTbHcxfEKoEvcs2J0fThJ9dIMtfbtUbIpzusJHkZPjsIy8HAJDw8knnJs=
on:
tags: true
repo: jazzband/django-analytical
env:
install: skip
script: skip
python: 3.7

View file

@ -26,12 +26,12 @@ an asynchronous version of the Javascript code if possible.
.. |latest-version| image:: https://img.shields.io/pypi/v/django-analytical.svg
:alt: Latest version on PyPI
:target: https://pypi.org/project/django-analytical/
.. |build-status| image:: https://img.shields.io/travis/jazzband/django-analytical/master.svg
:alt: Build status
:target: https://travis-ci.org/jazzband/django-analytical
.. |coverage| image:: https://img.shields.io/coveralls/github/jazzband/django-analytical/master.svg
.. |build-status| image:: https://github.com/jazzband/django-analytical/workflows/Test/badge.svg
:target: https://github.com/jazzband/django-analytical/actions
:alt: GitHub Actions
.. |coverage| image:: https://codecov.io/gh/jazzband/django-analytical/branch/master/graph/badge.svg
:alt: Test coverage
:target: https://coveralls.io/r/jazzband/django-analytical
:target: https://codecov.io/gh/jazzband/django-analytical
.. |python-support| image:: https://img.shields.io/pypi/pyversions/django-analytical.svg
:target: https://pypi.org/project/django-analytical/
:alt: Python versions

49
tox.ini
View file

@ -1,69 +1,54 @@
[tox]
envlist =
# Python/Django combinations that are officially supported
py{27,34,35,36,37}-django111
py{27,35,36,37}-django111
py{35,36,37,38}-django22
py{36,37,38}-django30
flake8
bandit
readme
docs
clean
py37-{flake8,bandit,readme,docs}
[testenv]
description = Unit tests
deps =
coverage
coveralls
django111: Django>=1.11,<2.0
django22: Django>=2.2,<3.0
django30: Django>=3.0,<3.1
commands =
coverage run setup.py test
sh -c 'coveralls | true'
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
whitelist_externals = sh
coverage xml
[testenv:bandit]
[gh-actions]
python =
2.7: py27
3.5: py35
3.6: py36
3.7: py37
3.8: py38
[testenv:py37-bandit]
description = PyCQA security linter
deps = bandit<1.6
commands = bandit -r --ini tox.ini
commands = - bandit -r --ini tox.ini
ignore_errors = true
[testenv:clean]
description = Clean up bytecode and build artifacts
deps =
commands =
rm -rf .tox/ django_analytical.egg-info/ build/ dist/ docs/_build/
find {toxinidir} -type f -name '*.pyc' -delete
find {toxinidir} -type d -name '__pycache__' -delete
whitelist_externals =
find
rm
[testenv:docs]
[testenv:py37-docs]
description = Build the HTML documentation
deps = sphinx
commands = sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html
whitelist_externals = make
[testenv:flake8]
[testenv:py37-flake8]
description = Static code analysis and code style
deps = flake8
commands = flake8
[testenv:readme]
[testenv:py37-readme]
description = Ensure README renders on PyPI
deps = twine
commands =
{envpython} setup.py -q sdist bdist_wheel
twine check dist/*
[travis:env]
DJANGO =
1.11: django111
2.2: django22
3.0: django30
[bandit]
exclude = .cache,.git,.tox,build,dist,docs,tests
targets = .