-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
151 lines (129 loc) · 4.53 KB
/
Justfile
File metadata and controls
151 lines (129 loc) · 4.53 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
# Variables
project_name := "greenlight-client"
binary_name := "client"
sources := "./cmd/cli"
output_dir := "./bin"
# Default task: list all available recipes
default:
@just --list
# Generate fish shell completions
completion-fish:
@echo "🐟 Generating fish completions..."
@mkdir -p ~/.config/fish/completions
@just --completions fish > ~/.config/fish/completions/just.fish
@echo "✅ Completions installed to ~/.config/fish/completions/just.fish"
# Run the application (Dev mode)
run:
@echo "🚀 Running application..."
go run {{ sources }}
# Run with hot reloading (requires air)
run-hot:
@echo "🔥 Running with hot-reloading..."
air
# Build the binary for production
build:
@echo "🔨 Building binary..."
@mkdir -p {{ output_dir }}
go build -o {{ output_dir }}/{{ binary_name }} {{ sources }}
@echo "✅ Build complete: {{ output_dir }}/{{ binary_name }}"
# Build the binary for linux_amd64 (production remote)
build-linux:
@echo "🔨 Building binary for linux_amd64..."
@mkdir -p {{ output_dir }}/linux_amd64
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s" -o {{ output_dir }}/linux_amd64/{{ binary_name }} {{ sources }}
@echo "✅ Build complete: {{ output_dir }}/linux_amd64/{{ binary_name }}"
# Build optimized release binary (smaller size, same speed)
build-release:
@echo "🚀 Building optimized release binary..."
@mkdir -p {{ output_dir }}
go build -ldflags="-s -w" -o {{ output_dir }}/{{ binary_name }} {{ sources }}
@echo "✅ Release build complete: {{ output_dir }}/{{ binary_name }}"
@ls -lh {{ output_dir }}/{{ binary_name }} | awk '{print "📦 Size: " $5}'
# Build release binary + compress with UPX (smallest size)
build-release-upx:
@echo "🚀 Building optimized release binary with UPX compression..."
@mkdir -p {{ output_dir }}
go build -ldflags="-s -w" -o {{ output_dir }}/{{ binary_name }} {{ sources }}
@if command -v upx > /dev/null 2>&1; then \
upx --best --lzma {{ output_dir }}/{{ binary_name }}; \
echo "✅ UPX compressed build complete: {{ output_dir }}/{{ binary_name }}"; \
else \
echo "⚠️ UPX not found. Install with: nix-env -iA nixpkgs.upx"; \
echo "✅ Build complete without compression: {{ output_dir }}/{{ binary_name }}"; \
fi
@ls -lh {{ output_dir }}/{{ binary_name }} | awk '{print "📦 Final size: " $5}'
# Run tests
test:
@echo "🧪 Running tests..."
go test -v ./...
# Run only unit tests (skip integration tests)
test-short:
@echo "🧪 Running unit tests (skipping integration tests)..."
go test -short -v ./...
# Clean test cache
test-clean:
@echo "🧹 Cleaning test cache..."
go clean -testcache
@echo "✅ Test cache cleaned."
# Run tests and stop on first failure
test-fast:
@echo "🧪 Running tests (failfast)..."
go test -failfast -v ./...
# Run tests sequentially per package (stops on error)
test-seq:
@echo "🧪 Running tests sequentially..."
@for s in $(go list ./...); do \
if ! go test -failfast -v -p 1 $s; then \
echo "❌ Test failed in package $s"; \
exit 1; \
fi; \
done
@echo "✅ All sequential tests passed."
# Run specific test or subtest (usage: just test-run TestName)
test-run TEST=".":
@echo "🧪 Running test(s) matching '{{ TEST }}'..."
go test -v -run {{ TEST }} ./...
# Run tests with race detector enabled
test-race:
@echo "🏃 Running tests with race detector..."
CGO_ENABLED=1 go test -race -v ./...
# Run go vet
vet:
@echo "🧐 Running go vet..."
go vet ./...
# Run quality control checks (tidy, vet, staticcheck, test -race)
audit:
@echo 'Checking module dependencies...'
go mod tidy -diff
go mod verify
@echo 'Vetting code...'
go vet ./...
staticcheck ./...
@echo 'Running tests...'
CGO_ENABLED=1 go test -race -vet=off ./...
# Lint the code (requires golangci-lint)
lint:
@echo "🧹 Linting code..."
golangci-lint run
# Format code
fmt:
@echo "📝 Formatting code..."
go fmt ./...
# Tidy and vendor module dependencies, and format all .go files
tidy:
@echo 'Tidying module dependencies...'
go mod tidy
@echo 'Verifying and vendoring module dependencies...'
go mod verify
go mod vendor
@echo 'Formatting .go files...'
go fmt ./...
# Clean build artifacts and tls and tmp folders
[confirm]
clean:
@echo "🗑️ Cleaning build artifacts..."
rm -rf {{ output_dir }}
rm -rf dist
rm -rf tmp
rm -rf tls
@echo "✨ Clean complete."