-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (47 loc) · 1.97 KB
/
Copy pathMakefile
File metadata and controls
58 lines (47 loc) · 1.97 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
.PHONY: help build clean test coverage-html lint install release-check verify verify-no-deps
COVERAGE_FILE := coverage.out
# Cached analyzer results contain source paths, so isolate them per checkout/worktree.
GOLANGCI_LINT_CACHE ?= $(HOME)/.cache/golangci-lint$(CURDIR)
help:
@printf "Available targets:\n"
@printf " %-14s %s\n" "help" "Show this help text."
@printf " %-14s %s\n" "build" "Build the tao binary into the bin directory."
@printf " %-14s %s\n" "clean" "Remove build and coverage artifacts."
@printf " %-14s %s\n" "test" "Run all Go tests with coverage output."
@printf " %-14s %s\n" "coverage-html" "Open an HTML coverage report in the browser."
@printf " %-14s %s\n" "lint" "Run golangci-lint."
@printf " %-14s %s\n" "install" "Build and install the tao binary into ~/.bin."
@printf " %-14s %s\n" "release-check" "Validate the GoReleaser config (requires goreleaser)."
@printf " %-14s %s\n" "verify-no-deps" "Fail if any third-party dependency is present."
@printf " %-14s %s\n" "verify" "Run the complete repository verification gate."
build:
@mkdir -p bin
@go build -o bin/tao ./cmd/tao
clean:
@rm -rvf bin $(COVERAGE_FILE)
test:
@go test -coverprofile=$(COVERAGE_FILE) ./...
@awk 'NR>1 { \
n=split($$1,p,"/"); pkg=p[1]; \
for(i=2;i<n;i++) pkg=pkg"/"p[i]; \
stmts[pkg]+=$$2; if($$3>0) cov[pkg]+=$$2 \
} \
END { for(k in stmts) printf "%6.1f%% %s\n", 100*cov[k]/stmts[k], k }' \
$(COVERAGE_FILE) | sort -k2
coverage-html: test
@go tool cover -html=$(COVERAGE_FILE)
lint:
@GOLANGCI_LINT_CACHE="$(GOLANGCI_LINT_CACHE)" golangci-lint run --allow-parallel-runners
install: build
@rm -f ~/.bin/tao; cp ./bin/tao ~/.bin/tao
release-check:
@goreleaser check
verify: build test lint verify-no-deps
verify-no-deps:
@count=$$(go list -m all | wc -l); \
if [ "$$count" -ne 1 ]; then \
echo "verify-no-deps: expected only the main module, found $$count modules:"; \
go list -m all; \
exit 1; \
fi; \
echo "verify-no-deps: no third-party dependencies."