56 lines
1.3 KiB
Makefile
56 lines
1.3 KiB
Makefile
#!/usr/bin/env nu
|
|
|
|
# Update buf dependencies
|
|
buf-deps:
|
|
buf dep update
|
|
|
|
# Generate protobuf files
|
|
proto: buf-deps
|
|
buf generate
|
|
|
|
# Build the server binary
|
|
build: proto
|
|
go build -o bin/server cmd/server/main.go
|
|
|
|
# Run the server
|
|
run: build
|
|
./bin/server
|
|
|
|
# Clean build artifacts
|
|
clean:
|
|
rm -rf bin/
|
|
rm -rf pkg/pb/
|
|
|
|
# Run tests
|
|
test:
|
|
go test ./...
|
|
|
|
# Run linter
|
|
lint:
|
|
golangci-lint run
|
|
|
|
# Install required tools and dependencies
|
|
install-deps:
|
|
@echo "Installing buf..."
|
|
@if ! command -v buf >/dev/null 2>&1; then \
|
|
mkdir -p ~/.local/bin && \
|
|
curl -sSL "https://github.com/bufbuild/buf/releases/latest/download/buf-$(uname -s)-$(uname -m)" -o "$HOME/.local/bin/buf" && \
|
|
chmod +x "$HOME/.local/bin/buf"; \
|
|
echo "buf installed to ~/.local/bin/buf"; \
|
|
echo "Make sure ~/.local/bin is in your PATH"; \
|
|
else \
|
|
echo "buf already installed"; \
|
|
fi
|
|
@echo "Installing protoc plugins..."
|
|
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
|
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
|
|
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest
|
|
|
|
# Download and tidy dependencies
|
|
deps:
|
|
go mod download
|
|
go mod tidy
|
|
|
|
# Development workflow
|
|
dev: deps proto run
|