-
-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathdefault.mk
More file actions
93 lines (73 loc) · 2.47 KB
/
default.mk
File metadata and controls
93 lines (73 loc) · 2.47 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
#
# default.mk
#
SRC = src test
default: help
help-default:
@echo 'Available commands:'
@echo
@echo ' make test Run all linting and unit tests'
@echo ' make watch Run all tests, watching for changes'
@echo ' make check Format & Lint & Typecheck changed files from master'
@echo
# check formatting before lint, since an autoformat might fix linting issues
test-default: check-formatting check-linting check-typing unittest
.sanity-check:
@echo '==> Checking your Python setup'
@if python -c "import sys; exit(0 if sys.platform.startswith('win32') else 1)"; then \
echo 'ERROR: you are using a non-WSL Python interpreter, please consult the'; \
echo ' docs on how to swich to WSL Python on windows'; \
echo ' https://github.com/owid/etl/'; \
exit 1; \
fi
touch .sanity-check
check-uv-default:
@if ! command -v uv >/dev/null 2>&1; then \
echo 'ERROR: uv is not installed.'; \
echo 'Install it with: curl -LsSf https://astral.sh/uv/install.sh | sh'; \
echo 'Or see: https://docs.astral.sh/uv/getting-started/installation/'; \
exit 1; \
fi
.venv-default: check-uv .sanity-check
@echo '==> Installing packages'
@if [ -n "$(PYTHON_VERSION)" ]; then \
echo '==> Using Python version $(PYTHON_VERSION)'; \
UV_PYTHON=$(PYTHON_VERSION) uv sync --all-extras --group dev; \
else \
uv sync --all-extras --group dev; \
fi
check-default:
@make lint
@make format
@make check-typing
lint-default: .venv
@echo '==> Linting & Sorting imports'
@.venv/bin/ruff check --fix $(SRC)
check-linting-default: .venv
@echo '==> Checking linting'
@.venv/bin/ruff check $(SRC)
check-formatting-default: .venv
@echo '==> Checking formatting'
@.venv/bin/ruff format --check $(SRC)
check-typing-default: .venv
@echo '==> Checking types'
.venv/bin/ty check $(SRC) --python .venv
unittest-default: .venv
@echo '==> Running unit tests'
.venv/bin/pytest $(SRC)
format-default: .venv
@echo '==> Reformatting files'
@.venv/bin/ruff format $(SRC)
coverage-default: .venv
@echo '==> Unit testing with coverage'
.venv/bin/pytest --cov=owid --cov-report=term-missing tests
watch-default: .venv
@echo '==> Watching for changes and re-running checks'
.venv/bin/watchmedo shell-command -c 'clear; make check' --recursive --drop .
bump-default: .venv
@echo '==> Bumping version'
.venv/bin/bump2version --no-tag --no-commit $(filter-out $@, $(MAKECMDGOALS))
# allow you to override a command, e.g. "watch", but if you do not, then use
# the default
%: %-default
@true