|
| 1 | +.PHONY: all format lint test tests test_watch integration_tests docker_tests help extended_tests |
| 2 | + |
| 3 | +# Default target executed when no arguments are given to make. |
| 4 | +all: help |
| 5 | + |
| 6 | +# Define a variable for the test file path. |
| 7 | +TEST_FILE ?= tests/unit_tests/ |
| 8 | + |
| 9 | +test: |
| 10 | + python -m pytest $(TEST_FILE) |
| 11 | + |
| 12 | +test_watch: |
| 13 | + python -m ptw --snapshot-update --now . -- -vv tests/unit_tests |
| 14 | + |
| 15 | +test_profile: |
| 16 | + python -m pytest -vv tests/unit_tests/ --profile-svg |
| 17 | + |
| 18 | +extended_tests: |
| 19 | + python -m pytest --only-extended $(TEST_FILE) |
| 20 | + |
| 21 | + |
| 22 | +###################### |
| 23 | +# LINTING AND FORMATTING |
| 24 | +###################### |
| 25 | + |
| 26 | +# Define a variable for Python and notebook files. |
| 27 | +PYTHON_FILES=src/ |
| 28 | +MYPY_CACHE=.mypy_cache |
| 29 | +lint format: PYTHON_FILES=. |
| 30 | +lint_diff format_diff: PYTHON_FILES=$(shell git diff --name-only --diff-filter=d main | grep -E '\.py$$|\.ipynb$$') |
| 31 | +lint_package: PYTHON_FILES=src |
| 32 | +lint_tests: PYTHON_FILES=tests |
| 33 | +lint_tests: MYPY_CACHE=.mypy_cache_test |
| 34 | + |
| 35 | +lint lint_diff lint_package lint_tests: |
| 36 | + python -m ruff check . |
| 37 | + [ "$(PYTHON_FILES)" = "" ] || python -m ruff format $(PYTHON_FILES) --diff |
| 38 | + [ "$(PYTHON_FILES)" = "" ] || python -m ruff check --select I $(PYTHON_FILES) |
| 39 | + [ "$(PYTHON_FILES)" = "" ] || python -m mypy --strict $(PYTHON_FILES) |
| 40 | + [ "$(PYTHON_FILES)" = "" ] || mkdir -p $(MYPY_CACHE) && python -m mypy --strict $(PYTHON_FILES) --cache-dir $(MYPY_CACHE) |
| 41 | + |
| 42 | +format format_diff: |
| 43 | + ruff format $(PYTHON_FILES) |
| 44 | + ruff check --select I --fix $(PYTHON_FILES) |
| 45 | + |
| 46 | +spell_check: |
| 47 | + codespell --toml pyproject.toml |
| 48 | + |
| 49 | +spell_fix: |
| 50 | + codespell --toml pyproject.toml -w |
| 51 | + |
| 52 | +###################### |
| 53 | +# HELP |
| 54 | +###################### |
| 55 | + |
| 56 | +help: |
| 57 | + @echo '----' |
| 58 | + @echo 'format - run code formatters' |
| 59 | + @echo 'lint - run linters' |
| 60 | + @echo 'test - run unit tests' |
| 61 | + @echo 'tests - run unit tests' |
| 62 | + @echo 'test TEST_FILE=<test_file> - run all tests in file' |
| 63 | + @echo 'test_watch - run unit tests in watch mode' |
| 64 | + |
0 commit comments