87f56c45 2026-05-01 Pavel Safronov | 1 | .PHONY: test tools-install tools-install-release |
04989558 2026-05-01 Pavel Safronov | 2 | |
| 3 | BINARY=template |
| 4 | VERSION=$(shell git describe --tags) |
| 5 | LDFLAGS=-ldflags "-w -s -X main.Version=${VERSION}" |
| 6 | |
| 7 | all: build test lint |
| 8 | all-clean: clean all |
| 9 | |
87f56c45 2026-05-01 Pavel Safronov | 10 | # Install lint tools at the versions pinned in tools/go.mod. |
04989558 2026-05-01 Pavel Safronov | 11 | tools-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 Safronov | 14 | |
| 15 | # Install release tools (goreleaser) pinned in tools/release/go.mod. |
| 16 | tools-install-release: |
| 17 | cd tools/release && go install github.com/goreleaser/goreleaser/v2 |
04989558 2026-05-01 Pavel Safronov | 18 | |
| 19 | prep: |
| 20 | go mod tidy |
| 21 | |
| 22 | clean: |
| 23 | go clean |
| 24 | go mod tidy |
| 25 | |
| 26 | build: prep |
37160b89 2026-05-01 Pavel Safronov | 27 | go build ${LDFLAGS} -o ${BINARY} ./cmd/template/ |
04989558 2026-05-01 Pavel Safronov | 28 | |
| 29 | lint: build tools-install |
| 30 | golangci-lint run --timeout=10m |
| 31 | |
| 32 | lint-docs: tools-install |
| 33 | gomarklint . |
| 34 | |
ecad2935 2026-05-01 Pavel Safronov | 35 | COVERAGE_THRESHOLD=65 |
| 36 | |
04989558 2026-05-01 Pavel Safronov | 37 | test: build |
| 38 | go test -v ./... -coverprofile="./test-coverage.out" |
ecad2935 2026-05-01 Pavel Safronov | 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}}' |
04989558 2026-05-01 Pavel Safronov | 42 | |
| 43 | test_coverage: test |
| 44 | go tool cover -html="./test-coverage.out" -o "./test-coverage.html" |
| 45 | |
| 46 | test_coverage_html: test_coverage |
| 47 | open "./test-coverage.html" |
| 48 | |
| 49 | install: build test lint |
37160b89 2026-05-01 Pavel Safronov | 50 | go install ${LDFLAGS} ./cmd/template/ |
04989558 2026-05-01 Pavel Safronov | 51 | |
| 52 | uninstall: |
| 53 | go clean -i gitlab.com/PavelSafronov/template... |
| 54 | rm -f $(BINARY) |
| 55 | |
87f56c45 2026-05-01 Pavel Safronov | 56 | release: all tools-install tools-install-release |
04989558 2026-05-01 Pavel Safronov | 57 | git restore go.mod |
| 58 | goreleaser release --clean |
| 59 | |
| 60 | brew-install: |
| 61 | brew tap PavelSafronov/template https://gitlab.com/PavelSafronov/template.git |
| 62 | brew install template |
| 63 | |
| 64 | brew-uninstall: |
| 65 | brew uninstall template |
| 66 | brew untap PavelSafronov/template |