Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
47 lines (36 loc) · 1.46 KB
/
Copy pathMakefile
File metadata and controls
47 lines (36 loc) · 1.46 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
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
LDFLAGS := -ldflags "-s -w \
-X github.com/open-cli-collective/google-cli/internal/version.Version=$(VERSION) \
-X github.com/open-cli-collective/google-cli/internal/version.Commit=$(COMMIT) \
-X github.com/open-cli-collective/google-cli/internal/version.Date=$(DATE)"
export GOFLAGS := -tags=keyring_no1password,keyring_nopassage
.PHONY: build test test-cover test-cover-check lint fmt tidy check install
build:
go build $(LDFLAGS) -o bin/gro ./cmd/gro
go build $(LDFLAGS) -o bin/grw ./cmd/grw
test:
go test -race ./...
test-cover:
go test -race -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
test-cover-check:
@go test -race -coverprofile=coverage.out ./... > /dev/null 2>&1
@total=$$(go tool cover -func=coverage.out | grep '^total:' | awk '{print $$3}' | tr -d '%'); \
threshold=60; \
echo "Total coverage: $${total}% (threshold: $${threshold}%)"; \
if [ $$(echo "$$total < $$threshold" | bc) -eq 1 ]; then \
echo "FAIL: coverage below threshold"; exit 1; \
fi
lint:
golangci-lint run ./...
fmt:
go fmt ./...
goimports -local github.com/open-cli-collective/google-cli -w .
tidy:
go mod tidy
git diff --exit-code go.mod go.sum
check: tidy lint test build
install: build
install -m 755 bin/gro bin/grw /usr/local/bin/