From 5738edb49c5253b98b03858f79053cad842ce7c8 Mon Sep 17 00:00:00 2001 From: jo Date: Wed, 7 Dec 2022 11:42:16 +0100 Subject: [PATCH] chore: split test and coverage tasks --- .github/workflows/_python.yml | 2 +- .github/workflows/api.yml | 2 +- analyzer/Makefile | 2 +- analyzer/pyproject.toml | 3 +++ api-client/Makefile | 2 +- api-client/pyproject.toml | 3 +++ api/Makefile | 12 ++---------- api/pyproject.toml | 3 +++ api/setup.py | 1 + playout/Makefile | 2 +- playout/pyproject.toml | 3 +++ shared/Makefile | 2 +- shared/pyproject.toml | 3 +++ tools/python.mk | 13 +++++++++---- worker/Makefile | 2 +- worker/pyproject.toml | 3 +++ 16 files changed, 37 insertions(+), 21 deletions(-) diff --git a/.github/workflows/_python.yml b/.github/workflows/_python.yml index 05efcaf9e..48d3e5d71 100644 --- a/.github/workflows/_python.yml +++ b/.github/workflows/_python.yml @@ -73,7 +73,7 @@ jobs: ${{ matrix.release }}-pip-${{ inputs.context }} - name: Test - run: make test + run: make test-coverage working-directory: ${{ inputs.context }} - name: Report coverage diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 1bd9c2e50..7be231af8 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -66,7 +66,7 @@ jobs: ${{ matrix.release }}-pip-api - name: Test - run: make test + run: make test-coverage working-directory: api - name: Report coverage diff --git a/analyzer/Makefile b/analyzer/Makefile index dac8bea12..32e862fd0 100644 --- a/analyzer/Makefile +++ b/analyzer/Makefile @@ -8,7 +8,6 @@ PIP_INSTALL := \ PYLINT_ARG := libretime_analyzer tests || true MYPY_ARG := libretime_analyzer tests || true BANDIT_ARG := libretime_analyzer || true -PYTEST_ARG := --cov=libretime_analyzer tests format: .format lint: .format-check .pylint .mypy .bandit @@ -17,4 +16,5 @@ fixtures: bash tests/fixtures/generate.sh test: fixtures .pytest +test-coverage: fixtures .coverage clean: .clean diff --git a/analyzer/pyproject.toml b/analyzer/pyproject.toml index 7de38496a..571f62982 100644 --- a/analyzer/pyproject.toml +++ b/analyzer/pyproject.toml @@ -13,6 +13,9 @@ disable = "logging-fstring-interpolation" log_cli = true log_cli_level = "DEBUG" +[tool.coverage.run] +source = ["libretime_analyzer"] + [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" diff --git a/api-client/Makefile b/api-client/Makefile index ec82ad095..aafa65422 100644 --- a/api-client/Makefile +++ b/api-client/Makefile @@ -8,9 +8,9 @@ PIP_INSTALL := \ PYLINT_ARG := libretime_api_client tests || true MYPY_ARG := libretime_api_client tests || true BANDIT_ARG := libretime_api_client || true -PYTEST_ARG := --cov=libretime_api_client tests format: .format lint: .format-check .pylint .mypy .bandit test: .pytest +test-coverage: .coverage clean: .clean diff --git a/api-client/pyproject.toml b/api-client/pyproject.toml index 7de38496a..3a9b526df 100644 --- a/api-client/pyproject.toml +++ b/api-client/pyproject.toml @@ -13,6 +13,9 @@ disable = "logging-fstring-interpolation" log_cli = true log_cli_level = "DEBUG" +[tool.coverage.run] +source = ["libretime_api_client"] + [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" diff --git a/api/Makefile b/api/Makefile index 172630b25..1943f0852 100644 --- a/api/Makefile +++ b/api/Makefile @@ -13,18 +13,10 @@ export DJANGO_SETTINGS_MODULE=libretime_api.settings.testing format: .format lint: .format-check .pylint .mypy .bandit +test: .pytest +test-coverage: .coverage clean: .clean -test: $(VENV) - $(VENV)/bin/pytest -v \ - --numprocesses=$(CPU_CORES) \ - --color=yes \ - --cov-config=pyproject.toml \ - --cov-report=term \ - --cov-report=xml:./coverage.xml \ - --cov=libretime_api \ - libretime_api - SCHEMA_FILE ?= schema.yml schema: $(VENV) $(VENV)/bin/libretime-api spectacular --file $(SCHEMA_FILE) diff --git a/api/pyproject.toml b/api/pyproject.toml index 7ece05658..b2c2c36c9 100644 --- a/api/pyproject.toml +++ b/api/pyproject.toml @@ -36,7 +36,10 @@ log_cli_level = "DEBUG" DJANGO_SETTINGS_MODULE = "libretime_api.settings.testing" [tool.coverage.run] +plugins = ["django_coverage_plugin"] +source = ["libretime_api"] omit = [ + "*/migrations/*", "*/tests/*", ] diff --git a/api/setup.py b/api/setup.py index b7ef15ef7..dc750622c 100644 --- a/api/setup.py +++ b/api/setup.py @@ -35,6 +35,7 @@ setup( "psycopg2>=2.8.6,<2.10", ], "dev": [ + "django-coverage-plugin", "django-stubs", "djangorestframework-stubs", "model_bakery", diff --git a/playout/Makefile b/playout/Makefile index 4aca9f5e5..9a79ac248 100644 --- a/playout/Makefile +++ b/playout/Makefile @@ -10,11 +10,11 @@ PIP_INSTALL := \ PYLINT_ARG := libretime_playout tests || true MYPY_ARG := libretime_playout tests || true BANDIT_ARG := libretime_playout || true -PYTEST_ARG := --cov=libretime_playout tests format: .format lint: .format-check .pylint .mypy .bandit test: .pytest +test-coverage: .coverage clean: .clean .PHONY: snapshot diff --git a/playout/pyproject.toml b/playout/pyproject.toml index 17fdd3f74..3222b65b8 100644 --- a/playout/pyproject.toml +++ b/playout/pyproject.toml @@ -16,6 +16,9 @@ disable = "logging-fstring-interpolation" log_cli = true log_cli_level = "DEBUG" +[tool.coverage.run] +source = ["libretime_playout"] + [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" diff --git a/shared/Makefile b/shared/Makefile index 66aef5bc6..18c0b8eda 100644 --- a/shared/Makefile +++ b/shared/Makefile @@ -6,9 +6,9 @@ PIP_INSTALL = --editable .[dev] PYLINT_ARG = libretime_shared tests MYPY_ARG = libretime_shared BANDIT_ARG := libretime_shared -PYTEST_ARG = --cov=libretime_shared tests format: .format lint: .format-check .pylint .mypy .bandit test: .pytest +test-coverage: .coverage clean: .clean diff --git a/shared/pyproject.toml b/shared/pyproject.toml index cd638a160..2dd7612ab 100644 --- a/shared/pyproject.toml +++ b/shared/pyproject.toml @@ -19,6 +19,9 @@ disallow_untyped_defs= true log_cli = true log_cli_level = "DEBUG" +[tool.coverage.run] +source = ["libretime_shared"] + [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" diff --git a/tools/python.mk b/tools/python.mk index 6103928b3..027f6a105 100644 --- a/tools/python.mk +++ b/tools/python.mk @@ -55,13 +55,18 @@ install: $(VENV) .PHONY: .pytest .pytest: $(VENV) - $(VENV)/bin/pytest -v \ + $(VENV)/bin/pytest \ --numprocesses=$(CPU_CORES) \ - --color=yes \ + --color=yes + +.PHONY: .coverage +.coverage: $(VENV) + $(VENV)/bin/pytest \ + --numprocesses=$(CPU_CORES) \ + --cov \ --cov-config=pyproject.toml \ --cov-report=term \ - --cov-report=xml:./coverage.xml \ - $(PYTEST_ARG) + --cov-report=xml .PHONY: .clean .clean: diff --git a/worker/Makefile b/worker/Makefile index 377e30448..352480426 100644 --- a/worker/Makefile +++ b/worker/Makefile @@ -8,9 +8,9 @@ PIP_INSTALL := \ PYLINT_ARG := libretime_worker MYPY_ARG := libretime_worker || true BANDIT_ARG := libretime_worker -PYTEST_ARG = --cov=libretime_worker tests format: .format lint: .format-check .pylint .mypy .bandit test: .pytest +test-coverage: .coverage clean: .clean diff --git a/worker/pyproject.toml b/worker/pyproject.toml index 7de38496a..d394870e9 100644 --- a/worker/pyproject.toml +++ b/worker/pyproject.toml @@ -13,6 +13,9 @@ disable = "logging-fstring-interpolation" log_cli = true log_cli_level = "DEBUG" +[tool.coverage.run] +source = ["libretime_worker"] + [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta"