340 lines
12 KiB
Makefile
340 lines
12 KiB
Makefile
# NoteFlow Quality Checks
|
|
# Runs TypeScript, Rust, and Python quality checks
|
|
|
|
.PHONY: all quality quality-ts quality-rs quality-py lint type-check test-quality coverage coverage-ts \
|
|
lint-rs clippy fmt fmt-rs fmt-check check help e2e e2e-ui e2e-grpc \
|
|
ensure-py ensure-ts ensure-rs ensure-hygiene install-hooks uninstall-hooks \
|
|
test test-ts test-rs test-py
|
|
|
|
# Default target
|
|
all: quality
|
|
|
|
# Optional path arguments for Python targets (space-separated).
|
|
# Example: make lint-py PY_TARGETS="src/noteflow/foo.py tests/"
|
|
PY_TARGETS ?=
|
|
HYGIENE_DIR ?= ./.hygeine
|
|
HYGIENE_DIR_ABS := $(abspath $(HYGIENE_DIR))
|
|
VENV_DIR ?= .venv
|
|
VENV_BIN := $(VENV_DIR)/bin
|
|
ACTIVATE_VENV = if [ -f "$(VENV_BIN)/activate" ]; then . "$(VENV_BIN)/activate"; fi
|
|
|
|
#-------------------------------------------------------------------------------
|
|
# Dependency Checks
|
|
#-------------------------------------------------------------------------------
|
|
|
|
## Ensure Python tooling is installed
|
|
ensure-py: ensure-hygiene
|
|
@$(ACTIVATE_VENV); \
|
|
if [ -x "$(VENV_BIN)/python" ]; then \
|
|
PYTHON_BIN="$(VENV_BIN)/python"; \
|
|
elif command -v python >/dev/null 2>&1; then \
|
|
PYTHON_BIN="python"; \
|
|
else \
|
|
echo "Python not found. Install Python 3.12+ or create $(VENV_DIR)."; \
|
|
exit 1; \
|
|
fi; \
|
|
missing=""; \
|
|
for tool in ruff basedpyright sourcery pytest; do \
|
|
if ! command -v $$tool >/dev/null 2>&1; then missing="$$missing $$tool"; fi; \
|
|
done; \
|
|
if [ -n "$$missing" ]; then \
|
|
echo "Installing Python tooling:$$missing"; \
|
|
"$$PYTHON_BIN" -m pip install -e ".[dev]"; \
|
|
fi; \
|
|
if [ -f "scripts/patch_grpc_stubs.py" ]; then \
|
|
"$$PYTHON_BIN" scripts/patch_grpc_stubs.py; \
|
|
fi
|
|
|
|
## Ensure Node/TypeScript tooling is installed
|
|
ensure-ts: ensure-hygiene
|
|
@command -v npm >/dev/null 2>&1 || { echo "npm not found. Install Node.js first."; exit 1; }
|
|
@if [ ! -d client/node_modules ]; then \
|
|
echo "Installing client dependencies..."; \
|
|
cd client && npm install; \
|
|
fi
|
|
|
|
## Ensure Rust tooling is installed
|
|
ensure-rs: ensure-hygiene
|
|
@command -v cargo >/dev/null 2>&1 || { echo "cargo not found. Install Rust toolchain first."; exit 1; }
|
|
@if command -v rustup >/dev/null 2>&1; then \
|
|
rustup component add rustfmt clippy; \
|
|
fi
|
|
|
|
## Ensure hygiene output directory exists
|
|
ensure-hygiene:
|
|
@mkdir -p $(HYGIENE_DIR_ABS)
|
|
|
|
#-------------------------------------------------------------------------------
|
|
# Combined Quality Checks
|
|
#-------------------------------------------------------------------------------
|
|
|
|
## Run all quality checks (TypeScript, Rust, Python)
|
|
quality: quality-ts quality-rs quality-py
|
|
@echo ""
|
|
@echo "✓ All quality checks passed"
|
|
|
|
## Run all tests (TypeScript, Rust, Python)
|
|
test: test-ts test-rs test-py
|
|
@echo ""
|
|
@echo "✓ All tests passed"
|
|
|
|
#-------------------------------------------------------------------------------
|
|
# TypeScript Quality Checks
|
|
#-------------------------------------------------------------------------------
|
|
|
|
## Run all TypeScript quality checks (Lint + Type Check + Quality Tests)
|
|
quality-ts: ensure-ts type-check lint test-quality
|
|
@echo "✓ TypeScript quality checks passed"
|
|
|
|
## Run TypeScript tests
|
|
test-ts: ensure-ts
|
|
@echo "=== TypeScript Tests ==="
|
|
cd client && npm run test
|
|
|
|
## Run TypeScript type checking
|
|
type-check: ensure-ts
|
|
@echo "=== TypeScript Type Check ==="
|
|
cd client && npm run type-check
|
|
|
|
## Run Biome linter
|
|
lint: ensure-ts
|
|
@echo "=== Biome Lint ==="
|
|
cd client && HYGIENE_DIR=$(HYGIENE_DIR_ABS) npm run lint
|
|
|
|
## Run Biome check (lint + format)
|
|
check: ensure-ts
|
|
@echo "=== Biome Check ==="
|
|
cd client && HYGIENE_DIR=$(HYGIENE_DIR_ABS) npm run check
|
|
|
|
## Run code quality tests (Vitest)
|
|
test-quality: ensure-ts
|
|
@echo "=== TypeScript Quality Tests ==="
|
|
cd client && npm run test:quality
|
|
|
|
## Run Vitest with coverage
|
|
coverage-ts: ensure-ts
|
|
@echo "=== TypeScript Coverage (Vitest) ==="
|
|
cd client && npm run test -- --coverage
|
|
|
|
## Run all coverage checks
|
|
coverage: coverage-ts
|
|
@echo "✓ Coverage checks passed"
|
|
|
|
#-------------------------------------------------------------------------------
|
|
# Rust Quality Checks
|
|
#-------------------------------------------------------------------------------
|
|
|
|
## Run all Rust quality checks
|
|
quality-rs: ensure-rs clippy lint-rs
|
|
@echo "✓ Rust quality checks passed"
|
|
|
|
## Run Rust tests (uses nextest if available for speed)
|
|
test-rs: ensure-rs
|
|
@echo "=== Rust Tests ==="
|
|
@cd client/src-tauri && \
|
|
if cargo nextest --version >/dev/null 2>&1; then \
|
|
echo "Using cargo-nextest for faster execution..."; \
|
|
cargo nextest run; \
|
|
else \
|
|
echo "cargo-nextest not found, falling back to cargo test (parallel threads)..."; \
|
|
cargo test; \
|
|
fi
|
|
|
|
## Run Clippy linter
|
|
clippy: ensure-rs
|
|
@echo "=== Clippy ==="
|
|
cd client/src-tauri && cargo clippy --message-format=json -- -D warnings > $(HYGIENE_DIR_ABS)/clippy.json 2>&1
|
|
|
|
## Run Rust code quality script
|
|
lint-rs: ensure-rs
|
|
@echo "=== Rust Code Quality ==="
|
|
./client/src-tauri/scripts/code_quality.sh --output $(HYGIENE_DIR_ABS)/rust_code_quality.txt
|
|
|
|
## Format Rust code
|
|
fmt-rs: ensure-rs
|
|
@echo "=== Rustfmt ==="
|
|
cd client/src-tauri && cargo fmt
|
|
|
|
## Check Rust formatting
|
|
fmt-check-rs: ensure-rs
|
|
@echo "=== Rustfmt Check ==="
|
|
cd client/src-tauri && cargo fmt --check
|
|
|
|
#-------------------------------------------------------------------------------
|
|
# Python Quality Checks
|
|
#-------------------------------------------------------------------------------
|
|
|
|
## Run all Python quality checks
|
|
quality-py: ensure-py lint-py type-check-py test-quality-py
|
|
@echo "✓ Python quality checks passed"
|
|
|
|
## Run Python tests
|
|
test-py: ensure-py
|
|
@echo "=== Python Tests ==="
|
|
@$(ACTIVATE_VENV); \
|
|
pytest -n auto
|
|
|
|
## Run Basedpyright lint on Python code
|
|
lint-py: ensure-py
|
|
@echo "=== Basedpyright (Python Lint) ==="
|
|
@$(ACTIVATE_VENV); \
|
|
if [ -n "$(PY_TARGETS)" ]; then basedpyright --outputjson $(PY_TARGETS) > $(HYGIENE_DIR_ABS)/basedpyright.lint.json 2>&1; else basedpyright --outputjson > $(HYGIENE_DIR_ABS)/basedpyright.lint.json 2>&1; fi
|
|
|
|
## Run Python type checking (basedpyright)
|
|
type-check-py: ensure-py
|
|
@echo "=== Basedpyright ==="
|
|
@$(ACTIVATE_VENV); \
|
|
if [ -n "$(PY_TARGETS)" ]; then basedpyright $(PY_TARGETS); else basedpyright; fi
|
|
|
|
## Run Python test quality checks
|
|
test-quality-py: ensure-py
|
|
@echo "=== Python Test Quality ==="
|
|
@$(ACTIVATE_VENV); \
|
|
pytest tests/quality/ -n auto -q
|
|
|
|
#-------------------------------------------------------------------------------
|
|
# Formatting
|
|
#-------------------------------------------------------------------------------
|
|
|
|
## Format all code (TypeScript + Rust)
|
|
fmt: ensure-ts fmt-rs
|
|
@echo "=== Biome Format ==="
|
|
cd client && npm run format
|
|
|
|
## Check all formatting
|
|
fmt-check: ensure-ts fmt-check-rs
|
|
@echo "=== Biome Format Check ==="
|
|
cd client && npm run format:check
|
|
|
|
#-------------------------------------------------------------------------------
|
|
# Fix Commands
|
|
#-------------------------------------------------------------------------------
|
|
|
|
## Auto-fix Biome lint issues
|
|
lint-fix: ensure-ts
|
|
cd client && HYGIENE_DIR=$(HYGIENE_DIR_ABS) npm run lint:fix
|
|
|
|
## Auto-fix all Biome issues (lint + format)
|
|
check-fix: ensure-ts
|
|
cd client && HYGIENE_DIR=$(HYGIENE_DIR_ABS) npm run check:fix
|
|
|
|
## Auto-fix Ruff issues
|
|
lint-fix-py: ensure-py
|
|
@$(ACTIVATE_VENV); \
|
|
if [ -n "$(PY_TARGETS)" ]; then ruff check --fix --output-format json --output-file $(HYGIENE_DIR_ABS)/ruff.fix.json $(PY_TARGETS); else ruff check --fix --output-format json --output-file $(HYGIENE_DIR_ABS)/ruff.fix.json .; fi
|
|
@$(ACTIVATE_VENV); \
|
|
if [ -n "$(PY_TARGETS)" ]; then sourcery review --config .sourcery.yaml --csv --fix $(PY_TARGETS) > $(HYGIENE_DIR_ABS)/sourcery.fix.csv; else sourcery review --config .sourcery.yaml --csv --fix src/ > $(HYGIENE_DIR_ABS)/sourcery.fix.csv && sourcery review --config .sourcery.yaml --csv --fix client/ > $(HYGIENE_DIR_ABS)/sourcery.fix.client.csv; fi
|
|
|
|
#-------------------------------------------------------------------------------
|
|
# E2E Tests
|
|
#-------------------------------------------------------------------------------
|
|
|
|
## Build the Tauri app for native E2E (enables VITE_E2E_MODE)
|
|
e2e-native-build: ensure-ts
|
|
@echo "=== Tauri Build (E2E Mode) ==="
|
|
cd client && VITE_E2E_MODE=1 npm run tauri:build
|
|
|
|
## Run native Tauri E2E tests (requires built app + backend)
|
|
e2e-native: ensure-ts
|
|
@echo "=== Native Tauri E2E Tests ==="
|
|
cd client && npm run test:native
|
|
|
|
## Run Playwright e2e tests (requires frontend running on :5173)
|
|
e2e: ensure-ts
|
|
@echo "=== Playwright E2E Tests ==="
|
|
cd client && NOTEFLOW_E2E=1 NOTEFLOW_E2E_NO_SERVER=1 NOTEFLOW_E2E_BASE_URL=http://localhost:5173 npx playwright test
|
|
|
|
## Run Playwright e2e tests with UI
|
|
e2e-ui: ensure-ts
|
|
@echo "=== Playwright E2E Tests (UI Mode) ==="
|
|
cd client && NOTEFLOW_E2E=1 NOTEFLOW_E2E_NO_SERVER=1 NOTEFLOW_E2E_BASE_URL=http://localhost:5173 npx playwright test --ui
|
|
|
|
## Run Rust gRPC integration tests (tests real backend wiring)
|
|
e2e-grpc: ensure-rs
|
|
@echo "=== Rust gRPC Integration Tests ==="
|
|
@echo "Requires: gRPC server running on :50051"
|
|
cd client/src-tauri && NOTEFLOW_INTEGRATION=1 cargo test --test grpc_integration -- --ignored --nocapture
|
|
|
|
#-------------------------------------------------------------------------------
|
|
# Git Hooks
|
|
#-------------------------------------------------------------------------------
|
|
|
|
## Install git hooks (pre-commit)
|
|
install-hooks:
|
|
@echo "=== Installing Git Hooks ==="
|
|
@chmod +x scripts/hooks/pre-commit
|
|
@ln -sf ../../scripts/hooks/pre-commit .git/hooks/pre-commit
|
|
@echo "✓ Pre-commit hook installed"
|
|
|
|
## Uninstall git hooks
|
|
uninstall-hooks:
|
|
@echo "=== Uninstalling Git Hooks ==="
|
|
@rm -f .git/hooks/pre-commit
|
|
@echo "✓ Pre-commit hook removed"
|
|
|
|
#-------------------------------------------------------------------------------
|
|
# Help
|
|
#-------------------------------------------------------------------------------
|
|
|
|
## Show this help
|
|
help:
|
|
@echo "NoteFlow Makefile"
|
|
@echo ""
|
|
@echo "Usage: make [target]"
|
|
@echo ""
|
|
@echo "Main targets:"
|
|
@echo " quality Run all quality checks (lint, type-check)"
|
|
@echo " test Run all tests"
|
|
@echo " quality-ts Run TypeScript checks only"
|
|
@echo " quality-rs Run Rust checks only"
|
|
@echo " quality-py Run Python checks only"
|
|
@echo ""
|
|
@echo "Tests:"
|
|
@echo " test-ts Run TypeScript tests"
|
|
@echo " test-rs Run Rust tests"
|
|
@echo " test-py Run Python tests"
|
|
@echo ""
|
|
@echo "TypeScript:"
|
|
@echo " type-check Run tsc --noEmit"
|
|
@echo " lint Run Biome linter"
|
|
@echo " lint-fix Auto-fix Biome lint issues"
|
|
@echo " check Run Biome check (lint + format)"
|
|
@echo " check-fix Auto-fix all Biome issues"
|
|
@echo " test-quality Run Vitest quality tests"
|
|
@echo " coverage Run coverage checks"
|
|
@echo " coverage-ts Run Vitest test coverage"
|
|
@echo ""
|
|
@echo "Rust:"
|
|
@echo " clippy Run Clippy linter"
|
|
@echo " lint-rs Run code quality script"
|
|
@echo " fmt-rs Format with rustfmt"
|
|
@echo " fmt-check-rs Check rustfmt formatting"
|
|
@echo ""
|
|
@echo "Python:"
|
|
@echo " lint-py Run Basedpyright lint (use PY_TARGETS=...)"
|
|
@echo " lint-fix-py Auto-fix Ruff issues + Sourcery review (use PY_TARGETS=...)"
|
|
@echo ""
|
|
@echo "E2E:"
|
|
@echo " e2e-native-build Build Tauri app for native E2E (VITE_E2E_MODE=1)"
|
|
@echo " e2e-native Run native Tauri E2E tests"
|
|
@echo " type-check-py Run basedpyright (use PY_TARGETS=...)"
|
|
@echo " test-quality-py Run pytest quality suite"
|
|
@echo ""
|
|
@echo "Formatting:"
|
|
@echo " fmt Format all code (Biome + rustfmt)"
|
|
@echo " fmt-check Check all formatting"
|
|
@echo ""
|
|
@echo "E2E Tests:"
|
|
@echo " e2e Run Playwright e2e tests (requires frontend on :5173)"
|
|
@echo " e2e-ui Run Playwright e2e tests with UI mode"
|
|
@echo " e2e-grpc Run Rust gRPC integration tests (real backend wiring)"
|
|
@echo ""
|
|
@echo "Git Hooks:"
|
|
@echo " install-hooks Install pre-commit hook"
|
|
@echo " uninstall-hooks Remove pre-commit hook"
|
|
@echo ""
|
|
@echo "Dependencies:"
|
|
@echo " ensure-py Ensure Python tooling is installed"
|
|
@echo " ensure-ts Ensure client dependencies are installed"
|
|
@echo " ensure-rs Ensure Rust tooling is installed"
|