-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
136 lines (109 loc) · 4.44 KB
/
Makefile
File metadata and controls
136 lines (109 loc) · 4.44 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
SHELL := /bin/bash
# Define colors for better output
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
# Project information
PACKAGE = goal
PYTHON = python3
PIP = pip3
PYTEST = python3 -m pytest
MYPY = python3 -m mypy
BLACK = python3 -m black
ISORT = python3 -m isort
FLAKE8 = python3 -m flake8
COVERAGE = python3 -m coverage
PART = patch
.PHONY: help install dev test build publish clean push benchmark benchmark-ci benchmark-json deps-cache deps-lock test-offline
help:
@echo "Targets:"
@echo " make install - install goal locally"
@echo " make dev - install in development mode"
@echo " make test - run tests"
@echo " make build - build package for PyPI"
@echo " make publish - build and upload to PyPI"
@echo " make clean - remove build artifacts"
@echo " make push - use goal to push changes"
@echo " make benchmark - run performance benchmark"
@echo " make benchmark-ci - benchmark for CI (plain, threshold)"
@echo " make benchmark-json - benchmark JSON output"
@echo " make deps-cache - download all deps to local wheel cache"
@echo " make deps-lock - freeze current versions to requirements-lock.txt"
@echo " make test-offline - run tests without network (uses cached deps)"
install:
pip install .
dev:
pip install -e ".[dev]"
test:
python -m pytest -q
build: clean
python -m pip install --upgrade build twine
python -m build --sdist --wheel
publish: bump-version build
python -m twine upload dist/*
clean:
rm -rf dist build *.egg-info .pytest_cache __pycache__ goal/__pycache__
push: bump-version
@if command -v goal &> /dev/null; then \
goal push; \
else \
echo "Goal not installed. Run 'make install' first."; \
fi
benchmark:
$(PYTHON) -m regix.benchmark
benchmark-ci:
$(PYTHON) -m regix.benchmark --plain --threshold 30.0
benchmark-json:
$(PYTHON) -m regix.benchmark --json > .pyqual/benchmark.json
docker-matrix:
bash integration/run_docker_matrix.sh
# ── Dependency caching ──────────────────────────────────────────────────────
WHEEL_CACHE := .wheels
deps-cache:
@echo "${YELLOW}Downloading all deps to local wheel cache...${RESET}"
mkdir -p $(WHEEL_CACHE)
$(PIP) download -d $(WHEEL_CACHE) -e ".[dev]"
@echo "${GREEN}Cached $$(ls $(WHEEL_CACHE) | wc -l) wheels in $(WHEEL_CACHE)/${RESET}"
deps-lock:
@echo "${YELLOW}Freezing current versions...${RESET}"
$(PIP) freeze --exclude-editable > requirements-lock.txt
@echo "${GREEN}Wrote requirements-lock.txt${RESET}"
test-offline:
@echo "${YELLOW}Running tests offline (no network)...${RESET}"
$(PYTHON) -m pytest tests/ -q --tb=short -p no:cacheprovider
@echo "${GREEN}Offline tests complete${RESET}"
# ── Install from local cache (no internet) ──────────────────────────────────
install-offline:
@if [ ! -d "$(WHEEL_CACHE)" ]; then \
echo "${YELLOW}No wheel cache found. Run 'make deps-cache' first.${RESET}"; \
exit 1; \
fi
$(PIP) install --no-index --find-links=$(WHEEL_CACHE) -e ".[dev]"
## Bump version (e.g., make bump-version PART=patch)
bump-version:
@if [ -z "$(PART)" ]; then \
echo "${YELLOW}Error: PART variable not set. Usage: make bump-version PART=<major|minor|patch>${RESET}"; \
exit 1; \
fi
@echo "${YELLOW}Bumping $(PART) version...${RESET}"
@current_version=$$(grep '^version = ' pyproject.toml | head -1 | sed 's/version = "\(.*\)"/\1/'); \
echo "Current version: $$current_version"; \
IFS='.' read -r major minor patch <<< "$$current_version"; \
case "$(PART)" in \
major) major=$$((major + 1)); minor=0; patch=0 ;; \
minor) minor=$$((minor + 1)); patch=0 ;; \
patch) patch=$$((patch + 1)) ;; \
*) echo "${YELLOW}Error: PART must be major, minor, or patch${RESET}"; exit 1 ;; \
esac; \
new_version="$${major}.$${minor}.$${patch}"; \
sed -i "s/^version = \"$$current_version\"/version = \"$$new_version\"/" pyproject.toml; \
echo "${GREEN}Version bumped to $$new_version${RESET}"; \
git add pyproject.toml; \
git commit -m "Bump version to $$new_version"; \
if git rev-parse "v$$new_version" >/dev/null 2>&1; then \
echo "${YELLOW}Error: tag 'v$$new_version' already exists${RESET}"; \
exit 1; \
fi; \
git tag -a "v$$new_version" -m "Version $$new_version"; \
echo "${GREEN}Created tag v$$new_version${RESET}"