|
| 1 | +.PHONY: help |
| 2 | +help: |
| 3 | + @grep '^# help\:' $(firstword $(MAKEFILE_LIST)) | sed 's/^# help\: //' |
| 4 | + |
| 5 | +PACKAGE_NAME := cpex-secrets-detection |
| 6 | +WHEEL_PREFIX := cpex_secrets_detection |
| 7 | +CARGO := cargo |
| 8 | +STUB_FILES := cpex_secrets_detection/__init__.pyi cpex_secrets_detection/secrets_detection_rust/__init__.pyi |
| 9 | +WHEEL_DIR := ../../../../target/wheels |
| 10 | + |
| 11 | +GREEN := \033[0;32m |
| 12 | +YELLOW := \033[0;33m |
| 13 | +NC := \033[0m |
| 14 | + |
| 15 | +# help: fmt - Format Rust code with rustfmt |
| 16 | +# help: fmt-check - Check Rust code formatting (CI) |
| 17 | +# help: clippy - Run clippy lints |
| 18 | +.PHONY: fmt fmt-check clippy |
| 19 | + |
| 20 | +fmt: |
| 21 | + $(CARGO) fmt |
| 22 | + |
| 23 | +fmt-check: |
| 24 | + $(CARGO) fmt -- --check |
| 25 | + |
| 26 | +clippy: |
| 27 | + $(CARGO) clippy -- -D warnings |
| 28 | + |
| 29 | +# help: sync - Install plugin development dependencies |
| 30 | +# help: test - Run Rust unit tests |
| 31 | +# help: test-verbose - Run Rust tests with verbose output |
| 32 | +# help: test-python - Run Python plugin tests |
| 33 | +# help: test-all - Run both Rust and Python tests |
| 34 | +.PHONY: sync test test-verbose test-python test-all verify-stubs |
| 35 | + |
| 36 | +sync: |
| 37 | + uv sync --dev |
| 38 | + |
| 39 | +test: |
| 40 | + @echo "$(GREEN)Running secrets_detection Rust tests...$(NC)" |
| 41 | + $(CARGO) test |
| 42 | + |
| 43 | +test-verbose: |
| 44 | + @echo "$(GREEN)Running secrets_detection Rust tests (verbose)...$(NC)" |
| 45 | + $(CARGO) test -- --nocapture |
| 46 | + |
| 47 | +test-python: |
| 48 | + @echo "$(GREEN)Running Python tests...$(NC)" |
| 49 | + uv run pytest tests/ -v |
| 50 | + |
| 51 | +test-all: test test-python |
| 52 | + |
| 53 | +verify-stubs: stub-gen |
| 54 | + @git diff --exit-code -- $(STUB_FILES) |
| 55 | + |
| 56 | +# help: stub-gen - Generate Python type stubs (.pyi files) |
| 57 | +# help: build - Build release wheel (no install) |
| 58 | +# help: install - Build and install editable extension into project venv |
| 59 | +# help: install-wheel - Install the previously built wheel into project venv |
| 60 | +.PHONY: stub-gen build install install-wheel uninstall |
| 61 | + |
| 62 | +stub-gen: |
| 63 | + @echo "$(GREEN)Generating Python type stubs...$(NC)" |
| 64 | + $(CARGO) run --bin stub_gen |
| 65 | + @echo "$(GREEN)Stubs generated$(NC)" |
| 66 | + |
| 67 | +build: stub-gen |
| 68 | + @echo "$(GREEN)Building $(PACKAGE_NAME)...$(NC)" |
| 69 | + uv run maturin build --release |
| 70 | + @echo "$(GREEN)Build complete$(NC)" |
| 71 | + |
| 72 | +install: stub-gen |
| 73 | + @echo "$(GREEN)Installing $(PACKAGE_NAME)...$(NC)" |
| 74 | + uv run maturin develop --release |
| 75 | + @echo "$(GREEN)Installation complete$(NC)" |
| 76 | + |
| 77 | +install-wheel: build |
| 78 | + @echo "$(GREEN)Installing built wheel for $(PACKAGE_NAME)...$(NC)" |
| 79 | + python3 ../../../../tools/install_built_wheel.py --wheel-dir "$(WHEEL_DIR)" --wheel-prefix "$(WHEEL_PREFIX)" --package-name "$(PACKAGE_NAME)" --venv-dir .venv |
| 80 | + @echo "$(GREEN)Wheel installation complete$(NC)" |
| 81 | + |
| 82 | +uninstall: |
| 83 | + @echo "$(YELLOW)Uninstalling $(PACKAGE_NAME)...$(NC)" |
| 84 | + @uv pip uninstall -y $(PACKAGE_NAME) 2>/dev/null || true |
| 85 | + |
| 86 | +# help: bench - Run Criterion benchmarks |
| 87 | +# help: bench-no-run - Compile Criterion benchmarks without running them |
| 88 | +.PHONY: bench bench-no-run |
| 89 | + |
| 90 | +bench: |
| 91 | + @echo "$(GREEN)Running benchmarks...$(NC)" |
| 92 | + $(CARGO) bench |
| 93 | + |
| 94 | +bench-no-run: |
| 95 | + @echo "$(GREEN)Compiling benchmarks without running them...$(NC)" |
| 96 | + $(CARGO) bench --no-run |
| 97 | + |
| 98 | +.PHONY: clean clean-all |
| 99 | + |
| 100 | +clean: |
| 101 | + $(CARGO) clean |
| 102 | + rm -rf target/ coverage/ |
| 103 | + find . -name "*.whl" -delete |
| 104 | + |
| 105 | +clean-all: clean |
| 106 | + |
| 107 | +# help: verify - Verify plugin installation |
| 108 | +# help: check-all - Run fmt-check + clippy + Rust tests |
| 109 | +# help: ci - Run the full CI-equivalent plugin verification flow |
| 110 | +.PHONY: verify check-all ci pre-commit |
| 111 | + |
| 112 | +verify: |
| 113 | + @uv run python -c "from cpex_secrets_detection import secrets_detection_rust; print('secrets_detection_rust available')" || echo "secrets_detection_rust not installed — run: make install" |
| 114 | + |
| 115 | +check-all: fmt-check clippy test |
| 116 | + @echo "$(GREEN)All checks passed$(NC)" |
| 117 | + |
| 118 | +ci: check-all verify-stubs build bench-no-run install-wheel test-python |
| 119 | + @echo "$(GREEN)CI verification passed$(NC)" |
| 120 | + |
| 121 | +pre-commit: check-all |
| 122 | + |
| 123 | +.DEFAULT_GOAL := help |
0 commit comments