-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
95 lines (78 loc) · 3.03 KB
/
Makefile
File metadata and controls
95 lines (78 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# k8sql Makefile
# Convenience targets for building, testing, and development
.PHONY: all build build-release test test-unit test-integration lint fmt clean help
# Default target
all: build test-unit
# Build debug binary
build:
cargo build
# Build release binary and copy to bin/
build-release:
cargo build --release
mkdir -p bin
cp target/release/k8sql bin/
# Run all tests (unit + integration)
test: test-unit test-integration
# Run unit tests only
test-unit:
cargo test --verbose
# Run integration tests (requires Docker and k3d)
# This will create k3d clusters, run tests, and clean up
# Uses separate KUBECONFIG to avoid touching ~/.kube/config
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
# Run integration tests without setup/cleanup (for debugging)
test-integration-run:
KUBECONFIG=/tmp/k8sql-test-kubeconfig K8SQL=./bin/k8sql ./tests/integration/run-tests.sh
# Setup integration test clusters only
test-integration-setup:
KUBECONFIG=/tmp/k8sql-test-kubeconfig ./tests/integration/setup-clusters.sh
# Cleanup integration test clusters
test-integration-cleanup:
./tests/integration/cleanup.sh
# Linting - check formatting and run clippy
lint:
cargo fmt --check
cargo clippy -- -D warnings
# Format code
fmt:
cargo fmt
# Run clippy with auto-fix
fix:
cargo clippy --fix --allow-dirty --allow-staged
# Clean build artifacts
clean:
cargo clean
rm -rf bin/
# Full clean including test clusters
clean-all: clean test-integration-cleanup
# Install the binary to ~/.cargo/bin
install: build-release
cp target/release/k8sql ~/.cargo/bin/
# Show help
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"