fuzzyworld

template / files / Makefile

Makefile

1.6 KB · history · blame

1.PHONY: test tools-install tools-install-release
2
3BINARY=template
4VERSION=$(shell git describe --tags)
5LDFLAGS=-ldflags "-w -s -X main.Version=${VERSION}"
6
7all: build test lint
8all-clean: clean all
9
10# Install lint tools at the versions pinned in tools/go.mod.
11tools-install:
12 cd tools && go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint
13 cd tools && go install github.com/shinagawa-web/gomarklint
14
15# Install release tools (goreleaser) pinned in tools/release/go.mod.
16tools-install-release:
17 cd tools/release && go install github.com/goreleaser/goreleaser/v2
18
19prep:
20 go mod tidy
21
22clean:
23 go clean
24 go mod tidy
25
26build: prep
27 go build ${LDFLAGS} -o ${BINARY} ./cmd/template/
28
29lint: build tools-install
30 golangci-lint run --timeout=10m
31
32lint-docs: tools-install
33 gomarklint .
34
35COVERAGE_THRESHOLD=65
36
37test: build
38 go test -v ./... -coverprofile="./test-coverage.out"
39 @go tool cover -func="./test-coverage.out" | grep "^total:" | \
40 awk -v t=$(COVERAGE_THRESHOLD) '{sub(/%/,"",$$3); if ($$3+0 < t) \
41 {print "Coverage " $$3 "% is below threshold " t "%"; exit 1}}'
42
43test_coverage: test
44 go tool cover -html="./test-coverage.out" -o "./test-coverage.html"
45
46test_coverage_html: test_coverage
47 open "./test-coverage.html"
48
49install: build test lint
50 go install ${LDFLAGS} ./cmd/template/
51
52uninstall:
53 go clean -i gitlab.com/PavelSafronov/template...
54 rm -f $(BINARY)
55
56release: all tools-install tools-install-release
57 git restore go.mod
58 goreleaser release --clean
59
60brew-install:
61 brew tap PavelSafronov/template https://gitlab.com/PavelSafronov/template.git
62 brew install template
63
64brew-uninstall:
65 brew uninstall template
66 brew untap PavelSafronov/template