adjust GitHub actions to test Django versions

This commit is contained in:
Terence D. Honles 2021-04-06 18:57:27 -07:00
parent 22dd853bda
commit 475bfc435f
2 changed files with 53 additions and 18 deletions

View File

@ -8,17 +8,36 @@ on:
jobs: jobs:
tests: tests:
name: Python ${{ matrix.python-version }} name: Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy: strategy:
fail-fast: false
matrix: matrix:
django-version:
- '3.1'
- '3.2'
python-version: python-version:
- '3.6' - '3.6'
- '3.7' - '3.7'
- '3.8' - '3.8'
- '3.9' - '3.9'
include:
# Old Django LTS only on older Pythons
- django-version: '2.2'
python-version: '3.6'
- django-version: '2.2'
python-version: '3.7'
# Pre-release Django only on new Pythons
- django-version: 'main'
python-version: '3.8'
- django-version: 'main'
python-version: '3.9'
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -33,25 +52,33 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-pip- ${{ runner.os }}-pip-
- name: Upgrade packaging tools
run: python -m pip install --upgrade pip setuptools virtualenv wheel
- name: Install dependencies - name: Install dependencies
run: python -m pip install --upgrade codecov tox
- name: Run tox targets for ${{ matrix.python-version }}
run: | run: |
ENV_PREFIX=$(tr -C -d "0-9" <<< "${{ matrix.python-version }}") python -m pip install --upgrade pip setuptools virtualenv wheel
TOXENV=$(tox --listenvs | grep "^py$ENV_PREFIX" | tr '\n' ',') tox python -m pip install --upgrade codecov tox tox-gh-actions
- name: Run extra tox targets - name: Run tox
if: ${{ matrix.python-version == '3.9' }}
run: | run: |
python setup.py bdist_wheel TOX_EXIT=0
rm -r djangorestframework.egg-info # see #6139 tox || TOX_EXIT=$?
if [[ $DJANGO == '3.2' && ${{ matrix.python-version }} == '3.9' ]]; then
# Run extra tox targets
# This would not be needed after https://github.com/ymyzk/tox-gh-actions/pull/60
tox -e base,dist,docs tox -e base,dist,docs
tox -e dist --installpkg ./dist/djangorestframework-*.whl TOX_EXTRA_EXIT=$?
if [[ $TOX_EXIT == 0 ]]; then
TOX_EXIT=$TOX_EXTRA_EXIT
fi
fi
exit $TOX_EXIT
env:
DJANGO: ${{ matrix.django-version }}
- name: Upload coverage - name: Upload coverage
run: | run: |
codecov -e TOXENV,DJANGO codecov -e DJANGO
env:
DJANGO: ${{ matrix.django-version }}

12
tox.ini
View File

@ -7,10 +7,18 @@ envlist =
{py38,py39}-djangomain, {py38,py39}-djangomain,
base,dist,docs, base,dist,docs,
[travis:env] [gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38
3.9: py39
# This needs https://github.com/ymyzk/tox-gh-actions/pull/60
# 3.9: py39,base,dist,docs
[gh-actions:env]
DJANGO = DJANGO =
2.2: django22 2.2: django22
3.0: django30
3.1: django31 3.1: django31
3.2: django32 3.2: django32
main: djangomain main: djangomain