Skip to content

Commit 878cf60

Browse files
committed
adjust GitHub actions to test Django versions
1 parent fd017d0 commit 878cf60

File tree

2 files changed

+65
-15
lines changed

2 files changed

+65
-15
lines changed

.github/workflows/main.yml

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,46 @@ on:
88

99
jobs:
1010
tests:
11-
name: Python ${{ matrix.python-version }}
11+
name: Python ${{ matrix.python-version }}, Django ${{ matrix.django-version || 'N/A' }}, TOXENV ${{ matrix.tox-env || 'N/A' }}
1212
runs-on: ubuntu-20.04
1313

1414
strategy:
15+
fail-fast: false
1516
matrix:
17+
django-version:
18+
- '3.1'
19+
- '3.2'
1620
python-version:
1721
- '3.6'
1822
- '3.7'
1923
- '3.8'
2024
- '3.9'
2125

26+
include:
27+
# Old Django LTS only on older Pythons
28+
- django-version: '2.2'
29+
python-version: '3.6'
30+
31+
- django-version: '2.2'
32+
python-version: '3.7'
33+
34+
# Pre-release Django only on new Pythons
35+
- django-version: 'main'
36+
python-version: '3.8'
37+
38+
- django-version: 'main'
39+
python-version: '3.9'
40+
41+
# Explicit tox envs
42+
- python-version: '3.9'
43+
tox-env: 'base'
44+
45+
- python-version: '3.9'
46+
tox-env: 'docs'
47+
48+
- python-version: '3.9'
49+
tox-env: 'dist'
50+
2251
steps:
2352
- uses: actions/checkout@v2
2453

@@ -33,25 +62,38 @@ jobs:
3362
restore-keys: |
3463
${{ runner.os }}-pip-
3564
36-
- name: Upgrade packaging tools
37-
run: python -m pip install --upgrade pip setuptools virtualenv wheel
38-
3965
- name: Install dependencies
40-
run: python -m pip install --upgrade codecov tox
66+
run: |
67+
python -m pip install --upgrade pip setuptools virtualenv wheel
68+
python -m pip install --upgrade codecov tox tox-gh-actions
4169
42-
- name: Run tox targets for ${{ matrix.python-version }}
70+
- name: Run tox
71+
if: ${{ matrix.tox-env == null }}
4372
run: |
44-
ENV_PREFIX=$(tr -C -d "0-9" <<< "${{ matrix.python-version }}")
45-
TOXENV=$(tox --listenvs | grep "^py$ENV_PREFIX" | tr '\n' ',') tox
73+
tox
74+
env:
75+
DJANGO: ${{ matrix.django-version }}
4676

77+
# This would not be needed after https://github.com/ymyzk/tox-gh-actions/pull/60
78+
# but it may need adjustment for --installpkg
4779
- name: Run extra tox targets
48-
if: ${{ matrix.python-version == '3.9' }}
80+
if: ${{ matrix.tox-env != null }}
4981
run: |
50-
python setup.py bdist_wheel
51-
rm -r djangorestframework.egg-info # see #6139
52-
tox -e base,dist,docs
53-
tox -e dist --installpkg ./dist/djangorestframework-*.whl
82+
ARGS=()
83+
if [[ $TOXENV == 'dist' ]]; then
84+
# see https://github.com/encode/django-rest-framework/pull/6139
85+
python setup.py bdist_wheel
86+
rm -r djangorestframework.egg-info
87+
ARGS=(--installpkg ./dist/djangorestframework-*.whl)
88+
fi
89+
90+
tox "${ARGS[@]}"
91+
env:
92+
TOXENV: ${{ matrix.tox-env }}
5493

5594
- name: Upload coverage
5695
run: |
5796
codecov -e TOXENV,DJANGO
97+
env:
98+
DJANGO: ${{ matrix.django-version }}
99+
TOXENV: ${{ matrix.tox-env }}

tox.ini

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,18 @@ envlist =
77
{py38,py39}-djangomain,
88
base,dist,docs,
99

10-
[travis:env]
10+
[gh-actions]
11+
python =
12+
3.6: py36
13+
3.7: py37
14+
3.8: py38
15+
3.9: py39
16+
# This needs https://github.com/ymyzk/tox-gh-actions/pull/60
17+
# 3.9: py39,base,dist,docs
18+
19+
[gh-actions:env]
1120
DJANGO =
1221
2.2: django22
13-
3.0: django30
1422
3.1: django31
1523
3.2: django32
1624
main: djangomain

0 commit comments

Comments
 (0)