-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add-upgrade
- Loading branch information
Showing
15 changed files
with
447 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,54 @@ | ||
# Testing tools configuration | ||
[tool.coverage.run] | ||
branch = true | ||
# Linting tools configuration | ||
|
||
[tool.coverage.report] | ||
show_missing = true | ||
[tool.ruff] | ||
target-version = "py38" | ||
line-length = 99 | ||
extend-exclude = [ "*.egg_info", "__pycache__" ] | ||
|
||
lint.select = [ | ||
"C", | ||
"D", | ||
"E", | ||
"F", | ||
"F401", | ||
"I", | ||
"I001", | ||
"N", | ||
"RUF", | ||
"UP", | ||
"W", | ||
] | ||
lint.ignore = [ "D107", "E501" ] | ||
lint.extend-ignore = [ | ||
"D203", | ||
"D204", | ||
"D213", | ||
"D215", | ||
"D400", | ||
"D404", | ||
"D406", | ||
"D407", | ||
"D408", | ||
"D409", | ||
"D413", | ||
] | ||
lint.per-file-ignores = { "tests/*" = [ "D100", "D101", "D102", "D103", "D104" ] } | ||
lint.mccabe.max-complexity = 10 | ||
|
||
[tool.codespell] | ||
skip = "build,lib,venv,icon.svg,.tox,.git,.mypy_cache,.ruff_cache,.coverage" | ||
|
||
[tool.pytest.ini_options] | ||
minversion = "6.0" | ||
log_cli_level = "INFO" | ||
|
||
# Formatting tools configuration | ||
[tool.black] | ||
line-length = 99 | ||
target-version = ["py38"] | ||
|
||
# Linting tools configuration | ||
[tool.ruff] | ||
line-length = 99 | ||
extend-exclude = ["__pycache__", "*.egg_info"] | ||
|
||
[tool.ruff.lint] | ||
select = ["E", "W", "F", "C", "N", "D", "I001"] | ||
extend-ignore = [ | ||
"D203", | ||
"D204", | ||
"D213", | ||
"D215", | ||
"D400", | ||
"D404", | ||
"D406", | ||
"D407", | ||
"D408", | ||
"D409", | ||
"D413", | ||
] | ||
ignore = ["E501", "D107"] | ||
per-file-ignores = { "tests/*" = ["D100", "D101", "D102", "D103", "D104"] } | ||
|
||
[tool.ruff.lint.mccabe] | ||
max-complexity = 10 | ||
[tool.coverage.run] | ||
branch = true | ||
|
||
[tool.codespell] | ||
skip = "build,lib,venv,icon.svg,.tox,.git,.mypy_cache,.ruff_cache,.coverage" | ||
[tool.coverage.report] | ||
show_missing = true | ||
|
||
[tool.pyright] | ||
include = ["src/**.py"] | ||
include = [ "src/**.py" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
|
||
|
||
class TestHelperSnapCache(unittest.TestCase): | ||
|
||
def _setup_snap( | ||
self, | ||
mock_snap, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,109 @@ | ||
# Copyright 2024 Canonical | ||
# See LICENSE file for licensing details. | ||
|
||
[tox] | ||
no_package = True | ||
skip_missing_interpreters = True | ||
env_list = format, lint, static-{charm,lib}, unit, scenario | ||
min_version = 4.0.0 | ||
requires = | ||
tox>=4.2 | ||
env_list = | ||
format | ||
lint | ||
static-{charm, lib} | ||
unit | ||
scenario | ||
no_package = true | ||
skip_missing_interpreters = true | ||
basepython = py38 | ||
|
||
[vars] | ||
src_path = {tox_root}/src | ||
tests_path = {tox_root}/tests | ||
lib_path = {tox_root}/lib/charms/maas_region/v0/ | ||
all_path = {[vars]src_path} {[vars]tests_path} {[vars]lib_path} | ||
|
||
[testenv] | ||
set_env = | ||
PYTHONPATH = {tox_root}/lib:{[vars]src_path} | ||
PYTHONBREAKPOINT=pdb.set_trace | ||
PY_COLORS=1 | ||
pass_env = | ||
PYTHONPATH | ||
CHARM_BUILD_DIR | ||
MODEL_SETTINGS | ||
PYTHONPATH | ||
set_env = | ||
PYTHONBREAKPOINT = pdb.set_trace | ||
PYTHONPATH = {tox_root}/lib:{[vars]src_path} | ||
PY_COLORS = 1 | ||
|
||
[testenv:format] | ||
description = Apply coding style standards to code | ||
deps = | ||
black | ||
pyproject-fmt | ||
ruff | ||
tox-ini-fmt | ||
commands = | ||
black {[vars]all_path} | ||
ruff format {[vars]all_path} | ||
ruff check --fix {[vars]all_path} | ||
- pyproject-fmt pyproject.toml | ||
- tox-ini-fmt tox.ini | ||
|
||
[testenv:lint] | ||
description = Check code against coding style standards | ||
deps = | ||
black | ||
ruff | ||
codespell | ||
pyproject-fmt | ||
ruff | ||
commands = | ||
# if this charm owns a lib, uncomment "lib_path" variable | ||
# and uncomment the following line | ||
# codespell {[vars]lib_path} | ||
codespell {tox_root} | ||
ruff check {[vars]all_path} | ||
black --check --diff {[vars]all_path} | ||
pyproject-fmt --check pyproject.toml | ||
|
||
[testenv:unit] | ||
description = Run unit tests | ||
deps = | ||
pytest | ||
coverage[toml] | ||
-r {tox_root}/requirements.txt | ||
coverage[toml] | ||
pytest | ||
commands = | ||
coverage run --source={[vars]src_path} \ | ||
-m pytest \ | ||
--tb native \ | ||
-v \ | ||
-s \ | ||
{posargs} \ | ||
{[vars]tests_path}/unit | ||
-m pytest \ | ||
--tb native \ | ||
-v \ | ||
-s \ | ||
{posargs} \ | ||
{[vars]tests_path}/unit | ||
coverage report | ||
|
||
[testenv:scenario] | ||
description = Run scenario tests | ||
deps = | ||
-r {tox_root}/requirements.txt | ||
cosl | ||
ops-scenario | ||
pytest | ||
commands = | ||
pytest -v -s --tb native {posargs} --log-cli-level=INFO {[vars]tests_path}/scenario | ||
|
||
[testenv:static-{charm,lib}] | ||
description = Run static analysis checks | ||
deps = | ||
pyright | ||
typing-extensions | ||
charm: -r{toxinidir}/requirements.txt | ||
lib: ops | ||
integration: {[testenv:integration]deps} | ||
lib: jinja2 | ||
lib: ops | ||
unit: {[testenv:unit]deps} | ||
integration: {[testenv:integration]deps} | ||
commands = | ||
charm: pyright --pythonversion 3.8 {[vars]src_path} {posargs} | ||
lib: pyright --pythonversion 3.8 {[vars]lib_path} {posargs} | ||
lib: /usr/bin/env sh -c 'for m in $(git diff main --name-only --line-prefix=`git rev-parse --show-toplevel`/ {[vars]lib_path}); do if ! git diff main $m | grep -q "+LIBPATCH\|+LIBAPI"; then echo "You forgot to bump the version on $m!"; exit 1; fi; done' | ||
allowlist_externals = /usr/bin/env | ||
allowlist_externals = | ||
/usr/bin/env | ||
|
||
[testenv:integration] | ||
description = Run integration tests | ||
deps = | ||
pytest | ||
-r {tox_root}/requirements.txt | ||
juju | ||
pytest | ||
pytest-operator | ||
-r {tox_root}/requirements.txt | ||
commands = | ||
pytest -v \ | ||
-s \ | ||
--tb native \ | ||
--log-cli-level=INFO \ | ||
{posargs} \ | ||
{[vars]tests_path}/integration | ||
-s \ | ||
--tb native \ | ||
--log-cli-level=INFO \ | ||
{posargs} \ | ||
{[vars]tests_path}/integration | ||
|
||
[testenv:scenario] | ||
description = Run scenario tests | ||
deps = | ||
pytest | ||
cosl | ||
ops-scenario | ||
-r {tox_root}/requirements.txt | ||
commands = | ||
pytest -v -s --tb native {posargs} --log-cli-level=INFO {[vars]tests_path}/scenario | ||
[vars] | ||
src_path = {tox_root}/src | ||
tests_path = {tox_root}/tests | ||
lib_path = {tox_root}/lib/charms/maas_region/v0/ | ||
all_path = {[vars]src_path} {[vars]tests_path} {[vars]lib_path} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.