Skip to content

Commit 45b1e5d

Browse files
committed
Improve GHA test jobs, move tool config to pyproject.toml (#202)
* Move Tox tool config settings to pyproject.toml * Restore older Bandit version for predictive setup Bandit UX is seriously broken. Unfortunately, only <1.6 works predictably. * Exclude unsupported Python/Django combinations Use a more self-explanatory build job name for tests * Help pytest find the Django test project settings * Use clean range for Django 4.0 * Keep load on the GHA runners low, use newer Python for checks
1 parent 7eb9db3 commit 45b1e5d

File tree

6 files changed

+49
-29
lines changed

6 files changed

+49
-29
lines changed

.bandit

-1
This file was deleted.

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Set up Python
1919
uses: actions/setup-python@v2
2020
with:
21-
python-version: 3.8
21+
python-version: '3.8'
2222

2323
- name: Get pip cache dir
2424
id: pip-cache

.github/workflows/test.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- master
1010

1111
jobs:
12-
build:
12+
python-django:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
max-parallel: 5
@@ -24,6 +24,10 @@ jobs:
2424
- '2.2'
2525
- '3.2'
2626
- '4.0'
27+
exclude:
28+
- { django-version: '2.2', python-version: '3.10' }
29+
- { django-version: '4.0', python-version: '3.6' }
30+
- { django-version: '4.0', python-version: '3.7' }
2731

2832
steps:
2933
- uses: actions/checkout@v2

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/.tox
55
/.coverage
66
/coverage.xml
7+
/tests/reports
78

89
/build
910
/dist

pyproject.toml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[tool.bandit]
2+
# Exclude/ignore of files is currently broken in Bandit.
3+
4+
[tool.black]
5+
color = true
6+
7+
[tool.coverage.xml]
8+
output = "tests/reports/coverage.xml"
9+
10+
[tool.isort]
11+
color_output = true
12+
profile = "black"
13+
14+
[tool.pylint.master]
15+
output-format = "colorized"
16+
17+
[tool.pytest.ini_options]
18+
addopts = "--junitxml=tests/reports/unittests.xml --color=yes --verbose"
19+
DJANGO_SETTINGS_MODULE = "tests.testproject.settings"

tox.ini

+23-26
Original file line numberDiff line numberDiff line change
@@ -17,48 +17,32 @@ deps =
1717
pytest-django
1818
django22: Django>=2.2,<3.0
1919
django32: Django>=3.2,<4.0
20-
django40: Django>=4.0a1,<4.1
21-
20+
django40: Django>=4.0,<4.1
2221
commands =
2322
coverage run -m pytest
2423
coverage xml
2524

26-
[gh-actions]
27-
python =
28-
3.6: py36
29-
3.7: py37
30-
3.8: py38
31-
3.9: py39
32-
3.10: py310
33-
34-
[gh-actions:env]
35-
DJANGO =
36-
2.2: django22
37-
3.2: django32
38-
4.0: django40
39-
4025
[testenv:bandit]
4126
description = PyCQA security linter
4227
deps = bandit<1.6
43-
commands = - bandit -r --ini tox.ini
44-
ignore_errors = true
28+
commands = -bandit --ini tox.ini {posargs:-r .}
4529

4630
[testenv:docs]
4731
description = Build the HTML documentation
4832
deps = sphinx
4933
commands = sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html
50-
whitelist_externals = make
34+
allowlist_externals = make
5135

5236
[testenv:flake8]
5337
description = Static code analysis and code style
5438
deps = flake8
55-
commands = flake8
39+
commands = flake8 {posargs}
5640

5741
[testenv:isort]
58-
description = Ensure imports are ordered
42+
description = Ensure imports are ordered consistently
43+
deps = isort[colors]
44+
commands = isort --check-only --diff {posargs:analytical setup.py tests}
5945
skip_install = True
60-
deps = isort
61-
commands = isort tests setup.py analytical --check --diff
6246

6347
[testenv:readme]
6448
description = Ensure README renders on PyPI
@@ -73,13 +57,26 @@ deps = pyclean
7357
commands =
7458
pyclean -v {toxinidir}
7559
rm -rf .tox/ build/ dist/ django_analytical.egg-info/ .coverage coverage.xml
76-
whitelist_externals =
60+
allowlist_externals =
7761
rm
7862

7963
[bandit]
80-
exclude = .cache,.git,.tox,build,dist,docs,tests
81-
targets = .
64+
exclude = .git,.github,.tox,build,dist,docs,tests
8265

8366
[flake8]
8467
exclude = .cache,.git,.tox,build,dist
8568
max-line-length = 100
69+
70+
[gh-actions]
71+
python =
72+
3.6: py36
73+
3.7: py37
74+
3.8: py38
75+
3.9: py39
76+
3.10: py310
77+
78+
[gh-actions:env]
79+
DJANGO =
80+
2.2: django22
81+
3.2: django32
82+
4.0: django40

0 commit comments

Comments
 (0)