-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMakefile
More file actions
150 lines (121 loc) · 5.9 KB
/
Copy pathMakefile
File metadata and controls
150 lines (121 loc) · 5.9 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
.PHONY: help build test test-unit test-integration test-coverage test-race clean fmt vet lint vuln install pre-commit release-snapshot docs starters
# Variables
BINARY_NAME=nic
CMD_DIR=./cmd/nic
PKG_DIRS=$(shell go list ./... | grep -v /vendor/)
GO_FILES=$(shell find . -type f -name '*.go' -not -path "./vendor/*")
# Build information
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
CLI_PKG=github.com/nebari-dev/nebari-infrastructure-core/internal/cli
LDFLAGS=-ldflags "-s -w -X $(CLI_PKG).version=$(VERSION) -X $(CLI_PKG).commit=$(COMMIT) -X $(CLI_PKG).date=$(DATE)"
help: ## Display this help message
@echo "Nebari Infrastructure Core - Makefile commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
build: ## Build the binary
@echo "Building $(BINARY_NAME)..."
CGO_ENABLED=0 go build -trimpath $(LDFLAGS) -o $(BINARY_NAME) $(CMD_DIR)
@echo "Built $(BINARY_NAME) successfully"
docs: ## Generate CLI and configuration reference documentation
@mkdir -p docs/reference/cli docs/configuration
@rm -f docs/reference/cli/*.md docs/configuration/*.md
go run ./cmd/docgen
starters: ## Generate the Nebi starter workspaces into dist/starters
@echo "Generating starters..."
go run ./cmd/starters -out dist/starters
build-all: ## Build binaries for all platforms
@echo "Building for all platforms..."
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath $(LDFLAGS) -o $(BINARY_NAME)-linux-amd64 $(CMD_DIR)
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath $(LDFLAGS) -o $(BINARY_NAME)-linux-arm64 $(CMD_DIR)
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -trimpath $(LDFLAGS) -o $(BINARY_NAME)-darwin-amd64 $(CMD_DIR)
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -trimpath $(LDFLAGS) -o $(BINARY_NAME)-darwin-arm64 $(CMD_DIR)
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -trimpath $(LDFLAGS) -o $(BINARY_NAME)-windows-amd64.exe $(CMD_DIR)
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -trimpath $(LDFLAGS) -o $(BINARY_NAME)-windows-arm64.exe $(CMD_DIR)
@echo "Built all platform binaries successfully"
install: ## Install the binary to $GOPATH/bin
@echo "Installing $(BINARY_NAME)..."
CGO_ENABLED=0 go install -trimpath $(LDFLAGS) $(CMD_DIR)
@echo "Installed $(BINARY_NAME) to $(shell go env GOPATH)/bin/$(BINARY_NAME)"
clean: ## Remove build artifacts
@echo "Cleaning..."
rm -f $(BINARY_NAME)
rm -f $(BINARY_NAME)-*
rm -f coverage.out
rm -f *.test
@echo "Cleaned successfully"
fmt: ## Format Go code
@echo "Running go fmt..."
gofmt -s -w $(GO_FILES)
@echo "Formatted successfully"
vet: ## Run go vet
@echo "Running go vet..."
go vet $(PKG_DIRS)
@echo "Vet passed successfully"
lint: ## Run golangci-lint
@echo "Running golangci-lint..."
@which golangci-lint > /dev/null || (echo "Error: golangci-lint is not installed. See https://golangci-lint.run/welcome/install/" && exit 1)
golangci-lint run
@echo "Lint passed successfully"
vuln: ## Run govulncheck security gate (fails on reachable, fixable vulnerabilities)
@echo "Running govulncheck gate..."
@./scripts/govulncheck-gate.sh
test: test-unit ## Run unit tests (default)
test-unit: ## Run unit tests only
@echo "Running unit tests..."
go test -v -short $(PKG_DIRS)
@echo "Unit tests passed successfully"
test-integration: ## Run integration tests (uses testcontainers, requires Docker)
@echo "Running integration tests with testcontainers..."
@which docker > /dev/null || (echo "Error: Docker is not installed or not running" && exit 1)
go test -v -tags=integration ./pkg/providers/cluster/aws -timeout 30m
@echo "Integration tests passed successfully"
test-all: ## Run all tests (unit + integration)
@echo "Running all tests..."
$(MAKE) test-unit
$(MAKE) test-integration
@echo "All tests passed successfully"
test-journeys: ## Run user journey tests against the cluster in $KUBECONFIG
@echo "Running user journey tests..."
@which pixi > /dev/null || (echo "Error: pixi is not installed (https://pixi.sh)" && exit 1)
cd tests/user_journeys && pixi run test
@echo "User journey tests passed successfully"
test-journeys-lib: ## Run tests of the journey library itself (no cluster needed)
cd tests/user_journeys && pixi run test-lib
LOCAL_CONFIG?=./examples/local-config.yaml
REGEN_APPS?=
test-coverage: ## Run unit tests with coverage
@echo "Running unit tests with coverage..."
go test -v -short -coverprofile=coverage.out -covermode=atomic $(PKG_DIRS)
go tool cover -func=coverage.out
@echo "Coverage report generated: coverage.out"
test-race: ## Run unit tests with race detection
@echo "Running unit tests with race detection..."
go test -v -short -race $(PKG_DIRS)
@echo "Race tests passed successfully"
check: fmt vet lint test ## Run all checks (fmt, vet, lint, test)
@echo "All checks passed successfully"
pre-commit: ## Install pre-commit hooks
@echo "Installing pre-commit hooks..."
@which pre-commit > /dev/null || (echo "Error: pre-commit is not installed. Install with: pip install pre-commit" && exit 1)
pre-commit install
@echo "Pre-commit hooks installed successfully"
pre-commit-run: ## Run pre-commit hooks on all files
@echo "Running pre-commit hooks..."
pre-commit run --all-files
release-snapshot: ## Create a snapshot release (local testing)
@echo "Creating snapshot release..."
@which goreleaser > /dev/null || (echo "Error: goreleaser is not installed. See https://goreleaser.com/install/" && exit 1)
goreleaser release --snapshot --clean
@echo "Snapshot release created successfully"
deps: ## Download Go dependencies
@echo "Downloading dependencies..."
go mod download
go mod verify
@echo "Dependencies downloaded successfully"
deps-update: ## Update Go dependencies
@echo "Updating dependencies..."
go get -u ./...
go mod tidy
@echo "Dependencies updated successfully"
.DEFAULT_GOAL := help