.PHONY: all build build-release test test-unit test-integration lint fmt clean help
all: build test-unit
build:
cargo build
build-release:
cargo build --release
mkdir -p bin
cp target/release/k8sql bin/
test: test-unit test-integration
test-unit:
cargo test --verbose
test-integration: build-release
@echo "=== Running integration tests ==="
@echo "Prerequisites: Docker and k3d must be installed"
@command -v docker >/dev/null 2>&1 || { echo "Error: docker is not installed"; exit 1; }
@command -v k3d >/dev/null 2>&1 || { echo "Error: k3d is not installed"; exit 1; }
KUBECONFIG=/tmp/k8sql-test-kubeconfig ./tests/integration/setup-clusters.sh
KUBECONFIG=/tmp/k8sql-test-kubeconfig K8SQL=./bin/k8sql ./tests/integration/run-tests.sh || (./tests/integration/cleanup.sh && exit 1)
./tests/integration/cleanup.sh
test-integration-run:
KUBECONFIG=/tmp/k8sql-test-kubeconfig K8SQL=./bin/k8sql ./tests/integration/run-tests.sh
test-integration-setup:
KUBECONFIG=/tmp/k8sql-test-kubeconfig ./tests/integration/setup-clusters.sh
test-integration-cleanup:
./tests/integration/cleanup.sh
lint:
cargo fmt --check
cargo clippy -- -D warnings
fmt:
cargo fmt
fix:
cargo clippy --fix --allow-dirty --allow-staged
clean:
cargo clean
rm -rf bin/
clean-all: clean test-integration-cleanup
install: build-release
cp target/release/k8sql ~/.cargo/bin/
help:
@echo "k8sql Makefile targets:"
@echo ""
@echo " build - Build debug binary"
@echo " build-release - Build release binary to bin/"
@echo " test - Run all tests (unit + integration)"
@echo " test-unit - Run unit tests only"
@echo " test-integration - Run integration tests with k3d clusters"
@echo " lint - Check formatting and run clippy"
@echo " fmt - Format code with rustfmt"
@echo " fix - Run clippy with auto-fix"
@echo " clean - Remove build artifacts"
@echo " clean-all - Remove build artifacts and test clusters"
@echo " install - Install binary to ~/.cargo/bin"
@echo " help - Show this help"
@echo ""
@echo "Integration test helpers:"
@echo " test-integration-setup - Setup k3d clusters only"
@echo " test-integration-run - Run tests only (assumes clusters exist)"
@echo " test-integration-cleanup - Cleanup k3d clusters"