-
Notifications
You must be signed in to change notification settings - Fork 112
/
tox.ini
184 lines (157 loc) · 4.73 KB
/
tox.ini
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
[tox]
skipsdist=True
# Run these envs when tox is invoked without -e
envlist=lint, validate-migrations, unittest
[testenv]
# Factored env for running most things with a matrix of Python, Django, and
# Wagtail versions. Configuration of individual top-level factors like lint
# and unittest is done in their respective configuration sections below.
#
# Factors:
# lint: Lint Python files with black, ruff, isort, and run bandit
# unittest: Run Python unittests
#
# These factors are expected to combine into the follow generative environments:
#
# lint
# unittest
#
# These factors are expected to combine to be invoked with:
#
# tox -e lint
# tox -e unittest
recreate=False
allowlist_externals=echo
changedir=
unittest: {[unittest-config]changedir}
basepython=python3.8
deps=
lint: {[lint-config]deps}
unittest: {[unittest-config]deps}
passenv=
unittest: {[unittest-config]passenv}
setenv=
unittest: {[unittest-config]setenv}
commands=
lint: {[lint-config]commands}
unittest: {[unittest-config]commands}
[lint-config]
# Configuration necessary to lint Python files.
# Note: This is not an env and will not run if invoked. Use:
#
# tox -e lint
#
# To run Python linting.
deps=
ruff
bandit[toml]
commands=
ruff format --check
ruff check cfgov
bandit -c "pyproject.toml" -r cfgov
[unittest-config]
# Configuration necessary to run unittests.
# Note: This is not an env and will not run if invoked. Use:
#
# tox -e unittest
#
# To run unit tests.
changedir=
{toxinidir}/cfgov
passenv=
PGUSER, PGPASSWORD, PGDATABASE, PGHOST, PGPORT, ES_HOST, ES_PORT, GITHUB_ACTIONS, SKIP_DJANGO_MIGRATIONS, TEST_RUNNER
setenv=
DJANGO_ADMIN_USERNAME=admin
DJANGO_ADMIN_PASSWORD=admin
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
DJANGO_SETTINGS_MODULE=cfgov.settings.test
deps=
-r{toxinidir}/requirements/libraries.txt
-r{toxinidir}/requirements/django.txt
-r{toxinidir}/requirements/wagtail.txt
-r{toxinidir}/requirements/test.txt
commands=
coverage erase
python -b -m coverage run --source='.' manage.py test {posargs}
## Standalone and user-friendly envs
[testenv:unittest]
# Invoke with: tox -e unittest
recreate=False
deps=
{[unittest-config]deps}
commands={[unittest-config]commands}
[testenv:lint]
# Invoke with: tox -e lint
recreate=False
deps={[lint-config]deps}
commands={[lint-config]commands}
[testenv:validate-assets]
# Invoke with: tox -e validate-assets
# Ensure all assets are generated without error.
recreate=False
changedir={toxinidir}
deps=
{[unittest-config]deps}
setenv=
DJANGO_SETTINGS_MODULE=cfgov.settings.production
DJANGO_STATIC_ROOT={toxinidir}/collectstatic
ALLOWED_HOSTS=["*"]
SECRET_KEY="fake-secret-key"
allowlist_externals=
{toxinidir}/frontend.sh
{toxinidir}/cfgov/manage.py
commands=
{toxinidir}/frontend.sh ci
{toxinidir}/cfgov/manage.py collectstatic --noinput
[testenv:validate-migrations]
# Invoke with: tox -e validate-migrations
# Ensure that we're not missing any migations
recreate=False
changedir={[unittest-config]changedir}
deps=
{[unittest-config]deps}
passenv=
PGUSER, PGPASSWORD, PGDATABASE, PGHOST, PGPORT
setenv=
PGUSER={env:PGUSER:cfpb}
PGPASSWORD={env:PGPASSWORD:cfpb}
PGDATABASE={env:PGDATABASE:cfgov}
PGHOST={env:PGHOST:localhost}
PGPORT={env:PGPORT:5432}
DJANGO_SETTINGS_MODULE=cfgov.settings.production
DJANGO_STATIC_ROOT={toxinidir}/collectstatic
ALLOWED_HOSTS=["*"]
SECRET_KEY="fake-secret-key"
commands=
python manage.py makemigrations --dry-run --check
[testenv:validate-translations]
# Invoke with: tox -e validate-translations
# Ensure that there are no changes to translatable strings that aren't
# contained in the comitted portable object files.
# This ultimate tests whether the generated django.mo file has changed
# (the django.po file will change because it includes the date it was
# generated).
# NOTE: Requires gettext. Will overwrite any existing
# */locale/*/LC_MESSAGES/django.po files.
recreate=False
changedir={[unittest-config]changedir}
deps=
{[unittest-config]deps}
setenv={[unittest-config]setenv}
allowlist_externals=
git
commands=
python manage.py makemessages --all --ignore=tests
python manage.py compilemessages
git diff --quiet */locale/*/LC_MESSAGES/django.mo
[testenv:coverage]
# Invoke with: tox -e coverage
# Report out the coverage of changes on the current branch against the main
# branch. This will fail if the coverage of changes is below 100%. This env
# requires a coverage file and should only be run after unittest
deps=
-r{toxinidir}/requirements/test.txt
commands=
coverage xml
diff-cover coverage.xml --compare-branch=origin/main --fail-under=100