forked from canonical/operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tox.ini
187 lines (172 loc) · 5.23 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
185
186
187
# 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, static, 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}
[testenv]
basepython = python3
setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/lib:{[vars]src_path}
PY_COLORS=1
passenv =
PYTHONPATH
HOME
PATH
MODEL_SETTINGS
[testenv:docs-deps]
description = Compile the requirements.txt file for docs
deps = pip-tools
commands =
pip-compile --extra=docs -o docs/requirements.txt pyproject.toml
python -c 'open("docs/requirements.txt", "a").write("./testing/\n")'
[testenv:docs]
description = Build the Sphinx docs
deps = pip-tools
commands_pre =
pip-sync {toxinidir}/docs/requirements.txt
commands =
sphinx-build -W --keep-going docs/ docs/_build/html
[testenv:docs-live]
description = Live development: build the Sphinx docs with autoreloading enabled
deps = {[testenv:docs]deps}
commands_pre =
{[testenv:docs]commands_pre}
commands =
sphinx-autobuild docs/ docs/_build/html --watch ops/ --port 8000 {posargs}
[testenv:fmt]
description = Apply coding style standards to code
deps =
ruff==0.7.0
commands =
ruff format --preview
[testenv:lint]
description = Check code against coding style standards
deps =
ruff==0.7.0
codespell==2.3.0
commands =
ruff check --preview
ruff format --preview --check
codespell
[testenv:static]
description = Run static type checker
allowlist_externals = cp
deps =
PyYAML==6.*
websocket-client==1.*
pyright==1.1.385
pytest~=7.2
typing_extensions~=4.2
-e .
-e testing
commands =
pyright {posargs}
[testenv:unit]
description = Run unit tests in parallel without coverage
passenv =
RUN_REAL_PEBBLE_TESTS
PEBBLE
deps =
PyYAML==6.*
websocket-client==1.*
pytest~=7.2
pytest-xdist~=3.6
typing_extensions~=4.2
jsonpatch~=1.33
-e .
-e testing
commands =
pytest -n auto --ignore={[vars]tst_path}smoke -v --tb native \
-W 'ignore:Harness is deprecated:PendingDeprecationWarning' {posargs}
[testenv:coverage]
description = Run unit tests with coverage
allowlist_externals = mkdir
passenv =
RUN_REAL_PEBBLE_TESTS
PEBBLE
deps =
PyYAML==6.*
websocket-client==1.*
coverage[toml]~=7.0
pytest~=7.2
typing_extensions~=4.2
jsonpatch~=1.33
-e .
-e testing
commands =
mkdir -p .report
coverage run --source={[vars]src_path},testing/src/scenario \
-m pytest --ignore={[vars]tst_path}smoke -v --tb native {posargs}
coverage xml -o .report/coverage.xml
coverage report
[testenv:pebble]
description = Run real pebble tests
allowlist_externals = pebble
mkdir
bash
setenv =
PEBBLE=/tmp/pebble
RUN_REAL_PEBBLE_TESTS=1
deps =
PyYAML==6.*
websocket-client==1.*
coverage[toml]~=7.0
pytest~=7.2
typing_extensions~=4.2
commands =
bash -c "umask 0; (pebble run --http=':4000' --create-dirs &>/dev/null & ) ; sleep 1; pytest -v --tb native test/test_real_pebble.py {posargs} ; killall -y 3m pebble"
[testenv:smoke]
description = Run a smoke test against a Juju controller.
allowlist_externals = juju
charmcraft
bash
passenv = JUJU_VERSION
deps =
build
coverage[toml]~=7.0
pytest~=7.2
pytest-operator~=0.23
commands =
# Build a source tarball for ops, and drop it into the root directory of the smoke test charm.
bash -c 'rm -vf ./test/charms/test_smoke/*.tar.gz'
python -m build --sdist --outdir={toxinidir}/test/charms/test_smoke/
# Inject the tarball into the smoke test charm's requirements.
bash -c 'echo "./$(ls -1 ./test/charms/test_smoke/ | grep tar.gz)" > ./test/charms/test_smoke/requirements.txt'
# If a specific Juju version is set, then make sure we are using that version of pylibjuju.
bash -c 'if [ -n "$JUJU_VERSION" ]; then pip install "juju ~= $JUJU_VERSION"; fi'
# 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:test-readme]
description = Test code snippets in the testing README.
skip_install = true
allowlist_externals =
mkdir
cp
deps =
-e .
-e testing
pytest
pytest-markdown-docs
commands =
mkdir -p {envtmpdir}/test-readme
cp {toxinidir}/testing/README.md {envtmpdir}/test-readme/README.md
cp {toxinidir}/testing/tests/readme-conftest.py {envtmpdir}/test-readme/conftest.py
pytest -v --tb native --log-cli-level=INFO -s {posargs} --markdown-docs {envtmpdir}/test-readme/README.md