.PHONY: all setup setup-ci setup-quality setup-release install update lint lint-all test test-unit pytest-cov clean install-tools install-hooks activate-scripts checkmake check-mutable-globals check-dep-docs check-test-speed PYTHON := python3 VENV := .venv BIN := $(VENV)/bin all: setup # Full setup for local development setup: $(VENV)/bin/activate .env activate-scripts install-tools @$(BIN)/pip install -e '.[dev]' 2>/dev/null; \ export PATH="$(HOME)/.local/bin:$$PATH"; \ $(BIN)/python -m devx.tools.setup --bin "$(BIN)" # Lean setup for CI jobs (pytest + lint + runtime deps) setup-ci: $(VENV)/bin/activate .env @$(BIN)/pip install -e '.[ci,lint]' 2>/dev/null; \ $(BIN)/python -m devx.tools.setup --bin "$(BIN)" --extras "ci,lint" --no-pre-commit --no-tea-login # Setup for quality job (lint + test deps, actionlint tool) setup-quality: $(VENV)/bin/activate .env install-tools @$(BIN)/pip install -e '.[ci,lint]' 2>/dev/null; \ export PATH="$(HOME)/.local/bin:$$PATH"; \ $(BIN)/python -m devx.tools.setup --bin "$(BIN)" --extras "ci,lint" --no-pre-commit --no-tea-login # Setup for release jobs (needs git-cliff, tea, lint tools) setup-release: $(VENV)/bin/activate .env @$(BIN)/pip install -e '.[ci,lint]' 2>/dev/null; \ $(BIN)/python -m devx.tools.install_tools --tool git-cliff --tool tea; \ export PATH="$(HOME)/.local/bin:$$PATH"; \ $(BIN)/python -m devx.tools.setup --bin "$(BIN)" --extras "ci,lint" --no-pre-commit .env: @if [ ! -f .env ]; then cp .env.example .env; echo "Created .env from .env.example — please edit it."; fi $(VENV)/bin/activate: @python3 -c "import sys; v=sys.version_info; assert v >= (3, 12), f'Python 3.12+ required, found {v.major}.{v.minor}'; print(f'Python {v.major}.{v.minor}.{v.micro} OK')" $(PYTHON) -m venv $(VENV) $(BIN)/pip install --upgrade pip setuptools wheel activate-scripts: $(VENV)/bin/activate @test -f activate.sh || (echo '#!/usr/bin/env bash' > activate.sh && echo 'source "$$(cd "$$(dirname "$${BASH_SOURCE[0]}")" && pwd)/.venv/bin/activate"' >> activate.sh && chmod +x activate.sh) @test -f activate.fish || (echo '#!/usr/bin/env fish' > activate.fish && echo 'set -l script_dir (dirname (status --current-filename))' >> activate.fish && echo 'source "$$script_dir/.venv/bin/activate.fish"' >> activate.fish && chmod +x activate.fish) @test -f activate.zsh || (echo '#!/usr/bin/env zsh' > activate.zsh && echo '0="$${ZERO:-$${0:#$$ZSH_ARGZERO}}"' >> activate.zsh && echo '0="$${$${(M)0:#/*}:-$$PWD/$$0}"' >> activate.zsh && echo 'source "$${0:A:h}/.venv/bin/activate"' >> activate.zsh && chmod +x activate.zsh) install-hooks: @cp hooks/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit @cp hooks/pre-push .git/hooks/pre-push && chmod +x .git/hooks/pre-push @echo "Git hooks installed." install-tools: $(VENV)/bin/activate @$(BIN)/pip install -e '.' 2>/dev/null; \ $(BIN)/python -m devx.tools.install_tools # --- devx.mak integration ---------------------------------------------------- # Include shared targets from the devx package itself (workflow-lint, # notify-failure, checkmake, lint targets, quality checks, etc.) # Since devx IS the package, we can include its own devx.mak. DEVX_PYTHON := $(BIN)/python DEVX_VENV := $(VENV) DEVX_BIN := $(BIN) DEVX_LINT_PATHS := src/ tests/ DEVX_COV_PKG := src/devx DEVX_TEST_PATHS := tests/ DEVX_MAK := $(shell $(BIN)/python -c \ "from pathlib import Path; import devx; print(Path(devx.__file__).parent / 'make' / 'devx.mak')" \ 2>/dev/null) -include $(DEVX_MAK) # Aliases — project-specific names map to devx.mak targets lint-ruff: devx-lint-ruff lint-format: devx-lint-format typecheck: devx-typecheck lint-bandit: devx-lint-bandit lint-deps: devx-lint-deps lint: devx-lint workflow-lint: devx-workflow-lint workflow-dryrun: devx-workflow-dryrun workflow-dryrun-safe: devx-workflow-dryrun-safe workflow-check: devx-workflow-check notify-failure: devx-notify-failure checkmake: devx-checkmake check-mutable-globals: devx-check-mutable-globals check-dep-docs: devx-check-dep-docs check-test-speed: devx-check-test-speed check-test-coverage: devx-check-test-coverage check-docs: devx-check-docs create-task: devx-create-task create-pr: devx-create-pr push-with-pr: devx-push-with-pr git-push: devx-push lint-all: lint workflow-lint @echo "[lint-all] All linting checks passed." test-unit: devx-test-unit pytest-cov: devx-pytest-cov test: pytest-cov pre-push: lint-all pytest-cov @echo "[pre-push] All checks passed. Proceeding with push." clean: devx-clean @echo "[clean] Done."