forked from dorkitude/linctl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
130 lines (108 loc) · 3.67 KB
/
Makefile
File metadata and controls
130 lines (108 loc) · 3.67 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
# linctl Makefile
.PHONY: build clean test install lint fmt deps help
# Build variables
BINARY_NAME=linctl
GO_FILES=$(shell find . -type f -name '*.go' | grep -v vendor/)
VERSION?=$(shell git describe --tags --exact-match 2>/dev/null || git rev-parse --short HEAD)
LDFLAGS=-ldflags "-X github.com/nicholls-inc/linctl/cmd.version=$(VERSION)"
# Default target
all: build
# Build the binary
build:
@echo "🔨 Building $(BINARY_NAME)..."
go build $(LDFLAGS) -o $(BINARY_NAME) .
# Clean build artifacts
clean:
@echo "🧹 Cleaning build artifacts..."
rm -f $(BINARY_NAME)
go clean
# Run unit tests only
test-unit:
@echo "🧪 Running unit tests..."
@go test ./...
# Run unit tests with verbose output
test-unit-verbose:
@echo "🧪 Running unit tests (verbose)..."
@go test -v ./...
# Run OAuth integration tests
test-oauth:
@echo "🧪 Running OAuth integration tests..."
@./test_oauth_integration.sh
# Run smoke tests (requires authentication)
test-smoke:
@echo "🧪 Running smoke tests..."
@./smoke_test.sh
# Run smoke tests with verbose output
test-smoke-verbose:
@echo "🧪 Running smoke tests (verbose)..."
@bash -x ./smoke_test.sh
# Run all tests (unit + OAuth integration)
test:
@echo "🧪 Running all tests..."
@$(MAKE) test-unit
@$(MAKE) test-oauth
# Run all tests including smoke tests (requires authentication)
test-all:
@echo "🧪 Running all tests including smoke tests..."
@$(MAKE) test-unit
@$(MAKE) test-oauth
@$(MAKE) test-smoke
# Install dependencies
deps:
@echo "📦 Installing dependencies..."
go mod download
go mod tidy
# Format code
fmt:
@echo "🎨 Formatting code..."
go fmt ./...
# Lint code
lint:
@echo "🔍 Linting code..."
golangci-lint run
# Install binary to system
install: build
@echo "📦 Installing $(BINARY_NAME) to /usr/local/bin..."
sudo mv $(BINARY_NAME) /usr/local/bin/
# Development installation (symlink)
dev-install: build
@echo "🔗 Creating development symlink..."
sudo ln -sf $(PWD)/$(BINARY_NAME) /usr/local/bin/$(BINARY_NAME)
# Cross-compile for multiple platforms
build-all:
@echo "🌍 Building for multiple platforms..."
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-amd64 .
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-amd64 .
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-arm64 .
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-windows-amd64.exe .
# Create release directory
release: clean
@echo "🚀 Preparing release..."
mkdir -p dist
$(MAKE) build-all
# Run the binary
run: build
./$(BINARY_NAME)
# Run everything: build, format, lint, test, and install
everything: build fmt lint test install
@echo "✅ Everything complete!"
# Show help
help:
@echo "📖 Available targets:"
@echo " build - Build the binary"
@echo " clean - Clean build artifacts"
@echo " test - Run unit tests and OAuth integration tests"
@echo " test-unit - Run unit tests only"
@echo " test-oauth - Run OAuth integration tests"
@echo " test-smoke - Run smoke tests (requires authentication)"
@echo " test-all - Run all tests including smoke tests"
@echo " deps - Install dependencies"
@echo " fmt - Format code"
@echo " lint - Lint code"
@echo " install - Install binary to system"
@echo " dev-install - Create development symlink"
@echo " build-all - Cross-compile for all platforms"
@echo " release - Prepare release builds"
@echo " run - Build and run the binary"
@echo " everything - Run build, fmt, lint, test, and install"
@echo " help - Show this help"