-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (68 loc) · 2.36 KB
/
Copy pathMakefile
File metadata and controls
78 lines (68 loc) · 2.36 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
.PHONY: help build test lint clean fmt lint-only frontend dev-tag
# Docker image versions
GOLANGCI_LINT_VERSION := v2.12.2
help:
@echo "Available targets:"
@echo " build - Build the glisk binary"
@echo " test - Run tests with coverage"
@echo " frontend - Install deps and build the SPA"
@echo " lint - Format code and run golangci-lint"
@echo " fmt - Format code using golangci-lint"
@echo " lint-only - Run golangci-lint without formatting"
@echo " clean - Clean build artifacts"
@echo " dev-tag - Generate dev tag for Docker image"
# Build the binary. The frontend dist is embedded; run `make frontend` first
# for a production build (the committed .gitkeep keeps `go build` working).
build:
go build -v -ldflags="-s -w" -o glisk .
test:
go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
frontend:
cd internal/webui/frontend && npm install && npm run build
fmt:
docker run --rm \
-u "$(shell id -u):$(shell id -g)" \
-e GOCACHE=/tmp/go-cache \
-e GOMODCACHE=/tmp/go-mod-cache \
-e GOLANGCI_LINT_CACHE=/tmp/golangci-lint-cache \
-v "$(PWD):/app" \
-v "$(HOME)/.cache:/tmp/cache" \
-w /app \
golangci/golangci-lint:$(GOLANGCI_LINT_VERSION) \
golangci-lint run --fix
lint:
docker run --rm \
-u "$(shell id -u):$(shell id -g)" \
-e GOCACHE=/tmp/go-cache \
-e GOMODCACHE=/tmp/go-mod-cache \
-e GOLANGCI_LINT_CACHE=/tmp/golangci-lint-cache \
-v "$(PWD):/app" \
-v "$(HOME)/.cache:/tmp/cache" \
-w /app \
golangci/golangci-lint:$(GOLANGCI_LINT_VERSION) \
golangci-lint run --fix
lint-only:
docker run --rm \
-u "$(shell id -u):$(shell id -g)" \
-e GOCACHE=/tmp/go-cache \
-e GOMODCACHE=/tmp/go-mod-cache \
-e GOLANGCI_LINT_CACHE=/tmp/golangci-lint-cache \
-v "$(PWD):/app" \
-v "$(HOME)/.cache:/tmp/cache" \
-w /app \
golangci/golangci-lint:$(GOLANGCI_LINT_VERSION) \
golangci-lint run
clean:
rm -f glisk coverage.txt
dev-tag:
@SHORT_SHA=$$(git rev-parse --short HEAD 2>/dev/null || echo "unknown"); \
LAST_TAG=$$(git describe --tags --abbrev=0 --match="v[0-9]*.[0-9]*.[0-9]*" 2>/dev/null || echo ""); \
if [ -z "$$LAST_TAG" ]; then \
VERSION="0.0.0"; \
COMMIT_COUNT=$$(git rev-list --count HEAD); \
else \
VERSION=$${LAST_TAG#v}; \
COMMIT_COUNT=$$(git rev-list --count $${LAST_TAG}..HEAD); \
fi; \
DEV_TAG="v$${VERSION}-dev.$${COMMIT_COUNT}.$${SHORT_SHA}"; \
echo "$$DEV_TAG"