-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
148 lines (118 loc) · 3.87 KB
/
Makefile
File metadata and controls
148 lines (118 loc) · 3.87 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
143
144
145
146
147
148
### Defensive settings for make:
# https://tech.davis-hansson.com/p/make/
SHELL:=bash
.ONESHELL:
.SHELLFLAGS:=-xeu -o pipefail -O inherit_errexit -c
.SILENT:
.DELETE_ON_ERROR:
MAKEFLAGS+=--warn-undefined-variables
MAKEFLAGS+=--no-builtin-rules
# We like colors
# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects
RED=`tput setaf 1`
GREEN=`tput setaf 2`
RESET=`tput sgr0`
YELLOW=`tput setaf 3`
# Python checks
UV?=uv
# installed?
ifeq (, $(shell which $(UV) ))
$(error "UV=$(UV) not found in $(PATH)")
endif
ROOT_FOLDER=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
GIT_FOLDER=$(ROOT_FOLDER)/.git
VENV_FOLDER=$(ROOT_FOLDER)/.venv
# Environment variables to be exported
export PYTHONWARNINGS := ignore
all: build
# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
.PHONY: help
help: ## This help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
$(VENV_FOLDER): ## Install dependencies
@echo "$(GREEN)==> Install environment$(RESET)"
@uv sync --all-extras
.PHONY: sync
sync: $(VENV_FOLDER) ## Sync project dependencies
@echo "$(GREEN)==> Sync project dependencies$(RESET)"
@uv sync --all-extras
.PHONY: install
install: $(VENV_FOLDER) ## Install environment
.PHONY: clean
clean: ## Clean installation
@echo "$(RED)==> Cleaning environment and build$(RESET)"
@rm -rf $(VENV_FOLDER) .*_cache .coverage
############################################
# QA
############################################
.PHONY: lint
lint: ## Check and fix code base
@echo "$(GREEN)==> Lint codebase$(RESET)"
@uvx ruff@latest check --fix --config pyproject.toml
.PHONY: lint-mypy
lint-mypy: ## Check type hints
@echo "$(GREEN)==> Check type hints$(RESET)"
@uvx mypy src
.PHONY: lint-pyroma
lint-pyroma: ## Check package health
@echo "$(GREEN)==> Check package health$(RESET)"
@uvx pyroma .
.PHONY: lint-python-versions
lint-python-versions: ## Check python versions
@echo "$(GREEN)==> Check package health$(RESET)"
@uvx check-python-versions .
.PHONY: format
format: ## Check and fix code base formatting
@echo "$(GREEN)==> Format codebase$(RESET)"
@uvx ruff@latest check --select I --fix --config pyproject.toml
@uvx ruff@latest format --config pyproject.toml
.PHONY: check
check: format lint lint-mypy ## Check and fix code base
.PHONY: check-package
check-package: lint-pyroma lint-python-versions ## Check package information and metadata
############################################
# Tests
############################################
.PHONY: test
test: $(VENV_FOLDER) ## run tests
@uv run pytest
.PHONY: test-coverage
test-coverage: $(VENV_FOLDER) ## run tests with coverage
@uv run coverage run -m pytest
@uv run coverage combine
@uv run coverage report
############################################
# Documentation
############################################
.PHONY: docs-html
docs-html: $(VENV_FOLDER) ## Build HTML documentation
@make -C ./docs html
.PHONY: docs-livehtml
docs-livehtml: $(VENV_FOLDER) ## Build documentation and serve it
@make -C ./docs livehtml
.PHONY: docs-vale
docs-vale: $(VENV_FOLDER) ## Run vale on the documentation
@make -C ./docs vale
.PHONY: docs-linkcheckbroken
docs-linkcheckbroken: $(VENV_FOLDER) ## Run checks for broken links
@make -C ./docs linkcheckbroken
.PHONY: docs-test
docs-test: $(VENV_FOLDER) ## Run tests on the documentation
@make -C ./docs test
############################################
# Release
############################################
.PHONY: changelog
changelog: ## Display the draft of the changelog
@echo "🚀 Display the draft for the changelog"
@uv run towncrier --draft
.PHONY: release
release: ## Release the package to pypi.org
@echo "🚀 Release package"
@uv run prerelease
@uv run release
@rm -Rf dist
@uv build
@uv publish
@uv run postrelease