-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (61 loc) · 2.12 KB
/
Makefile
File metadata and controls
79 lines (61 loc) · 2.12 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
79
VERSION ?= 1.5.0
COMMIT_HASH ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_TIME ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -s -w -X 'main.Version=$(VERSION)' -X 'main.BuildTime=$(BUILD_TIME)' -X 'main.CommitHash=$(COMMIT_HASH)'
.PHONY: build test test-integration test-short test-race bench cover lint vet fmt clean install run tidy help
build:
CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -trimpath -o bin/cmd4coder ./cmd/cli
@ls -lh bin/cmd4coder | awk '{print "Built: " $$5 " (" $$9 ")"}'
build-all:
@bash scripts/build.sh
test:
go test -v -cover ./...
test-short:
go test -short -cover ./...
test-integration:
go test -v -tags=integration ./test/...
test-race:
go test -race ./...
bench:
go test -bench=. -benchmem ./...
cover:
go test -coverprofile=coverage_reports/coverage.out ./...
go tool cover -html=coverage_reports/coverage.out -o coverage_reports/coverage.html
go tool cover -func=coverage_reports/coverage.out
lint:
golangci-lint run ./...
vet:
go vet ./...
fmt:
go fmt ./...
clean:
rm -rf bin/ build/ coverage_reports/coverage.out coverage_reports/coverage.html
tidy:
go mod tidy
install: build
@mkdir -p $(GOPATH)/bin
cp bin/cmd4coder $(GOPATH)/bin/
run:
go run ./cmd/cli
validator:
go run ./cmd/validator -d ./data -v
help:
@echo "cmd4coder Makefile"
@echo ""
@echo "Usage:"
@echo " make build Build the binary"
@echo " make build-all Build for all platforms"
@echo " make test Run all tests with coverage"
@echo " make test-short Run tests (skip slow tests)"
@echo " make test-race Run tests with race detector"
@echo " make bench Run benchmarks"
@echo " make cover Generate coverage report"
@echo " make lint Run linter"
@echo " make vet Run go vet"
@echo " make fmt Format code"
@echo " make clean Clean build artifacts"
@echo " make test-integration Run integration tests"
@echo " make tidy Run go mod tidy"
@echo " make install Build and install to GOPATH/bin"
@echo " make run Run without building"
@echo " make validator Run data validator"