Skip to content

Commit 244b008

Browse files
committed
establish GitHub actions testing with TOX
1 parent c2302df commit 244b008

File tree

5 files changed

+155
-11
lines changed

5 files changed

+155
-11
lines changed

.coveragerc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[run]
2+
omit =
3+
*/virtualenvs/*,
4+
*/migrations/*,
5+
*/site-packages/*
6+
include = import_export_celery/*
7+
plugins =
8+
django_coverage_plugin
9+
branch = True

.github/workflows/linters.yml

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Flake8
1+
name: CI
22

33
on: [push, pull_request]
44

@@ -7,6 +7,87 @@ concurrency:
77
cancel-in-progress: true
88

99
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
services:
14+
postgres:
15+
image: postgres:13
16+
ports:
17+
- 5432:5432
18+
env:
19+
POSTGRES_DB: pguser
20+
POSTGRES_USER: pguser
21+
POSTGRES_PASSWORD: foobar
22+
options: >-
23+
--health-cmd "pg_isready -U pguser"
24+
--health-interval 10s
25+
--health-timeout 5s
26+
--health-retries 5
27+
28+
redis:
29+
image: redis:latest
30+
ports:
31+
- 6379:6379
32+
options: >-
33+
--health-cmd "redis-cli ping"
34+
--health-interval 10s
35+
--health-timeout 5s
36+
--health-retries 5
37+
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
42+
django-version: ["3.2", "4.0", "4.1", "4.2", "5.0", "5.1"]
43+
exclude:
44+
- python-version: "3.8"
45+
django-version: "5.0"
46+
- python-version: "3.8"
47+
django-version: "5.1"
48+
49+
- python-version: "3.9"
50+
django-version: "5.0"
51+
- python-version: "3.9"
52+
django-version: "5.1"
53+
54+
- python-version: "3.11"
55+
django-version: "3.2"
56+
57+
- python-version: "3.12"
58+
django-version: "3.2"
59+
- python-version: "3.12"
60+
django-version: "4.0"
61+
62+
steps:
63+
- uses: actions/checkout@v2
64+
65+
- name: Set up Python ${{ matrix.python-version }}
66+
uses: actions/setup-python@v2
67+
with:
68+
python-version: ${{ matrix.python-version }}
69+
70+
- name: Install dependencies
71+
run: |
72+
python -m pip install --upgrade pip
73+
pip install tox tox-gh-actions
74+
75+
- name: Run Tox
76+
env:
77+
DJANGO_VERSION: ${{ matrix.django-version }}
78+
run: |
79+
PYTHON_VERSION=`echo ${{ matrix.python-version }} | sed 's/\.//'`
80+
DJANGO_VERSION=`echo $DJANGO_VERSION | sed 's/\.//'`
81+
tox -e py${PYTHON_VERSION}-django${DJANGO_VERSION}
82+
83+
# TODO: activate when organization token will be available
84+
# - name: Upload coverage to Codecov
85+
# uses: codecov/codecov-action@v4
86+
# with:
87+
# token: ${{ secrets.CODECOV_TOKEN }}
88+
# files: coverage.xml
89+
# fail_ci_if_error: true
90+
1091
flake8:
1192
name: flake8
1293
runs-on: ubuntu-latest

example/project/settings.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"django.contrib.auth.context_processors.auth",
6868
"django.contrib.messages.context_processors.messages",
6969
],
70+
"debug": DEBUG,
7071
},
7172
},
7273
]
@@ -78,16 +79,24 @@
7879
# Database
7980
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
8081

81-
DATABASES = {
82-
"default": {
83-
"ENGINE": "django.db.backends.postgresql_psycopg2",
84-
"NAME": os.environ.get("DATABASE_NAME", "pguser"),
85-
"USER": os.environ.get("DATABASE_USER", "pguser"),
86-
"PASSWORD": os.environ.get("DATABASE_PASSWORD", "foobar"),
87-
"HOST": os.environ.get("DATABASE_HOST", "postgres"),
88-
"PORT": os.environ.get("DATABASE_PORT", ""),
89-
},
90-
}
82+
if os.environ.get("DATABASE_TYPE") == "sqlite":
83+
DATABASES = {
84+
"default": {
85+
"ENGINE": "django.db.backends.sqlite3",
86+
"NAME": os.environ.get("DATABASE_NAME", os.path.join(BASE_DIR, "db.sqlite3")),
87+
}
88+
}
89+
else:
90+
DATABASES = {
91+
"default": {
92+
"ENGINE": "django.db.backends.postgresql_psycopg2",
93+
"NAME": os.environ.get("DATABASE_NAME", "pguser"),
94+
"USER": os.environ.get("DATABASE_USER", "pguser"),
95+
"PASSWORD": os.environ.get("DATABASE_PASSWORD", "foobar"),
96+
"HOST": os.environ.get("DATABASE_HOST", "postgres"),
97+
"PORT": os.environ.get("DATABASE_PORT", ""),
98+
},
99+
}
91100

92101
STORAGES = {
93102
"IMPORT_EXPORT_CELERY_STORAGE": {

requirements_test.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Django
2+
django-import-export
3+
django-author
4+
html2text
5+
celery
6+
psycopg2-binary
7+
django-admin-smoke-tests

tox.ini

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[tox]
2+
envlist =
3+
py{36,37,38,39,310}-django32
4+
py{38,39,310}-django40
5+
py{38,39,310,311}-django41
6+
py{38,39,310,311,312}-django42
7+
py{310,311,312}-django50
8+
py{310,311,312}-django51
9+
10+
[testenv]
11+
deps =
12+
-rrequirements_test.txt
13+
coverage
14+
django-coverage-plugin
15+
django32: django>=3.2,<3.3
16+
django40: django>=4.0,<4.1
17+
django41: django>=4.1,<4.2
18+
django42: django>=4.2,<4.3
19+
django50: django>=5.0,<5.1
20+
django51: django>=5.1a1,<5.2
21+
22+
setenv =
23+
DATABASE_TYPE=sqlite
24+
REDIS_URL=redis://127.0.0.1:6379/0
25+
26+
allowlist_externals = coverage
27+
28+
test-executable =
29+
python --version
30+
python -c "import django; print(django.get_version())"
31+
pip install -r requirements_test.txt
32+
{envbindir}/python -Wall {envbindir}/coverage run --append
33+
34+
commands =
35+
python example/manage.py migrate
36+
{[testenv]test-executable} example/manage.py test winners
37+
coverage report
38+
coverage xml -o coverage.xml

0 commit comments

Comments
 (0)