-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
56 lines (46 loc) · 1.19 KB
/
Copy pathMakefile
File metadata and controls
56 lines (46 loc) · 1.19 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
# gopy developer Makefile.
# Run `make help` for the task list.
GO ?= go
PKG := ./...
BIN_DIR := bin
BIN := $(BIN_DIR)/gopy
LDFLAGS ?= -s -w
.PHONY: help
help:
@echo "Targets:"
@echo " build Build the gopy binary into ./$(BIN)"
@echo " test Run unit tests with the race detector"
@echo " cover Produce coverage.txt across all packages"
@echo " vet Run go vet"
@echo " fmt Run gofmt -s -w"
@echo " lint Run golangci-lint (if installed)"
@echo " tidy Run go mod tidy"
@echo " clean Remove build output"
.PHONY: build
build:
@mkdir -p $(BIN_DIR)
$(GO) build -trimpath -ldflags '$(LDFLAGS)' -o $(BIN) ./cmd/gopy
.PHONY: test
test:
$(GO) test -race -count=1 $(PKG)
.PHONY: cover
cover:
$(GO) test -race -covermode=atomic -coverprofile=coverage.txt $(PKG)
$(GO) tool cover -func=coverage.txt | tail -n 1
.PHONY: vet
vet:
$(GO) vet $(PKG)
.PHONY: fmt
fmt:
gofmt -s -w .
.PHONY: lint
lint:
@command -v golangci-lint >/dev/null 2>&1 || { \
echo "golangci-lint is not installed. See https://golangci-lint.run"; exit 1; }
golangci-lint run
.PHONY: tidy
tidy:
$(GO) mod tidy
.PHONY: clean
clean:
rm -rf $(BIN_DIR) dist coverage.txt coverage.html