diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..3df3806a --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,36 @@ +name: Tests + +on: + push: + branches: [develop, master] + pull_request: + branches: [develop, master] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.11"] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e ".[dev]" + + - name: Run tests with coverage + run: pytest --cov=kiauh --cov-report=xml --cov-report=term + + - name: Upload coverage + uses: actions/upload-artifact@v4 + with: + name: coverage-${{ matrix.python-version }} + path: coverage.xml diff --git a/.gitignore b/.gitignore index 2cac3a12..0a33cdad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ .idea .vscode .pytest_cache +.ruff_cache +.mypy_cache .jupyter *.ipynb *.ipynb_checkpoints @@ -10,5 +12,7 @@ __pycache__ .venv *.code-workspace *.iml +*.egg-info +.coverage kiauh.cfg klipper_repos.txt diff --git a/pyproject.toml b/pyproject.toml index bd63166f..eb3a0bf9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,19 @@ +[build-system] +requires = ["setuptools>=61", "wheel"] +build-backend = "setuptools.build_meta" + [project] +name = "kiauh" +version = "0.0.0" requires-python = ">=3.8" [project.optional-dependencies] -dev=["ruff", "mypy", "pytest"] +dev = ["ruff", "mypy", "pytest", "pytest-cov"] [tool.ruff] required-version = ">=0.9.10" respect-gitignore = true -exclude = [".git",".github", "./docs"] +exclude = [".git", ".github", "./docs"] line-length = 88 indent-width = 4 output-format = "full" @@ -24,6 +30,8 @@ extend-select = ["I"] [tool.mypy] python_version = "3.8" platform = "linux" +explicit_package_bases = true +mypy_path = "kiauh" check_untyped_defs = true ignore_missing_imports = true warn_redundant_casts = true @@ -31,7 +39,28 @@ warn_unused_ignores = true warn_return_any = true warn_unreachable = true +[tool.coverage.report] +fail_under = 65 +skip_covered = false + [tool.pytest.ini_options] minversion = "8.2.1" -testpaths = ["kiauh/core/simple_config_parser/tests", "kiauh/utils/tests"] +testpaths = [ + "kiauh/components/klipper/services/tests", + "kiauh/components/moonraker/services/tests", + "kiauh/components/moonraker/utils/tests", + "kiauh/components/webui_client/services/tests", + "kiauh/components/webui_client/tests", + "kiauh/components/webui_client/menus/tests", + "kiauh/core/backends/tests", + "kiauh/core/cli/tests", + "kiauh/core/instance_manager/tests", + "kiauh/core/menus/tests", + "kiauh/core/services/tests", + "kiauh/core/settings/tests", + "kiauh/core/simple_config_parser/tests", + "kiauh/extensions/tests", + "kiauh/tests", + "kiauh/utils/tests", +] pythonpath = ["kiauh"] diff --git a/requirements-dev.txt b/requirements-dev.txt index bc5d172a..117e34f2 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,4 @@ ruff (>=0.9.10) mypy pytest +pytest-cov