-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
174 lines (128 loc) · 5.29 KB
/
Makefile
File metadata and controls
174 lines (128 loc) · 5.29 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# !make
# Copyright 2025 Itential Inc. All Rights Reserved
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# ==============================================================================
# ipsdk — HTTP client SDK for Itential Platform and Automation Gateway
# ==============================================================================
# Usage:
# make Show available targets
# make test Run unit tests
# make ci Run all checks (use before committing)
#
# Dependencies: uv (https://github.com/astral-sh/uv)
# ==============================================================================
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := help
.DELETE_ON_ERROR:
# ------------------------------------------------------------------------------
# Configuration
# ------------------------------------------------------------------------------
UV ?= uv
SRC := src/ipsdk
TESTS := tests
SCRIPTS := scripts
# ------------------------------------------------------------------------------
# Core
# ------------------------------------------------------------------------------
.PHONY: install test coverage build
install: ## Install dev environment and pre-commit hooks
$(UV) sync --all-extras --dev
$(UV) run pre-commit install -f
test: ## Run unit tests
$(UV) run pytest $(TESTS) -v
coverage: ## Run tests with coverage report (enforces 100%)
$(UV) run pytest \
--cov=$(SRC) \
--cov-report=term-missing \
--cov-report=html \
--cov-fail-under=100 \
$(TESTS)/
build: ## Build distribution packages (wheel + sdist)
$(UV) build
# ------------------------------------------------------------------------------
# Quality checks
# ------------------------------------------------------------------------------
.PHONY: hooks lint format format-check ruff-fix security typecheck license license-fix notice-check
typecheck: ## Run mypy static type checking
$(UV) run mypy $(SRC)
lint: ## Lint with ruff
$(UV) run ruff check $(SRC) $(TESTS)
format: ## Format source files with ruff
$(UV) run ruff format $(SRC) $(TESTS)
format-check: ## Check formatting without modifying files
$(UV) run ruff format --check $(SRC) $(TESTS)
ruff-fix: ## Auto-fix ruff lint issues
$(UV) run ruff check --fix $(SRC) $(TESTS)
security: ## Run bandit security analysis
$(UV) run bandit -r $(SRC) --configfile pyproject.toml
license: ## Check all Python files for license headers
$(UV) run python $(SCRIPTS)/check_license_headers.py
license-fix: ## Add missing license headers to Python files
$(UV) run python $(SCRIPTS)/check_license_headers.py --fix
hooks: ## Install pre-commit hooks (run once after cloning)
$(UV) run pre-commit install
notice-check: ## Verify NOTICE file lists all packages in uv.lock
@echo "Packages in uv.lock not mentioned in NOTICE:"
@grep -E '^name = "' uv.lock | sed 's/name = "\(.*\)"/\1/' | \
grep -v '^ipsdk$$' | \
while read pkg; do \
normalized=$$(echo "$$pkg" | tr '-' '.'); \
if ! grep -qi "$$pkg" NOTICE && ! grep -qi "$$normalized" NOTICE; then \
echo " MISSING: $$pkg"; \
fi \
done
@echo "Done."
# ------------------------------------------------------------------------------
# CI
# ------------------------------------------------------------------------------
.PHONY: ci
ci: clean lint format-check typecheck security license tox ## Run all checks (required before committing)
# ------------------------------------------------------------------------------
# Tox (multi-version)
# ------------------------------------------------------------------------------
.PHONY: tox tox-py310 tox-py311 tox-py312 tox-py313 tox-py314
.PHONY: tox-coverage tox-lint tox-format tox-security tox-ci tox-list
tox: ## Run tests across all Python versions (3.10-3.14)
$(UV) run tox
tox-py310: ## Run tests with Python 3.10
$(UV) run tox -e py310
tox-py311: ## Run tests with Python 3.11
$(UV) run tox -e py311
tox-py312: ## Run tests with Python 3.12
$(UV) run tox -e py312
tox-py313: ## Run tests with Python 3.13
$(UV) run tox -e py313
tox-py314: ## Run tests with Python 3.14
$(UV) run tox -e py314
tox-coverage: ## Run coverage report via tox
$(UV) run tox -e coverage
tox-lint: ## Run lint via tox
$(UV) run tox -e lint
tox-format: ## Run format via tox
$(UV) run tox -e format
tox-security: ## Run security scan via tox
$(UV) run tox -e security
tox-ci: ## Run all CI checks via tox
$(UV) run tox -e ci
tox-list: ## List all available tox environments
$(UV) run tox list
# ------------------------------------------------------------------------------
# Housekeeping
# ------------------------------------------------------------------------------
.PHONY: clean
clean: ## Remove build artifacts and caches
@rm -rf .pytest_cache .ruff_cache coverage.* htmlcov dist build *.egg-info
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
# ------------------------------------------------------------------------------
# Help
# ------------------------------------------------------------------------------
.PHONY: help
help: ## Show available targets
@echo "Usage: make <target>"
@echo ""
@grep -E '^[a-zA-Z_/-]+:.*##' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*##"}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' \
| sort
@echo ""