Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try out testing with UV #29

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
with:
fail-on-error: "true"

lint-unit:
name: Lint Unit
lint-unit-uv:
name: Lint / Unit Tests
uses: charmed-kubernetes/workflows/.github/workflows/lint-unit.yaml@main
with:
python: "['3.8', '3.9', '3.10', '3.11']"
with-uv: true
needs:
- call-inclusive-naming-check
11 changes: 0 additions & 11 deletions mypy.ini

This file was deleted.

82 changes: 82 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
[lint]
ignore = ["E501", "D107"]
extend-ignore = [
"D203",
"D204",
"D213",
"D215",
"D400",
"D404",
"D406",
"D407",
"D408",
"D409",
"D413",
]
per-file-ignores = {"tests/*" = ["D100","D101","D102","D103","D104"]}

[lint.mccabe]
max-complexity = 10



# Testing tools configuration
[tool.coverage.run]
branch = true

# Formatting tools configuration
[tool.black]
line-length = 99
target-version = ["py38"]

[tool.coverage.report]
show_missing = true


[tool.isort]
line_length=99
multi_line_output=3
include_trailing_comma = true
use_parentheses = true

[tool.mypy]
warn_unused_ignores = true
warn_unused_configs = true
warn_unreachable = true
disallow_untyped_defs = true
# Due to python 3.5 support we can't enforce variable type annotations
disable_error_code = "var-annotated"

[[tool.mypy.overrides]]
module = "charms.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "lightkube.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "ops.*"
ignore_missing_imports = true

[tool.pytest.ini_options]
minversion = "6.0"

# Linting tools configuration
[tool.ruff]
# line-length = 99
# select = ["E", "W", "F", "C", "N", "D", "I001"]
extend-exclude = ["__pycache__", "*.egg_info"]

[tool.codespell]
skip = "build,lib,venv,icon.svg,.tox,.git,.mypy_cache,.ruff_cache,.coverage"

[tool.pyright]
extraPaths = ["./lib"]

[project]
name = "ceph-csi"
dynamic = ["version"]
dependencies = [
"tox-uv"
]
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ tox
isort
black
types-PyYAML
uv
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
coverage
pytest
pytest-operator
uv
2 changes: 1 addition & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def check_kube_config(self) -> None:
def check_namespace(self) -> None:
self.unit.status = ops.MaintenanceStatus("Evaluating namespace")
try:
self._client.get(Namespace, name=self.stored.namespace) # type: ignore
self._client.get(Namespace, name=self.stored.namespace)
except ApiError as e:
if "not found" in str(e.status.message):
status.add(ops.BlockedStatus(f"Missing namespace '{self.stored.namespace}'"))
Expand Down
32 changes: 13 additions & 19 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tox]
skipsdist=True
envlist = lint, unit
requires =
pip >= 20.3
; requires =
; pip >= 20.3

[vars]
cov_path = {toxinidir}/htmlcov
Expand All @@ -24,18 +24,18 @@ deps = -r{toxinidir}/requirements-dev.txt
[testenv:lint]
basepython = python3
commands =
codespell {[vars]all_path}
ruff check {[vars]all_path}
isort --check-only --diff {[vars]all_path}
black -l 99 --check --diff {[vars]all_path}
mypy --namespace-packages {[vars]src_path}
uvx codespell {[vars]all_path}
uvx ruff check {[vars]all_path}
uvx isort --check-only --diff {[vars]all_path}
uvx black -l 99 --check --diff {[vars]all_path}
uvx mypy --namespace-packages {[vars]src_path}

[testenv:unit]
basepython = python3
deps = -r{toxinidir}/requirements-test.txt
commands =
coverage run --source={toxinidir}/src -m pytest {toxinidir}/tests/unit/ {posargs}
coverage report -m --fail-under=97
uv run coverage run --source={toxinidir}/src -m pytest {toxinidir}/tests/unit/ {posargs}
uv run coverage report -m --fail-under=97

[testenv:integration]
basepython = python3
Expand All @@ -45,17 +45,17 @@ passenv =
TEST_HTTPS_PROXY
deps = -r{toxinidir}/requirements-test.txt
commands =
pytest --log-cli-level=INFO \
uv run pytest --log-cli-level=INFO \
--asyncio-mode=auto \
{posargs} \
{toxinidir}/tests/functional/

[testenv:format]
basepython = python3
commands =
isort {[vars]all_path}
black -l 99 {[vars]all_path}
ruff check --fix {[vars]all_path}
uvx isort {[vars]all_path}
uvx black -l 99 {[vars]all_path}
uvx ruff check --fix {[vars]all_path}

[testenv:update]
deps =
Expand All @@ -65,12 +65,6 @@ commands =
python {toxinidir}/upstream/update.py {posargs}


[isort]
line_length=99
multi_line_output=3
include_trailing_comma=True
use_parentheses=True

[coverage:report]
exclude_lines =
pragma: no cover
Expand Down
Loading