-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
142 lines (112 loc) · 3.1 KB
/
Makefile
File metadata and controls
142 lines (112 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#* Variables
SHELL := /usr/bin/env bash -o pipefail
PYTHON := python3
#* Directories with source code
CODE = {{ cookiecutter.package_name }} tests
TESTS = tests
#* uv package manager
.PHONY: uv-install
uv-install:
curl -LsSf https://astral.sh/uv/install.sh | sh
#* Installation
.PHONY: install
install:
uv sync
.PHONY: pre-commit-install
pre-commit-install:
uv run pre-commit install
#* Formatters
.PHONY: codestyle
codestyle:
uv run ruff format $(CODE)
uv run ruff check $(CODE) --fix-only
.PHONY: format
format: codestyle
#* Test
.PHONY: test
test:
uv run pytest
uv run coverage xml
# Validate dependencies
.PHONY: check-uv
check-uv:
uv lock --check
.PHONY: check-deptry
check-deptry:
uv run deptry .
.PHONY: check-dependencies
check-dependencies: check-uv check-deptry
#* Static linters
.PHONY: check-ruff
check-ruff:
uv run ruff check $(CODE) --no-fix
.PHONY: check-codestyle
check-codestyle:
uv run ruff format $(CODE) --check
{% if cookiecutter.git_platform == 'gitlab' %}
.PHONY: check-ruff-gitlab
check-ruff-gitlab:
uv run ruff check $(CODE) --output-format=gitlab > ruff-report.json
{% endif %}
{% if cookiecutter.git_platform == 'github' %}
.PHONY: check-ruff-github
check-ruff-github:
uv run ruff check $(CODE) --no-fix --output-format=github
{% endif %}
.PHONY: check-mypy
check-mypy:
uv run mypy --install-types --non-interactive --config-file pyproject.toml $(CODE)
{% if cookiecutter.git_platform == 'gitlab' %}
.PHONY: check-mypy-gitlab
check-mypy-gitlab:
uv run mypy --install-types --non-interactive --no-error-summary --no-pretty --config-file pyproject.toml $(CODE) \
2>&1 | uv run mypy-gitlab-code-quality > mypy-report.json
{% endif %}
.PHONY: static-lint
static-lint: check-ruff check-mypy
#* Check safety
.PHONY: check-safety
check-safety:
uv run safety check --full-report
.PHONY: lint
lint: check-dependencies check-codestyle static-lint
# Currently not supported in uv: https://github.com/astral-sh/uv/issues/6794
#.PHONY: update-dev-deps
#update-dev-deps:
# poetry add -G dev mypy@latest pre-commit@latest pytest@latest deptry@latest \
# coverage@latest safety@latest typeguard@latest ruff@latest
.PHONY: update
update:
uv lock --upgrade
# Docker compose
.PHONY: docker-up
docker-up:
docker compose up
#* Cleaning
.PHONY: pycache-remove
pycache-remove:
find . | grep -E "(__pycache__|\.pyc|\.pyo$$)" | xargs rm -rf || true
.PHONY: dsstore-remove
dsstore-remove:
find . | grep -E ".DS_Store" | xargs rm -rf || true
.PHONY: mypycache-remove
mypycache-remove:
find . | grep -E ".mypy_cache" | xargs rm -rf || true
.PHONY: ipynbcheckpoints-remove
ipynbcheckpoints-remove:
find . | grep -E ".ipynb_checkpoints" | xargs rm -rf || true
.PHONY: pytestcache-remove
pytestcache-remove:
find . | grep -E ".pytest_cache" | xargs rm -rf || true
.PHONY: ruffcache-remove
ruffcache-remove:
find . | grep -E ".ruff_cache" | xargs rm -rf || true
.PHONY: build-remove
build-remove:
rm -rf build/
.PHONY: reports-remove
reports-remove:
rm -rf reports/
.PHONY: cleanup
cleanup: pycache-remove dsstore-remove mypycache-remove ruffcache-remove \
ipynbcheckpoints-remove pytestcache-remove reports-remove