This commit is contained in:
2026-01-02 04:22:40 +00:00
parent f533d5aec2
commit e4b2c733d5
233 changed files with 18169 additions and 4871 deletions

136
Makefile
View File

@@ -2,11 +2,64 @@
# Runs TypeScript, Rust, and Python quality checks
.PHONY: all quality quality-ts quality-rs quality-py lint type-check test-quality \
lint-rs clippy fmt fmt-rs fmt-check check help e2e e2e-ui e2e-grpc
lint-rs clippy fmt fmt-rs fmt-check check help e2e e2e-ui e2e-grpc \
ensure-py ensure-ts ensure-rs ensure-hygiene
# 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 pyrefly 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
## 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
#-------------------------------------------------------------------------------
@@ -21,26 +74,26 @@ quality: quality-ts quality-rs quality-py
#-------------------------------------------------------------------------------
## Run all TypeScript quality checks
quality-ts: type-check lint test-quality
quality-ts: ensure-ts type-check lint test-quality
@echo "✓ TypeScript quality checks passed"
## Run TypeScript type checking
type-check:
type-check: ensure-ts
@echo "=== TypeScript Type Check ==="
cd client && npm run type-check
## Run Biome linter
lint:
lint: ensure-ts
@echo "=== Biome Lint ==="
cd client && npm run lint
cd client && HYGIENE_DIR=$(HYGIENE_DIR_ABS) npm run lint
## Run Biome check (lint + format)
check:
check: ensure-ts
@echo "=== Biome Check ==="
cd client && npm run check
cd client && HYGIENE_DIR=$(HYGIENE_DIR_ABS) npm run check
## Run code quality tests (Vitest)
test-quality:
test-quality: ensure-ts
@echo "=== TypeScript Quality Tests ==="
cd client && npm run test:quality
@@ -49,26 +102,26 @@ test-quality:
#-------------------------------------------------------------------------------
## Run all Rust quality checks
quality-rs: clippy lint-rs
quality-rs: ensure-rs clippy lint-rs
@echo "✓ Rust quality checks passed"
## Run Clippy linter
clippy:
clippy: ensure-rs
@echo "=== Clippy ==="
cd client/src-tauri && cargo clippy -- -D warnings
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:
lint-rs: ensure-rs
@echo "=== Rust Code Quality ==="
./client/src-tauri/scripts/code_quality.sh
./client/src-tauri/scripts/code_quality.sh --output $(HYGIENE_DIR_ABS)/rust_code_quality.txt
## Format Rust code
fmt-rs:
fmt-rs: ensure-rs
@echo "=== Rustfmt ==="
cd client/src-tauri && cargo fmt
## Check Rust formatting
fmt-check-rs:
fmt-check-rs: ensure-rs
@echo "=== Rustfmt Check ==="
cd client/src-tauri && cargo fmt --check
@@ -77,22 +130,25 @@ fmt-check-rs:
#-------------------------------------------------------------------------------
## Run all Python quality checks
quality-py: lint-py type-check-py test-quality-py
quality-py: ensure-py lint-py type-check-py test-quality-py
@echo "✓ Python quality checks passed"
## Run Ruff linter on Python code
lint-py:
@echo "=== Ruff (Python Lint) ==="
ruff check .
lint-py: ensure-py
@echo "=== Pyrefly (Python Lint) ==="
@$(ACTIVATE_VENV); \
if [ -n "$(PY_TARGETS)" ]; then pyrefly check --summarize-errors $(PY_TARGETS) > $(HYGIENE_DIR_ABS)/pyrefly.txt 2>&1; else pyrefly check --summarize-errors > $(HYGIENE_DIR_ABS)/pyrefly.txt 2>&1; fi
## Run Python type checking (basedpyright)
type-check-py:
type-check-py: ensure-py
@echo "=== Basedpyright ==="
basedpyright
@$(ACTIVATE_VENV); \
if [ -n "$(PY_TARGETS)" ]; then basedpyright $(PY_TARGETS); else basedpyright; fi
## Run Python test quality checks
test-quality-py:
test-quality-py: ensure-py
@echo "=== Python Test Quality ==="
@$(ACTIVATE_VENV); \
pytest tests/quality/ -q
#-------------------------------------------------------------------------------
@@ -100,12 +156,12 @@ test-quality-py:
#-------------------------------------------------------------------------------
## Format all code (TypeScript + Rust)
fmt: fmt-rs
fmt: ensure-ts fmt-rs
@echo "=== Biome Format ==="
cd client && npm run format
## Check all formatting
fmt-check: fmt-check-rs
fmt-check: ensure-ts fmt-check-rs
@echo "=== Biome Format Check ==="
cd client && npm run format:check
@@ -114,33 +170,36 @@ fmt-check: fmt-check-rs
#-------------------------------------------------------------------------------
## Auto-fix Biome lint issues
lint-fix:
cd client && npm run lint:fix
lint-fix: ensure-ts
cd client && HYGIENE_DIR=$(HYGIENE_DIR_ABS) npm run lint:fix
## Auto-fix all Biome issues (lint + format)
check-fix:
cd client && npm run check:fix
check-fix: ensure-ts
cd client && HYGIENE_DIR=$(HYGIENE_DIR_ABS) npm run check:fix
## Auto-fix Ruff issues
lint-fix-py:
ruff check --fix .
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
#-------------------------------------------------------------------------------
## Run Playwright e2e tests (requires frontend running on :5173)
e2e:
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:
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:
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
@@ -176,9 +235,9 @@ help:
@echo " fmt-check-rs Check rustfmt formatting"
@echo ""
@echo "Python:"
@echo " lint-py Run Ruff linter"
@echo " lint-fix-py Auto-fix Ruff issues"
@echo " type-check-py Run basedpyright"
@echo " lint-py Run Pyrefly lint (use PY_TARGETS=...)"
@echo " lint-fix-py Auto-fix Ruff issues + Sourcery review (use PY_TARGETS=...)"
@echo " type-check-py Run basedpyright (use PY_TARGETS=...)"
@echo " test-quality-py Run pytest quality suite"
@echo ""
@echo "Formatting:"
@@ -189,3 +248,8 @@ help:
@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 "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"