Skip to content

adjust GitHub actions to test Django versions #7910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 43 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,36 @@ on:

jobs:
tests:
name: Python ${{ matrix.python-version }}
name: Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}
runs-on: ubuntu-20.04

strategy:
fail-fast: false
matrix:
django-version:
- '3.1'
- '3.2'
python-version:
- '3.6'
- '3.7'
- '3.8'
- '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:
- uses: actions/checkout@v2

Expand All @@ -33,25 +52,33 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-

- name: Upgrade packaging tools
run: python -m pip install --upgrade pip setuptools virtualenv wheel

- name: Install dependencies
run: python -m pip install --upgrade codecov tox

- name: Run tox targets for ${{ matrix.python-version }}
run: |
ENV_PREFIX=$(tr -C -d "0-9" <<< "${{ matrix.python-version }}")
TOXENV=$(tox --listenvs | grep "^py$ENV_PREFIX" | tr '\n' ',') tox
Comment on lines -44 to -45
Copy link
Contributor Author

@terencehonles terencehonles Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be filled in by tox-gh-actions and with ymyzk/tox-gh-actions#60 it could specify everything.

python -m pip install --upgrade pip setuptools virtualenv wheel
python -m pip install --upgrade codecov tox tox-gh-actions

- name: Run extra tox targets
if: ${{ matrix.python-version == '3.9' }}
- name: Run tox
run: |
python setup.py bdist_wheel
rm -r djangorestframework.egg-info # see #6139
tox -e base,dist,docs
tox -e dist --installpkg ./dist/djangorestframework-*.whl
Comment on lines -50 to -53
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be no longer needed

TOX_EXIT=0
tox || TOX_EXIT=$?

if [[ $DJANGO == '3.2' && ${{ matrix.python-version }} == '3.9' ]]; then
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be done as before, but I believe it would not be run if the first fails. This should allow both to run and report an error if either fails.

# 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_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
run: |
codecov -e TOXENV,DJANGO
codecov -e DJANGO
env:
DJANGO: ${{ matrix.django-version }}
2 changes: 1 addition & 1 deletion tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,7 @@ class TestNaiveDayLightSavingTimeTimeZoneDateTimeField(FieldValues):
}
outputs = {}

class MockTimezone:
class MockTimezone(pytz.BaseTzInfo):
@staticmethod
def localize(value, is_dst):
raise pytz.InvalidTimeError()
Expand Down
12 changes: 10 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ envlist =
{py38,py39}-djangomain,
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 =
2.2: django22
3.0: django30
3.1: django31
3.2: django32
main: djangomain
Expand Down