-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (56 loc) · 1.6 KB
/
Makefile
File metadata and controls
73 lines (56 loc) · 1.6 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
.PHONY: build test test-e2e test-all lint clean install run dev
# Build variables
BINARY_NAME=cbox
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_TIME=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
LDFLAGS=-ldflags "-X github.com/bobbyrathore/cbox/internal/cli.Version=$(VERSION) -X github.com/bobbyrathore/cbox/internal/cli.Commit=$(COMMIT) -X github.com/bobbyrathore/cbox/internal/cli.BuildTime=$(BUILD_TIME)"
# Default target
all: build
# Build the binary
build:
go build $(LDFLAGS) -o bin/$(BINARY_NAME) ./cmd/cbox
# Build for release (smaller binary)
build-release:
CGO_ENABLED=0 go build $(LDFLAGS) -ldflags "-s -w" -o bin/$(BINARY_NAME) ./cmd/cbox
# Run tests
test:
go test -v ./...
# Run tests with coverage
test-coverage:
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
# Run e2e tests (requires Docker)
test-e2e: build
go test -v -timeout 10m ./tests/e2e/...
# Run all tests
test-all: test test-e2e
# Run linter
lint:
golangci-lint run ./...
# Format code
fmt:
go fmt ./...
gofmt -s -w .
# Clean build artifacts
clean:
rm -rf bin/
rm -f coverage.out coverage.html
# Install binary to GOPATH/bin
install: build
cp bin/$(BINARY_NAME) $(GOPATH)/bin/$(BINARY_NAME)
# Run the CLI (for development)
run: build
./bin/$(BINARY_NAME)
# Run in dev mode
dev:
go run ./cmd/cbox $(ARGS)
# Tidy dependencies
tidy:
go mod tidy
# Download dependencies
deps:
go mod download
# Check for vulnerabilities
vuln:
go run golang.org/x/vuln/cmd/govulncheck@latest ./...