Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
80 lines (63 loc) · 2.77 KB
/
Copy pathMakefile
File metadata and controls
80 lines (63 loc) · 2.77 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# By default, Makefiles are executed with /bin/sh, which may not support
# certain features like `$(shell ...)` or `$(if ...)`. Force bash for
# consistency.
SHELL := /bin/bash
# Strict shell flags. -e: exit on error. -u: error on unset vars. -o pipefail:
# any failure in a pipeline fails the whole pipeline. -c: required.
.SHELLFLAGS := -euo pipefail -c
# Default goal: print help when `make` is invoked with no target.
.DEFAULT_GOAL := help
_INFO := "\033[32m%s\033[0m %s\n"
_WARN := "\033[33m%s\033[0m %s\n"
##------------------------------------------------------------------------------
# Help — self-documenting target list
#
# Targets are documented inline by appending `## <description>` to the rule
# line. The help target parses those annotations and prints them.
##------------------------------------------------------------------------------
.PHONY: help
help: ## Show this help message and exit
@printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"
@awk 'BEGIN {FS = ":.*## "} \
/^[a-zA-Z_][a-zA-Z0-9_-]+:.*## / { printf " \033[36m%-22s\033[0m %s\n", $$1, $$2 }' \
$(MAKEFILE_LIST) | sort
@printf "\n"
.PHONY: clean
clean: ## Remove build files, test coverage, and other artifacts
rm -rf "./build"
.PHONY: lint
lint: ## Golangci-lint: run the configured linters (includes `go vet`)
golangci-lint run
.PHONY: fix
fix: ## Golangci-lint: apply linter auto-fixes
golangci-lint run --fix
.PHONY: fmt-check
fmt-check: ## Golangci-lint/Prettier: check code format without applying changes (includes `go fmt`)
npx prettier --check .
golangci-lint fmt --diff-colored && echo "Golangci-lint Formatters: OK"
.PHONY: fmt
fmt: ## Golangci-lint/Prettier: run the configured code formatters (includes `go fmt`)
npx prettier --write .
golangci-lint fmt && echo "Golangci-lint Formatters: OK"
.PHONY: test
test: ## Run the test suite with the race detector and shuffled order
go test -race -shuffle=on ./...
build:
mkdir -p "$@"
.PHONY: cover
cover: | build ## Write a test coverage profile and HTML report under build/
go test -race -shuffle=on -covermode=atomic -coverprofile=build/coverage.out ./...
go tool cover -html=build/coverage.out -o build/coverage.html
@printf $(_INFO) "[coverage]" "report written to build/coverage.html"
.PHONY: vulncheck
vulncheck: ## Scan for known vulnerabilities with govulncheck
go run golang.org/x/vuln/cmd/govulncheck@latest ./...
.PHONY: ci
ci: fmt-check lint test ## Run what CI runs: check format + lint + test
##------------------------------------------------------------------------------
# Local overrides
#
# If .local/Makefile exists it can define additional targets or override the
# ones above. Must be the last directive in this file.
##------------------------------------------------------------------------------
-include .local/Makefile