-
Notifications
You must be signed in to change notification settings - Fork 260
Expand file tree
/
Copy pathMakefile
More file actions
109 lines (75 loc) · 4.21 KB
/
Makefile
File metadata and controls
109 lines (75 loc) · 4.21 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
# Basic Usage:
# make <rule> : Run a specific rule (e.g., make test)
# make VAR=value <rule> : Run rule with environment variable (e.g., make DOCS_PORT=8080 docs-serve)
#
# Common Rules: help, clean, test, format, lint, docs-serve
#
# Rules can depend on other rules which run first. Rules with _ prefix are internal helpers.
MODULE_NAME = soccerdata
DOCS_PORT ?= 8000
SOCCERDATA_DIR ?= tests/appdata
.DEFAULT_GOAL := help
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Utilities ━━━━━━━━━━━━━━━━━━━━━━━━━━━ #
.PHONY: all help
all: help
help: ## Show this help message
@echo "\n\033[1m~ Available rules: ~\033[0m\n"
@echo "For VSCode/Cursor, try: ⇧ ⌘ P, Tasks: Run Task\n"
@grep -E '^[a-zA-Z][a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[38;5;222m%-30s\033[0m %s\n", $$1, $$2}'
# ━━━━━━━━━━━━━━━━━━━━━━━ Filesystem Cleaning ━━━━━━━━━━━━━━━━━━━━━━ #
.PHONY: clean _clean-mac _clean-python
clean: _clean-mac _clean-python ## Delete all compiled Python files and macOS-related files
find . -type d -name ".cache" -delete
_clean-mac: ## Clean macOS-related files
find . -type f -name "*.DS_store" -delete
_clean-python: ## Clean all compiled Python files
find . -type f -name "*.py[co]" -delete
find . -type d -name "__pycache__" -delete
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Testing ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ #
.PHONY: test test-fastest test-continuous test-debug-last _clean_manual_test
test: ## Run all tests
SOCCERDATA_DIR=$(SOCCERDATA_DIR) MAX_AGE=604800 \
pytest \
--cov=$(MODULE_NAME)
test-class: ## Run tests in a specific class
SOCCERDATA_DIR=$(SOCCERDATA_DIR) MAX_AGE=604800 \
pytest -k "$(filter-out $@,$(MAKECMDGOALS))" --cov=$(MODULE_NAME)
test-continuous: ## Run tests in watch mode using pytest-watcher
SOCCERDATA_DIR=$(SOCCERDATA_DIR) MAX_AGE=604800 \
ptw . --now --runner pytest --config-file pyproject.toml
test-debug-last: ## Debug last failed test with pdb
SOCCERDATA_DIR=$(SOCCERDATA_DIR) MAX_AGE=604800 \
pytest --lf --pdb
# ━━━━━━━━━━━━━━━━━━━━━━━━━ Quality Assurance ━━━━━━━━━━━━━━━━━━━━━━━ #
.PHONY: lint format mypy
lint: ## Lint using ruff (use `make format` to do formatting)
ruff check --config pyproject.toml $(MODULE_NAME)
format: ## Format source code
ruff format --config pyproject.toml $(MODULE_NAME)
mypy: ## Type check using mypy
mypy --install-types --non-interactive --config-file pyproject.toml $(MODULE_NAME) tests
# ━━━━━━━━━━━━━━━━━━━━━━━━━━ Documentation ━━━━━━━━━━━━━━━━━━━━━━━━━ #
.PHONY: docs-serve docs-build
docs-serve: ## Serve documentation locally on port $(DOCS_PORT)
sphinx-autobuild --host=0.0.0.0 --port=$(DOCS_PORT) docs docs/_build || \
echo "\n\nInstance found running on $(DOCS_PORT), try killing process and rerun."
# Makes sure docs can be served prior to actually deploying
docs-build: ## Build and deploy documentation to GitHub Pages
sphinx-build docs docs/_build
# ━━━━━━━━━━━━━━━━━━━━━ Packaging & Environment ━━━━━━━━━━━━━━━━━━━━ #
.PHONY: create-env
create-env: ## Set up python interpreter environment
uv venv
@echo ">>> New virtualenv with uv created. Activate with:\nsource '.venv/bin/activate'"
.PHONY: requirements
requirements: ## Install Python Dep
uv sync
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━ Pre-Commits ━━━━━━━━━━━━━━━━━━━━━━━━━━ #
.PHONY: pre-commit-test pre-commit-update
pre-commit-test: ## Test hooks
pre-commit run --all-files --show-diff-on-failure
git add .pre-commit-config.yaml
pre-commit-update: ## Update, install, and test hooks w/ new config
pre-commit autoupdate
pre-commit install
$(MAKE) pre-commit-test