-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
137 lines (115 loc) · 3.91 KB
/
Makefile
File metadata and controls
137 lines (115 loc) · 3.91 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
# LeakIXClient-Python Makefile
.PHONY: help
help: ## Ask for help!
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; \
{printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: install
install: ## Install dependencies
uv sync
VERSION := $(shell python -c \
"import tomllib; \
print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
.PHONY: build
build: clean-dist ## Build the package
uv build
.PHONY: publish-dry-run
publish-dry-run: build ## Dry-run: show what would be published
@echo "Would publish leakix v$(VERSION)"
@echo "Would create tag: v$(VERSION)"
@echo "Would create GitHub release: v$(VERSION)"
@echo "Package contents:"
@ls -lh dist/
uv publish --dry-run
.PHONY: publish
publish: build ## Publish to PyPI, tag and create GitHub release
uv publish
git tag -a "v$(VERSION)" -m "Release v$(VERSION)"
git push origin "v$(VERSION)"
gh release create "v$(VERSION)" dist/* \
--title "v$(VERSION)" \
--notes "Release v$(VERSION)"
.PHONY: clean-dist
clean-dist: ## Clean distribution artifacts
rm -rf dist/
.PHONY: test
test: ## Run tests
uv run pytest
.PHONY: test-cov
test-cov: ## Run tests with coverage
uv run pytest --cov=leakix --cov-report=term-missing
.PHONY: format
format: ## Format code with ruff
uv run ruff format leakix/ tests/ example/ executable/
.PHONY: check-format
check-format: ## Check code formatting
uv run ruff format --check leakix/ tests/ example/ executable/
.PHONY: lint
lint: ## Run ruff linter
uv run ruff check leakix/ tests/ example/ executable/
.PHONY: lint-fix
lint-fix: ## Run ruff linter with auto-fix
uv run ruff check --fix leakix/ tests/ example/ executable/
.PHONY: lint-shell
lint-shell: ## Lint shell scripts using shellcheck
shellcheck .github/scripts/*.sh
.PHONY: typecheck
typecheck: ## Run mypy type checker
uv run mypy leakix/
.PHONY: audit
audit: ## Run security audit
uv run pip-audit
.PHONY: check
check: check-format lint typecheck test ## Run all checks
.PHONY: check-outdated
check-outdated: ## Check for outdated dependencies
uv pip list --outdated || true
.PHONY: clean
clean: ## Clean build artifacts
rm -rf dist/ build/ *.egg-info/ .pytest_cache/ .mypy_cache/ .ruff_cache/
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete 2>/dev/null || true
# Trailing whitespace targets
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
SED := $(shell command -v gsed 2>/dev/null)
ifeq ($(SED),)
$(error GNU sed (gsed) not found on macOS. Install with: brew install gnu-sed)
endif
else
SED := sed
endif
.PHONY: fix-trailing-whitespace
fix-trailing-whitespace: ## Remove trailing whitespaces from all files
@echo "Removing trailing whitespaces from all files..."
@find . -type f \( \
-name "*.py" -o -name "*.toml" -o -name "*.md" -o -name "*.yaml" \
-o -name "*.yml" -o -name "*.json" \) \
-not -path "./.git/*" \
-not -path "./.mypy_cache/*" \
-not -path "./.pytest_cache/*" \
-not -path "./.ruff_cache/*" \
-exec sh -c \
'$(SED) -i -e "s/[[:space:]]*$$//" "$$1"' \
_ {} \; && \
echo "Trailing whitespaces removed."
.PHONY: check-trailing-whitespace
check-trailing-whitespace: ## Check for trailing whitespaces in source files
@echo "Checking for trailing whitespaces..."
@files_with_trailing_ws=$$(find . -type f \( \
-name "*.py" -o -name "*.toml" -o -name "*.md" -o -name "*.yaml" \
-o -name "*.yml" -o -name "*.json" \) \
-not -path "./.git/*" \
-not -path "./.mypy_cache/*" \
-not -path "./.pytest_cache/*" \
-not -path "./.ruff_cache/*" \
-exec grep -l '[[:space:]]$$' {} + 2>/dev/null || true); \
if [ -n "$$files_with_trailing_ws" ]; then \
echo "Files with trailing whitespaces found:"; \
echo "$$files_with_trailing_ws" | sed 's/^/ /'; \
echo ""; \
echo "Run 'make fix-trailing-whitespace' to fix automatically."; \
exit 1; \
else \
echo "No trailing whitespaces found."; \
fi