forked from yoanbernabeu/grepai
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
76 lines (56 loc) · 2.1 KB
/
Makefile
File metadata and controls
76 lines (56 loc) · 2.1 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
.PHONY: build install test clean lint run docs docs-generate docs-build docs-dev fmt pre-commit nix-hash
BINARY_NAME=grepai
VERSION?=0.1.0
BUILD_DIR=bin
LDFLAGS=-ldflags "-s -w -X main.version=$(VERSION)"
build:
go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/grepai
install:
go install $(LDFLAGS) ./cmd/grepai
test:
go test -v -race ./...
test-cover:
go test -v -race -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
clean:
rm -rf $(BUILD_DIR)
rm -f coverage.out coverage.html
lint:
docker run --rm -v $(PWD):/app -w /app golangci/golangci-lint:v1.64.2 golangci-lint run ./...
lint-local:
golangci-lint run ./...
run: build
./$(BUILD_DIR)/$(BINARY_NAME)
# Cross-compilation
build-all: build-linux build-darwin build-windows
build-linux:
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 ./cmd/grepai
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 ./cmd/grepai
build-darwin:
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 ./cmd/grepai
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 ./cmd/grepai
build-windows:
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe ./cmd/grepai
# Documentation
docs: docs-build
docs-generate:
go run cmd/gendocs/main.go
docs-build: docs-generate
cd docs && npm ci && npm run build
docs-dev: docs-generate
cd docs && npm install && npm run dev
# Code formatting
fmt:
gofmt -w .
# Pre-commit checks: format, vet, lint, and test
pre-commit: fmt
go vet ./...
docker run --rm -v $(PWD):/app -w /app golangci/golangci-lint:v1.64.2 golangci-lint run ./...
go test -race ./...
@echo "✓ All checks passed! Ready to commit."
# Nix flake: compute vendorHash via Docker
nix-hash:
@echo "Computing vendorHash (requires Docker)..."
@docker run --rm -v $(PWD):/src -w /src nixos/nix:latest sh -c \
'echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf && \
nix build .#grepai 2>&1 | grep "got:" | sed "s/.*got:\s*//"'