-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
153 lines (111 loc) · 4.56 KB
/
Makefile
File metadata and controls
153 lines (111 loc) · 4.56 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
# !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)
# ==============================================================================
# asyncgateway — async Python client for Itential 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/asyncgateway
TESTS := tests
# ------------------------------------------------------------------------------
# Core
# ------------------------------------------------------------------------------
.PHONY: install test coverage coverage-html build
install: ## Install all dependencies including dev group
$(UV) sync --group dev
test: ## Run unit tests
$(UV) run pytest $(TESTS)
coverage: ## Run tests with XML coverage report (matches CI output)
$(UV) run pytest \
--cov=$(SRC) \
--cov-report=term-missing \
--cov-report=xml \
$(TESTS)/
coverage-html: ## Run tests with HTML coverage report (local browsing)
$(UV) run pytest \
--cov=$(SRC) \
--cov-report=term \
--cov-report=html \
$(TESTS)/
build: ## Build distribution packages (wheel + sdist)
$(UV) build
# ------------------------------------------------------------------------------
# Quality checks
# ------------------------------------------------------------------------------
.PHONY: lint format format-check typecheck security
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)
typecheck: ## Run static type analysis with mypy
$(UV) run mypy src/
security: ## Run bandit security analysis
$(UV) run bandit -r $(SRC) --configfile pyproject.toml
# ------------------------------------------------------------------------------
# CI
# ------------------------------------------------------------------------------
.PHONY: ci
ci: format-check lint typecheck security tox ## Run all quality gates (matches CI pipeline)
# ------------------------------------------------------------------------------
# Tox (multi-version)
# ------------------------------------------------------------------------------
.PHONY: tox tox-py310 tox-py311 tox-py312 tox-py313
.PHONY: tox-coverage tox-lint tox-security tox-list
tox: ## Run tests across all Python versions (3.10-3.13)
$(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-coverage: ## Run coverage report via tox
$(UV) run tox -e coverage
tox-lint: ## Run lint via tox
$(UV) run tox -e lint
tox-security: ## Run security scan via tox
$(UV) run tox -e security
tox-list: ## List all available tox environments
$(UV) run tox list
# ------------------------------------------------------------------------------
# Development
# ------------------------------------------------------------------------------
.PHONY: setup
setup: ## Set up development environment with pre-commit hooks
@./scripts/setup-pre-commit.sh
# ------------------------------------------------------------------------------
# Housekeeping
# ------------------------------------------------------------------------------
.PHONY: clean
clean: ## Remove build artifacts and caches
@rm -rf .pytest_cache .ruff_cache .tox 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 ""