Tests, Formatting, Docs
Running tests¶
# Gitlint
hatch run dev:gitlint # run the local source copy of gitlint
hatch run dev:gitlint --version
hatch run dev:gitlint --debug
# Unit tests
hatch run test:unit-tests
# Variations to run specific tests
hatch run test:unit-tests gitlint-core/gitlint/tests/rules/test_body_rules.py::BodyRuleTests::test_body_missing
hatch run test:unit-tests -k test_body_missing_merge_commit
hatch run test:unit-tests-no-cov # don't run test coverage
# Integration tests
hatch run qa:install-local # required step (1)
hatch run qa:integration-tests
# Formatting check (black)
hatch run test:format
# Linting (ruff)
hatch run test:lint
# Type Check (mypy)
hatch run test:type-check
# Run unit-tests and all style checks (format, lint, type-check)
hatch run test:all
# Project stats
hatch run test:stats
- Install the local gitlint source copy for integration testing.
The integration tests will just look for agitlint
command and test against that. This means you can also run integration tests against released versions of gitlint:
Autoformatting and autofixing¶
We use black for code formatting.
# format all python code
hatch run test:autoformat
# format a specific file
hatch run test:autoformat gitlint-core/gitlint/lint.py
We use ruff for linting, it can autofix many of the issue it finds (although not always perfect).
Documentation¶
We use mkdocs with Material for MkDocs for generating our documentation from markdown.
To use it:
Then access the documentation website on http://localhost:8000.
Tools¶
We keep a small set of scripts in the tools/
directory: