-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (66 loc) · 2.16 KB
/
Makefile
File metadata and controls
85 lines (66 loc) · 2.16 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
.PHONY: build build-relay build-all test test-coverage test-coverage-check clean run lint lint-fix docker setup-hooks check
# Build variables
VERSION?=0.1.0
LDFLAGS=-ldflags "-X main.version=$(VERSION)"
# Default target
all: lint test build-all
# Build the server binary
build:
go build $(LDFLAGS) -o bin/gatekeeperd ./cmd/gatekeeperd
# Build the relay client binary
build-relay:
go build $(LDFLAGS) -o bin/gatekeeper-relay ./cmd/gatekeeper-relay
# Build all binaries
build-all: build build-relay
# Run tests
test:
go test -v ./...
# Run tests with coverage (generates report)
test-coverage:
go test -v -coverprofile=coverage.out -tags=ci ./...
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
# Run tests and REQUIRE 100% coverage (use before releasing)
# Specific branches can be excluded with: // coverage:ignore - <reason>
test-coverage-check:
@./scripts/check-coverage.sh
# Run the server locally (for development)
run: build
./bin/gatekeeperd -config config/example.yaml -listen :8080
# Run the relay client locally (for development)
run-relay: build-relay
./bin/gatekeeper-relay -config config/relay-client-example.yaml
# Clean build artifacts
clean:
rm -rf bin/
rm -f coverage.out coverage.html
# Run linter
lint:
golangci-lint run ./...
# Run linter and fix issues automatically where possible
lint-fix:
golangci-lint run --fix ./...
# Build Docker images
docker:
docker build -t gatekeeper:$(VERSION) -f Dockerfile .
docker build -t gatekeeper-relay:$(VERSION) -f Dockerfile.relay .
# Format code
fmt:
go fmt ./...
goimports -w -local github.com/tight-line/gatekeeper .
# Tidy dependencies
tidy:
go mod tidy
# Install development tools
tools:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install golang.org/x/tools/cmd/goimports@latest
# Set up git hooks for development
setup-hooks:
@echo "Installing pre-commit hook..."
@cp scripts/pre-commit .git/hooks/pre-commit
@chmod +x .git/hooks/pre-commit
@echo "Pre-commit hook installed successfully."
# Verify everything (used by CI and before releasing)
check: lint test-coverage-check build-all
@echo "All checks passed. Ready for release."