-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
131 lines (100 loc) · 4.62 KB
/
Copy pathMakefile
File metadata and controls
131 lines (100 loc) · 4.62 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
.PHONY: help db-up db-down db-clean db-logs build run test fmt lint check install-hooks helm-lint helm-validate helm-check pre-pr
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-20s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
# =============================================================================
# Database Management
# =============================================================================
db-up: ## Start local SurrealDB container
@echo "Starting SurrealDB..."
docker-compose up -d surrealdb;
echo "SurrealDB starting (application will retry connection automatically)...";
db-down: ## Stop local SurrealDB container, remove data volume (clears all data)
@echo "Stopping SurrealDB..."
docker-compose down -v;
db-logs: ## Show SurrealDB logs
docker-compose logs -f surrealdb; \
# =============================================================================
# Development
# =============================================================================
build: ## Build the project
cargo +nightly build
run: ## Run the service locally (requires .env file)
cargo +nightly run
test: ## Run unit tests only (fast)
TEST_MODE=true cargo +nightly test --lib
TEST ?= '*'
test-integration: db-up ## Run integration tests only (requires SurrealDB, optionally set TEST=<name>)
@echo "Running integration tests: $(TEST)"
@TEST_MODE=true cargo test --test $(TEST) -- --ignored --test-threads=1
test-all: test test-integration ## Run all tests (unit + integration if docker available)
test-verbose: ## Run tests with output
TEST_MODE=true cargo +nightly test -- --nocapture
fmt: ## Format code and auto-fix clippy issues
cargo +nightly fmt
cargo +nightly clippy --fix --allow-dirty --allow-staged
lint: ## Run clippy lints
cargo +nightly clippy -- -D warnings
check: fmt lint test-all ## Run all checks (format, lint, unit tests)
# =============================================================================
# Docker
# =============================================================================
docker-build: ## Build Docker image
docker build -t arda-collateral-intel:latest .
docker-run: ## Run Docker container locally
docker run -p 3010:3010 --env-file .env arda-collateral-intel:latest
# =============================================================================
# Development Workflow
# =============================================================================
dev-setup: db-up ## Setup local development environment
@echo "Creating .env file from .env.example..."
@if [ ! -f .env ]; then \
cp .env.example .env; \
echo "Created .env file. Please update SURREALDB_PASSWORD and other settings."; \
else \
echo ".env file already exists"; \
fi
@echo ""
@echo "Installing git hooks..."
@$(MAKE) install-hooks
@echo ""
@echo "Development environment setup complete!"
@echo "Next steps:"
@echo " 1. Update .env with your configuration"
@echo " 2. Run 'make run' to start the service"
dev-start: db-up run ## Start database and run service
dev-stop: db-down ## Stop all services
install-hooks: ## Install git hooks (pre-commit, pre-push)
@echo "Installing git hooks..."
@mkdir -p .git/hooks
@cp hooks/pre-commit .git/hooks/pre-commit
@cp hooks/pre-push .git/hooks/pre-push
@chmod +x .git/hooks/pre-commit
@chmod +x .git/hooks/pre-push
@echo "✅ Git hooks installed successfully!"
@echo " - pre-commit: runs 'make check'"
@echo " - pre-push: runs 'make build' and 'make docker-build'"
# =============================================================================
# Helm Validation
# =============================================================================
helm-lint: ## Run Helm lint in strict mode
@echo "Running Helm lint..."
helm lint helm/arda-collateral-intel/ --strict
helm-validate: ## Validate Helm templates render correctly
@echo "Validating Helm templates with default values..."
@helm template test-release helm/arda-collateral-intel/ --dry-run > /dev/null
@echo "✅ Default values validation successful"
@echo ""
@echo "Validating Helm templates with Cloudflare Gateway secrets..."
@helm template test-release helm/arda-collateral-intel/ \
--set 'secrets.cloudflareGatewayToken=test-token' \
--show-only templates/secret.yaml > /dev/null
@echo "✅ Secrets validation successful"
helm-check: helm-lint helm-validate ## Run all Helm validation checks
# =============================================================================
# Pre-PR Validation
# =============================================================================
pre-pr: ## Run all pre-PR validation checks
@./pre-pr-check.sh