From 8ec3037777f349146be08ba1bee5691f8ba78400 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Thu, 21 Dec 2023 22:04:06 +0100 Subject: [PATCH] Add `pytest-cov` for unit-test coverage --- .gitignore | 7 +++++++ CONTRIBUTING.md | 28 +++++++++++++++++++++++----- Makefile | 5 ++++- pyproject.toml | 1 + 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 5fe9e5c..07dee62 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,14 @@ __pycache__ *.egg dist/ build/ +.coverage +htmlcov .vscode .idea .DS_Store + +docs/changelog.md + +# default folder for memory storage data +storage/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ed8d6c8..72b8f08 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,15 +20,33 @@ and [direnv](https://github.com/direnv/direnv) to automatically activate/deactiv ## Dependencies -To install this package and its development dependencies, run `make install-dev` +To install this package and its development dependencies, run `make install-dev`. -## Formatting +## Code checking -We use `ruff` to automatically format the code to a common format. To run the formatting, just run `make format`. +To run all our code checking tools together, just run `make check-code`. -## Linting, type-checking and unit testing +### Linting -We use `ruff` for linting, `mypy` for type checking and `pytest` for unit testing. To run these tools, just run `make check-code`. +We use [ruff](https://docs.astral.sh/ruff/) for linting to to analyze the code for potential issues and enforce +uniformed code style. See the `pyproject.toml` for its configuration. To run the linting, just run `make lint`. + +### Formatting + +We use [ruff](https://docs.astral.sh/ruff/) for automated code formatting. It formats the code to follow uniformed +code style and addresses auto-fixable linting issues. See the `pyproject.toml` for its configuration. To run +the formatting, just run `make format`. + +### Type checking + +We use [mypy](https://mypy.readthedocs.io/en/stable/) for type checking. See the `mypy.ini` for its configuration. +To run the type checking, just run `make type-check`. + +### Unit tests + +We use [pytest](https://docs.pytest.org/) as a testing framework with many plugins. See the `pyproject.toml` for +both its configuration and the list of installed plugins. To run unit tests execute `make unit-tests`. To run unit +tests with HTML coverage report execute `make unit-tests-cov`. ## Release process diff --git a/Makefile b/Makefile index 6b7d454..bc6b2ac 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,10 @@ lint: python3 -m ruff check $(DIRS_WITH_CODE) unit-tests: - python3 -m pytest -n auto -ra tests/unit + python3 -m pytest -n auto -ra tests/unit --cov=src/apify_shared + +unit-tests-cov: + python3 -m pytest -n auto -ra tests/unit --cov=src/apify_shared --cov-report=html type-check: python3 -m mypy $(DIRS_WITH_CODE) diff --git a/pyproject.toml b/pyproject.toml index 5447722..da43aeb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,7 @@ dev = [ "pydoc-markdown ~= 4.8.2", "pytest ~= 7.4.2", "pytest-asyncio ~= 0.21.0", + "pytest-cov ~= 4.1.0", "pytest-only ~= 2.0.0", "pytest-timeout ~= 2.2.0", "pytest-xdist ~= 3.3.1",