-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
76 lines (61 loc) · 3.47 KB
/
Makefile
File metadata and controls
76 lines (61 loc) · 3.47 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
.PHONY: help init lint test docs clean install-tools validate fmt
help: ## Show this help message
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
init: ## Initialize OpenTofu and install pre-commit hooks
@echo "Initializing OpenTofu..."
@tofu init
@echo "Installing pre-commit hooks..."
@pre-commit install || echo "pre-commit not installed. Run 'make install-tools' first."
install-tools: ## Install required development tools
@echo "Installing development tools..."
@which pre-commit > /dev/null || pip install pre-commit
@which terraform-docs > /dev/null || go install github.com/terraform-docs/terraform-docs@latest
@which tflint > /dev/null || (curl -L "https://github.com/terraform-linters/tflint/releases/download/v0.50.3/tflint_linux_amd64.zip" -o tflint.zip && unzip -o tflint.zip && sudo mv tflint /usr/local/bin/ && rm tflint.zip)
@echo "Installing Go dependencies for testing..."
@cd test && go mod download
fmt: ## Format OpenTofu/Terraform files
@echo "Formatting OpenTofu/Terraform files..."
@tofu fmt -recursive .
validate: ## Validate OpenTofu configuration
@echo "Validating OpenTofu configuration..."
@tofu init -backend=false
@tofu validate
@echo "Running tflint..."
@tflint --init || true
@tflint
lint: fmt validate ## Run all linting checks (fmt + validate)
@echo "Running pre-commit hooks..."
@pre-commit run --all-files || true
test: ## Run unit tests (no infrastructure)
@echo "Running unit tests..."
@cd test && go test -v -timeout 10m -run "TestTerraformValidation|TestExamplesValidation|TestHrafnarModuleFunctionality"
test-integration: ## Run integration tests (deploys real infrastructure)
@echo "Running integration tests..."
@echo "WARNING: This will deploy real GCP infrastructure and may incur costs!"
@cd test && go test -v -timeout 45m -run "Integration|TestMinimalDeployment"
test-dev: ## Run dev environment integration test
@echo "Running dev environment integration test..."
@echo "WARNING: This will deploy real GCP infrastructure!"
@cd test && go test -v -timeout 30m -run TestDevEnvironmentDeployment
test-prod: ## Run prod environment integration test
@echo "Running prod environment integration test..."
@echo "WARNING: This will deploy real GCP infrastructure!"
@cd test && go test -v -timeout 30m -run TestProdEnvironmentDeployment
test-minimal: ## Run minimal deployment integration test
@echo "Running minimal deployment integration test..."
@echo "WARNING: This will deploy real GCP infrastructure!"
@cd test && go test -v -timeout 30m -run TestMinimalDeployment
test-all: test test-integration ## Run all tests (unit + integration)
docs: ## Generate documentation with terraform-docs
@echo "Generating documentation..."
@docker run --rm --volume "$$(pwd):/terraform-docs" -u $$(id -u) quay.io/terraform-docs/terraform-docs:latest markdown /terraform-docs --output-file README.md
@terraform-docs markdown examples/dev > examples/dev/README.md || true
clean: ## Clean up temporary files and directories
@echo "Cleaning up..."
@find . -type d -name ".terraform" -exec rm -rf {} + 2>/dev/null || true
@find . -type f -name ".terraform.lock.hcl" -exec rm -f {} + 2>/dev/null || true
@find . -type f -name "*.tfplan" -exec rm -f {} + 2>/dev/null || true
@find . -type f -name "terraform.tfstate*" -exec rm -f {} + 2>/dev/null || true
ci: install-tools lint test ## Run CI pipeline locally
@echo "CI pipeline completed successfully!"