Skip to content

Commit

Permalink
ci: Add testing for django 5.0 and django main (#566)
Browse files Browse the repository at this point in the history
* ci: Improving tox workflow and updating test versions

* build: Update classifiers

* fix: Don't filter favs with unsaved (playground) queries

* ci: Update github actions to run tox

* fix: Change job name

* fix: Adjust coverage path

* fix: Remove coverage reporting from tox

---------

Co-authored-by: Mark Walker <[email protected]>
  • Loading branch information
chrisclark and marksweb authored Dec 26, 2023
1 parent 65a99d3 commit 5d2448b
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 122 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ jobs:
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
143 changes: 53 additions & 90 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,116 +1,79 @@
name: Tests

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

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true


jobs:
unit-tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
django-version: ['3.2', '4.0', '4.1', '4.2b1']
os: [
ubuntu-20.04,
]
exclude:
- python-version: '3.11'
django-version: '3.2'
- python-version: '3.11'
django-version: '4.0'
env:
ENABLE_TASKS: no
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/base.txt
pip install Django==${{ matrix.django-version }}
python setup.py install
- name: Run tests
run: coverage run --source=explorer manage.py test
tests:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-22.04

- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3

unit-tests-with-optional-packages:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
django-version: ['3.2', '4.0', '4.1', '4.2b1']
os: [
ubuntu-20.04,
]
exclude:
- python-version: '3.11'
django-version: '3.2'
- python-version: '3.11'
django-version: '4.0'
env:
ENABLE_TASKS: yes
python-version:
- '3.10'
- '3.11'
- '3.12'

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/base.txt
pip install -r requirements/optional.txt
pip install Django==${{ matrix.django-version }}
python setup.py install
- name: Run tests
run: coverage run --source=explorer manage.py test
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade 'tox>=4.0.0rc3'
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
- name: Run tox targets for ${{ matrix.python-version }}
run: tox run -f py$(echo ${{ matrix.python-version }} | tr -d .)

unit-tests-future-versions:
# Runs for all Django/Python versions which are not yet supported
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11']
django-version: [
'https://github.com/django/django/archive/main.tar.gz'
]
os: [
ubuntu-20.04,
]
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-data-${{ matrix.python-version }}
path: '${{ github.workspace }}/.coverage*'

coverage:
name: Coverage
runs-on: ubuntu-22.04
needs: tests
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}

uses: actions/setup-python@v5
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ${{ matrix.django-version }} coverage
python setup.py install
run: python -m pip install --upgrade coverage[toml]

- name: Download data
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}
pattern: coverage-data-*
merge-multiple: true

- name: Run coverage
run: coverage run --source=explorer manage.py test
continue-on-error: true
- name: Combine coverage
run: |
python -m coverage combine
python -m coverage html --skip-covered --skip-empty
python -m coverage report
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
- name: Upload HTML report
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: html-report
path: htmlcov
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/build
*#
*~
.coverage
.coverage*
/htmlcov/
*.orig
tmp
Expand Down
2 changes: 1 addition & 1 deletion explorer/views/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def query_viewmodel(request, query, title=None, form=None, message=None,

user = request.user
is_favorite = False
if user.is_authenticated:
if user.is_authenticated and query.pk:
is_favorite = QueryFavorite.objects.filter(user=user, query=query).exists()

ret = {
Expand Down
3 changes: 0 additions & 3 deletions requirements/django-3.2.txt

This file was deleted.

3 changes: 0 additions & 3 deletions requirements/django-4.0.txt

This file was deleted.

3 changes: 0 additions & 3 deletions requirements/django-4.1.txt

This file was deleted.

2 changes: 2 additions & 0 deletions requirements/optional.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-r base.txt

importlib-metadata<5.0; python_version <= '3.7'
celery>=4.0
boto3>=1.20.0
Expand Down
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,19 @@ def read(fname):
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Topic :: Utilities',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Django :: 4.1',
'Framework :: Django :: 4.2',
'Framework :: Django :: 5.0',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3 :: Only',
],
python_requires='>=3.8',
install_requires=[
'Django>=3.2.12',
'Django>=3.2',
'sqlparse>=0.4.0',
],
extras_require={
Expand Down
19 changes: 7 additions & 12 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,22 @@
envlist =
flake8
isort
py{38,39,310}-dj{32,40,41,42}
py{310,311}-dj{41,42,main}
{base-reqs,optional}-py{310,311,312}-dj{42,50}
{base-reqs,optional}-py{311,312}-dj{50,main}

skip_missing_interpreters=True

[testenv]
allowlist_externals = coverage
deps =
-r{toxinidir}/requirements/base.txt
-r{toxinidir}/requirements/optional.txt
dj32: Django>=3.2,<3.3
dj40: Django>=4.0,<4.1
dj41: Django>=4.1,<4.2
dj42: Django>=4.2b1,<4.3
base-reqs: -r requirements/base.txt
dj42: django>=4.2,<5.0
dj50: django>=5.0,<5.1
djmain: https://github.com/django/django/archive/main.tar.gz
optional: -r requirements/optional.txt
commands =
{envpython} --version
{env:COMMAND:coverage} erase
{env:COMMAND:coverage} run manage.py test
{env:COMMAND:coverage} combine
{env:COMMAND:coverage} html --skip-covered --skip-empty
{env:COMMAND:coverage} report
ignore_outcome =
djmain: True
ignore_errors =
Expand Down

0 comments on commit 5d2448b

Please sign in to comment.