From e6db576b1c984eaa5d34bc56c05b8348ed6c0805 Mon Sep 17 00:00:00 2001 From: Olaf Haag Date: Wed, 8 Nov 2023 23:16:38 +0100 Subject: [PATCH] ci(tests): fix linting and test envs add environments for linting & testing to avoid pre-commit hooks in ci --- .github/workflows/test.yml | 10 +++++----- pyproject.toml | 34 +++++++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 997eed1..bb5c929 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,11 +36,11 @@ jobs: - name: Install Hatch run: pip install --upgrade hatch - - name: Run tests - run: hatch run cov - - name: Run linting - run: hatch run style + run: hatch run lint:style - name: Run type-checking - run: hatch run typing + run: hatch run lint:typing + + - name: Run tests + run: hatch run test:cov diff --git a/pyproject.toml b/pyproject.toml index 2f89c66..f8b0dad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,12 +34,18 @@ dependencies = [ ] [project.optional-dependencies] -tests = [ +test = [ "pytest", "pytest-xdist", + "coverage[toml]>=6.5", +] +lint = [ + "black>=23.3.0", + "mypy>=1.5.1", + "ruff>=0.0.285", ] dev = [ - "readyplayerme.meshops[tests]", + "readyplayerme.meshops[test, lint]", "pre-commit", ] @@ -58,13 +64,6 @@ packages = ["src/readyplayerme"] description = "Python virtual environment in project dir to quickly get up and running in an IDE like VSCode." type = "virtual" path = ".venv" -dependencies = [ - "black>=23.3.0", - "mypy>=1.5.1", - "ruff>=0.0.285", - "coverage[toml]>=6.5", - "pytest", -] features = [ "dev", ] @@ -100,6 +99,22 @@ all = [ "cov", ] +[tool.hatch.envs.lint] +description = "Python virtual environment to be used in CI to run linting and type checking." +# Note: This still inherits the path from the default env, so it will use the same venv. +features = [ + "lint", +] +post-install-commands = [] + +[tool.hatch.envs.test] +description = "Python virtual environment to be used in CI to run tests." +# Note: This still inherits the path from the default env, so it will use the same venv. +features = [ + "test", +] +post-install-commands = [] + [[tool.hatch.envs.all.matrix]] python = ["3.10", "3.11"] @@ -227,6 +242,7 @@ warn_unused_ignores = true disallow_any_generics = true check_untyped_defs = true no_implicit_reexport = true +plugins = ["numpy.typing.mypy_plugin"] [[tool.mypy.overrides]] module = "readyplayerme.*"