Skip to content

Commit

Permalink
Update GitHub Actions migration to match other Jazzband projects. (#769)
Browse files Browse the repository at this point in the history
* Update test workflow to match other Jazzband projects.

- adds caching
- splits test matrix by django version
- drop support for Python 3.5 (EOL)

* Add release workflow.

* Rename workflow file to match Jazzband defaults.

* Minor change to trigger GHA.

* Remove run limit.
  • Loading branch information
jezdez authored Jan 2, 2021
1 parent faed6d5 commit 60beaf4
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 29 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release

on:
push:
tags:
- '*'

jobs:
build:
if: github.repository == 'jazzband/django-simple-history'
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-simple-history/upload
60 changes: 42 additions & 18 deletions .github/workflows/build.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
name: build
name: Test

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
on: [push, pull_request]

jobs:
build:
name: python ${{ matrix.python-version }}
name: build (Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }})
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9']
django-version: ['2.2', '3.0', '3.1', 'dev']

services:

postgres:
image: postgres:latest
env:
Expand All @@ -22,6 +25,7 @@ jobs:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

mysql:
image: mysql:latest
env:
Expand All @@ -30,6 +34,7 @@ jobs:
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

mariadb:
image: mariadb:latest
env:
Expand All @@ -39,21 +44,40 @@ jobs:
- 3307:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
- name: set up Python ${{ matrix.python-version }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: install dependencies

- 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 dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements/tox.txt
- name: run tox
run: tox
- name: publish coverage
python -m pip install --upgrade pip
python -m pip install -r requirements/tox.txt
- 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 }}
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@
"Framework :: Django :: 3.0",
"Framework :: Django :: 3.1",
"Programming Language :: Python",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"License :: OSI Approved :: BSD License",
],
python_requires=">=3.5",
python_requires=">=3.6",
include_package_data=True,
)
21 changes: 12 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
[tox]
envlist =
py{35,36,37,38,39}-django22-{sqlite3,postgres,mysql},
py{36,37,38,39}-django30-{sqlite3,postgres,mysql,mariadb},
py{36,37,38,39}-django31-{sqlite3,postgres,mysql,mariadb},
py{36,37,38,39}-djangodev-{sqlite3,postgres,mysql,mariadb},
py{36,37,38,39}-dj{22,30,31,dev}-{sqlite3,postgres,mysql,mariadb},
docs,
lint

[gh-actions]
python =
3.5: py35
3.6: py36
3.7: py37
3.8: py38, docs, lint
3.9: py39

[gh-actions:env]
DJANGO =
2.2: dj22
3.0: dj30
3.1: dj31
dev: djdev

[flake8]
ignore = N802,F401,W503
max-complexity = 10
Expand All @@ -24,10 +27,10 @@ exclude = __init__.py,simple_history/registry_tests/migration_test_app/migration
[testenv]
deps =
-rrequirements/test.txt
django22: Django>=2.2,<2.3
django30: Django>=3.0,<3.1
django31: Django>=3.1,<3.2
djangodev: https://github.com/django/django/tarball/master
dj22: Django>=2.2,<2.3
dj30: Django>=3.0,<3.1
dj31: Django>=3.1,<3.2
djdev: https://github.com/django/django/tarball/master
postgres: -rrequirements/postgres.txt
mysql: -rrequirements/mysql.txt
mariadb: -rrequirements/mysql.txt
Expand Down

0 comments on commit 60beaf4

Please sign in to comment.