-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
26 lines (23 loc) · 878 Bytes
/
Makefile
File metadata and controls
26 lines (23 loc) · 878 Bytes
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
# Locally render the godocs site
pkgdocs:
@echo "Launching pkgdocs ..."
@cd v2 && \
go run golang.org/x/pkgsite/cmd/pkgsite@latest -open
test-cov:
@echo "Running tests and generating coverage output ..."
@cd v2 && \
go test ./... -coverprofile coverage.out -covermode count
@sleep 2 # Sleeping to allow for coverage.out file to get generated
covcheck: test-cov
@COVERAGE=$(shell cd v2 && go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'); \
THRESHOLD=75.0; \
echo "Test coverage: $$COVERAGE%"; \
echo "Coverage threshold: $$THRESHOLD%"; \
if [ $$(echo "$$COVERAGE < $$THRESHOLD" | bc) -gt 0 ]; then \
echo "WARNING: Test coverage ($$COVERAGE%) is below the threshold ($$THRESHOLD%)!"; \
exit 1; \
else \
echo "Test coverage ($$COVERAGE%) exceeds the threshold ($$THRESHOLD%)."; \
exit 0; \
fi
PHONY: test-cov covcheck pkgdocs