forked from canonical/operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtox.ini
More file actions
201 lines (184 loc) · 6.2 KB
/
tox.ini
File metadata and controls
201 lines (184 loc) · 6.2 KB
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# Copyright 2021 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[tox]
skipsdist = True
skip_missing_interpreters = True
envlist = lint, unit
[vars]
# These need to be relative paths because autopep8 doesn't handle absolute
# paths with relative paths in "exclude" correctly.
src_path = ops/
tst_path = test/
all_path = {[vars]src_path} {[vars]tst_path}
testing_src_path = testing/src/scenario/
testing_tst_path = testing/tests/
tracing_tst_path = tracing/test/
examples_path = examples/
[testenv]
runner = uv-venv-lock-runner
setenv =
PY_COLORS=1
passenv =
HOME
PATH
MODEL_SETTINGS
SCENARIO_SKIP_CONSISTENCY_CHECKS
SCENARIO_BARE_CHARM_ERRORS
[testenv:format]
description = Apply coding style standards to code
dependency_groups = lint
commands = ruff format --preview
[testenv:lint]
description = Check code style and type correctness
dependency_groups = lint, unit
commands =
ruff check --preview
ruff format --preview --check
codespell {posargs}
pyright {posargs}
[testenv:py{3.10,3.12,3.14}-unit]
runner = uv-venv-lock-runner
base=unit
[testenv:unit]
description = Run unit tests in parallel without coverage
passenv =
RUN_REAL_PEBBLE_TESTS
PEBBLE
SCENARIO_SKIP_CONSISTENCY_CHECKS
SCENARIO_BARE_CHARM_ERRORS
dependency_groups = unit, xdist
commands =
pytest --doctest-modules -n auto \
--ignore={toxinidir}/docs \
--ignore={toxinidir}/release.py \
--ignore={[vars]tst_path}smoke \
--ignore={[vars]tst_path}integration \
--ignore={[vars]tst_path}benchmark \
--ignore={[vars]testing_tst_path}benchmark \
--ignore={[vars]tracing_tst_path} \
--ignore={[vars]examples_path} \
--ignore={[vars]tst_path}charms \
-v --tb native \
-W 'ignore:Harness is deprecated:PendingDeprecationWarning' {posargs}
[testenv:coverage]
description = Run unit tests with coverage
allowlist_externals = mv
passenv =
RUN_REAL_PEBBLE_TESTS
PEBBLE
SCENARIO_SKIP_CONSISTENCY_CHECKS
SCENARIO_BARE_CHARM_ERRORS
dependency_groups = unit, coverage
commands =
coverage run --source={[vars]src_path},{[vars]testing_src_path} \
--branch -m pytest \
--ignore={[vars]tst_path}smoke \
--ignore={[vars]tst_path}integration \
--ignore={[vars]tst_path}benchmark \
--ignore={[vars]testing_tst_path}benchmark \
--ignore={[vars]tracing_tst_path} \
--ignore={[vars]examples_path} \
-v --tb native \
-W 'ignore:Harness is deprecated:PendingDeprecationWarning' {posargs}
coverage report
mv .coverage .coverage-ops
[testenv:coverage-tracing]
description = Run tracing unit tests with coverage
allowlist_externals = mv
dependency_groups = unit, coverage
changedir = ./tracing/
commands =
coverage run --source=. --branch -m pytest \
-v --tb native \
-W 'ignore:Harness is deprecated:PendingDeprecationWarning' {posargs}
coverage report
mv .coverage ../.coverage-tracing
[testenv:coverage-report]
description = Report on coverage
allowlist_externals = mkdir
dependency_groups = coverage
commands =
mkdir -p .report
coverage combine -a .coverage-ops
coverage combine -a .coverage-tracing
coverage xml -o .report/coverage.xml
coverage report
[testenv:benchmark]
description = Run benchmark tests
passenv =
RUN_REAL_PEBBLE_TESTS
PEBBLE
SCENARIO_SKIP_CONSISTENCY_CHECKS
SCENARIO_BARE_CHARM_ERRORS
dependency_groups = unit, benchmark
commands =
pytest -v --tb native \
{[vars]tst_path}benchmark \
{[vars]testing_tst_path}benchmark \
{posargs}
[testenv:py{3.10,3.12,3.14}-pebble]
runner = uv-venv-lock-runner
base=pebble
[testenv:pebble]
description = Run real pebble tests
allowlist_externals = bash
killall
setenv =
PEBBLE=/tmp/pebble
RUN_REAL_PEBBLE_TESTS=1
passenv =
PATH
SCENARIO_SKIP_CONSISTENCY_CHECKS
SCENARIO_BARE_CHARM_ERRORS
dependency_groups = unit
commands_pre = bash -c "umask 0; pebble run --http=':4000' --create-dirs &>/dev/null& sleep 1"
commands = pytest -v --tb native test/test_real_pebble.py {posargs}
commands_post = killall -y 3m pebble
[testenv:smoke]
description = Run a smoke test against a Juju controller.
allowlist_externals =
juju
charmcraft
bash
cp
uv
dependency_groups = integration
commands =
# Clean any stale artefacts, in case these steps are run locally and repeatedly.
bash -c "find test/charms/test_smoke -name '*.whl' -or -name '*.tar.gz' -or -name pyproject.toml -or -name uv.lock | xargs -r rm -vf"
# Build ops from this checkout.
uv build --out-dir=test/charms/test_smoke --wheel .
# Inject current ops into the smoke test charm's requirements.
cp test/charms/test_smoke/reference-pyproject.toml test/charms/test_smoke/pyproject.toml
bash -c 'uv --project test/charms/test_smoke add test/charms/test_smoke/ops-3.*.whl'
# Run our smoke tests (this will build the charm, then run the tests).
pytest -v --tb native --log-cli-level=INFO -s {posargs} {toxinidir}/test/smoke
[testenv:integration]
description = Run a suite of integration tests.
dependency_groups = integration
commands = pytest -vvv --tb native {toxinidir}/test/integration/ {posargs}
[testenv:draft-release]
description = Make a draft release
dependency_groups = release
passenv =
GITHUB_TOKEN
SSH_AUTH_SOCK # Without this, on some systems SSH connections to github.com fail.
commands = python release.py {posargs}
[testenv:post-release]
description = Perform post-release actions
dependency_groups = release
passenv =
GITHUB_TOKEN
SSH_AUTH_SOCK # Without this, on some systems SSH connections to github.com fail.
commands = python release.py --post-release {posargs}