-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
100 lines (86 loc) · 2.89 KB
/
Makefile
File metadata and controls
100 lines (86 loc) · 2.89 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
.PHONY: all clean check test codestyle docstyle lint pip
PROJECT ?= driviz
TESTS ?= tests
SCRIPTS ?= scripts
all:
make clean
make lint || exit 1
make test || exit 1
clean:
rm -rf .pytest_cache
rm -rf .mypy_cache
rm -rf .ruff_cache
rm -f .coverage
rm -rf htmlcov
check: format lint
format:
uv run ruff format $(PROJECT) $(TESTS)
uv run ruff check --fix --unsafe-fixes $(PROJECT) $(TESTS) $(SCRIPTS)
lint:
uv run ruff format --check $(PROJECT) $(TESTS) $(SCRIPTS)
uv run ruff check $(PROJECT) $(TESTS) $(SCRIPTS)
uv run mypy $(PROJECT) $(SCRIPTS)
lock:
uv lock
test:
uv run pytest --cov --cov-report=html --cov-report=xml
test-unit:
uv run pytest --cov --cov-report=html --cov-report=xml -m "not integration"
test-integration:
uv run pytest -m "integration"
bump-version:
@make -- --check-git-status
@old_version=$$(uv version --dry-run --short); echo "Current version: $${old_version}"; \
bmp_vrs=$(COMMIT_VERSION); \
case $${bmp_vrs} in \
major|minor|patch) echo "Version bumping: $${bmp_vrs}"; uv version --bump $${bmp_vrs}; ;; \
*) echo "New version provided: $${bmp_vrs}"; uv version "$${bmp_vrs}"; ;; \
esac; \
new_version=$$(uv version --dry-run --short); \
if [ "$${new_version}" = "$${old_version}" ]; then \
echo "$${old_version} version update did not change the version number."; \
exit 0; \
else \
uv sync; \
uv run git commit pyproject.toml uv.lock -m ":bookmark: Bumping version from v$${old_version} to v$${new_version}"; \
git tag -a "v$${new_version}" -m ":bookmark: Bumping version from v$${old_version} to v$${new_version}"; \
echo "\nNew version: $${new_version}"; \
fi
--check-git-status:
@status=$$(git status --porcelain); \
if [ -n "$${status}" ]; \
then \
echo "ERROR:\n GIT status is not clean.\
\n Commit or discard your changes before using this script."; \
exit 1; \
fi
--setup-uv:
@echo "Checking if uv is installed ..."; \
uv_path=$$(command -v "uv"); \
if [ -z "$${uv_path}" ]; \
then \
echo "ERROR: uv not found.\
\n You should have uv installed in order to setup this project.\
\n https://docs.astral.sh/uv/getting-started/installation/\n"; \
exit 1; \
fi
@echo "Checking if uv.lock is up-to-date ..."; \
if uv lock --check > /dev/null 2>&1 ; \
then \
echo "uv.lock is up-to-date"; \
uv sync; \
uv run pre-commit install --install-hooks; \
else \
echo "uv.lock is NOT up-to-date."; \
echo "Update uv.lock and commit it."; \
uv sync; \
uv run pre-commit install --install-hooks; \
git add uv.lock; \
uv run pre-commit run --files uv.lock || true; \
uv run git commit .pre-commit-config.yaml uv.lock -m ":lock: Lock the project dependencies"; \
fi
setup:
@make -- --check-git-status || exit 1
@make -- --setup-uv || exit 1
@echo "Checking pre-commits ..."; poetry run pre-commit run --all-files || exit 1
@echo "\nSetup completed successfully!\n"; exit 0