-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
48 lines (34 loc) · 1.08 KB
/
Makefile
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
.PHONY : build run fresh test clean
include dev.env
export
BIN := cache-offloader
HASH := $(shell git rev-parse --short HEAD)
COMMIT_DATE := $(shell git show -s --format=%ci ${HASH})
BUILD_DATE := $(shell date '+%Y-%m-%d %H:%M:%S')
VERSION := ${HASH} (${COMMIT_DATE})
clean:
go clean
go clean -testcache
rm -rf ./bin ./vendor go.sum coverage.out coverage.out.tmp
go mod tidy
lint:
golangci-lint run
format:
gofumpt -l -w .
build:
export GO111MODULE=on
env GOARCH=amd64 GOOS=linux go build -o bin/${BIN} -ldflags="-s -w -X 'main.version=${VERSION}' -X 'main.buildDate=${BUILD_DATE}'" -v ./cmd/${BIN}.go
env GOARCH=arm64 GOOS=darwin go build -o bin/${BIN}-mac -ldflags="-s -w" -v ./cmd/${BIN}.go
run: fresh
go run ./cmd/${BIN}.go
fresh: clean build
test:
go test -race -count=1 -v --coverprofile=coverage.txt ./...
go tool cover -func coverage.txt | grep total
test-json:
go test -json ./... > test-report.json
cov: test
go tool cover -html=coverage.txt
.PHONY: setup
setup:
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.46.2