fuzzyworld

template / files / Makefile

Makefile

Blame: the commit that last changed each line · file · history

87f56c45 2026-05-01 Pavel Safronov1.PHONY: test tools-install tools-install-release
04989558 2026-05-01 Pavel Safronov2
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
87f56c45 2026-05-01 Pavel Safronov10# Install lint tools at the versions pinned in tools/go.mod.
04989558 2026-05-01 Pavel Safronov11tools-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
87f56c45 2026-05-01 Pavel Safronov14
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
04989558 2026-05-01 Pavel Safronov18
19prep:
20 go mod tidy
21
22clean:
23 go clean
24 go mod tidy
25
26build: prep
37160b89 2026-05-01 Pavel Safronov27 go build ${LDFLAGS} -o ${BINARY} ./cmd/template/
04989558 2026-05-01 Pavel Safronov28
29lint: build tools-install
30 golangci-lint run --timeout=10m
31
32lint-docs: tools-install
33 gomarklint .
34
ecad2935 2026-05-01 Pavel Safronov35COVERAGE_THRESHOLD=65
36
04989558 2026-05-01 Pavel Safronov37test: build
38 go test -v ./... -coverprofile="./test-coverage.out"
ecad2935 2026-05-01 Pavel Safronov39 @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}}'
04989558 2026-05-01 Pavel Safronov42
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
37160b89 2026-05-01 Pavel Safronov50 go install ${LDFLAGS} ./cmd/template/
04989558 2026-05-01 Pavel Safronov51
52uninstall:
53 go clean -i gitlab.com/PavelSafronov/template...
54 rm -f $(BINARY)
55
87f56c45 2026-05-01 Pavel Safronov56release: all tools-install tools-install-release
04989558 2026-05-01 Pavel Safronov57 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