forked from canonical/operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tox.ini
143 lines (130 loc) · 3.84 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
# 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
[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:fmt]
description = Apply coding style standards to code
deps =
ruff==0.4.5
commands =
ruff format --preview
[testenv:lint]
description = Check code against coding style standards
deps =
ruff==0.4.5
commands =
ruff check --preview
ruff format --preview --check
[testenv:static]
description = Run static type checker
deps =
PyYAML==6.*
websocket-client==1.*
pyright==1.1.377
pytest~=7.2
typing_extensions~=4.2
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
commands =
pytest -n auto --ignore={[vars]tst_path}smoke -v --tb native {posargs}
[testenv:coverage]
description = Run unit tests with coverage
passenv =
RUN_REAL_PEBBLE_TESTS
PEBBLE
deps =
PyYAML==6.*
websocket-client==1.*
coverage[toml]~=7.0
pytest~=7.2
typing_extensions~=4.2
commands =
coverage run --source={[vars]src_path} \
-m pytest --ignore={[vars]tst_path}smoke -v --tb native {posargs}
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
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'
# 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/