- Introduced a new script `patch_grpc_stubs.py` to modify gRPC stub files, ensuring compatibility with strict type checks enforced by Basedpyright. - Updated the Makefile to execute the patch script after installing Python tooling. - Removed outdated gRPC type definitions from the project, resulting in zero errors in the Basedpyright linting results. All quality checks pass.
257 lines
9.4 KiB
Makefile
257 lines
9.4 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 \
|
|
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 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; \
|
|
"$$PYTHON_BIN" scripts/patch_grpc_stubs.py
|
|
|
|
## 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"
|
|
|
|
#-------------------------------------------------------------------------------
|
|
# TypeScript Quality Checks
|
|
#-------------------------------------------------------------------------------
|
|
|
|
## Run all TypeScript quality checks
|
|
quality-ts: ensure-ts type-check lint test-quality
|
|
@echo "✓ TypeScript quality checks passed"
|
|
|
|
## 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
|
|
|
|
#-------------------------------------------------------------------------------
|
|
# Rust Quality Checks
|
|
#-------------------------------------------------------------------------------
|
|
|
|
## Run all Rust quality checks
|
|
quality-rs: ensure-rs clippy lint-rs
|
|
@echo "✓ Rust quality checks passed"
|
|
|
|
## 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 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/ -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
|
|
#-------------------------------------------------------------------------------
|
|
|
|
## 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
|
|
|
|
#-------------------------------------------------------------------------------
|
|
# Help
|
|
#-------------------------------------------------------------------------------
|
|
|
|
## Show this help
|
|
help:
|
|
@echo "NoteFlow Makefile"
|
|
@echo ""
|
|
@echo "Usage: make [target]"
|
|
@echo ""
|
|
@echo "Main targets:"
|
|
@echo " quality Run all quality checks (default)"
|
|
@echo " quality-ts Run TypeScript checks only"
|
|
@echo " quality-rs Run Rust checks only"
|
|
@echo " quality-py Run Python checks only"
|
|
@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 ""
|
|
@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 " 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 "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"
|