-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
53 lines (44 loc) · 1.51 KB
/
Makefile
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
MAKEFLAGS += --warn-undefined-variables
SHELL := bash
.SHELLFLAGS := -euo pipefail -c
.DEFAULT_GOAL := all
BIN_DIR ?= $(shell go env GOPATH)/bin
export PATH := $(PATH):$(BIN_DIR)
.PHONY: deps
deps: ## download go modules
go mod download
.PHONY: fmt
fmt: lint/check ## ensure consistent code style
go run oss.indeed.com/go/go-groups -w .
gofmt -s -w .
golangci-lint run --fix > /dev/null 2>&1 || true
go mod tidy
.PHONY: lint/check
lint/check:
@if ! golangci-lint --version > /dev/null 2>&1; then \
echo -e "\033[0;33mgolangci-lint is not installed: run \`\033[0;32mmake lint-install\033[0m\033[0;33m\` or install it from https://golangci-lint.run\033[0m"; \
exit 1; \
fi
.PHONY: lint-install
lint-install: ## installs golangci-lint to the go bin dir
@if ! golangci-lint --version > /dev/null 2>&1; then \
echo "Installing golangci-lint"; \
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(BIN_DIR) v1.30.0; \
fi
.PHONY: lint
lint: lint/check ## run golangci-lint
golangci-lint run
@if [ -n "$$(gofmt -s -l .)" ] || [ -n "$$(go run oss.indeed.com/go/go-groups -d .)" ]; then \
echo -e "\033[0;33mdetected fmt problems: run \`\033[0;32mmake fmt\033[0m\033[0;33m\`\033[0m"; \
exit 1; \
fi
.PHONY: test
test: lint ## run go tests
go test ./... -race
.PHONY: all
all: test
.PHONY: help
help: ## displays this help message
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_\/-]+:.*?## / {printf "\033[34m%-12s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \
sort | \
grep -v '#'