This repository has been archived by the owner on Jan 14, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
Makefile
71 lines (53 loc) · 2.18 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
SOURCE_FILES?=./...
TEST_PATTERN?=.
TEST_OPTIONS?=
OS=$(shell uname -s)
export PATH := ./bin:$(PATH)
export GO111MODULE := on
# enable consistent Go 1.12/1.13 GOPROXY behavior.
export GOPROXY = https://proxy.golang.org
setup: ## Install all the build and lint dependencies
mkdir -p bin
curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh
curl -sfL https://install.goreleaser.com/github.com/gohugoio/hugo.sh | sh
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh
ifeq ($(OS), Darwin)
curl -sfL -o ./bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.4.6/shellcheck_darwin
else
curl -sfL -o ./bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.4.6/shellcheck
endif
chmod +x ./bin/shellcheck
go mod download
.PHONY: setup
install: build ## build and install
go install .
test: ## Run all the tests
go test $(TEST_OPTIONS) -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt $(SOURCE_FILES) -run $(TEST_PATTERN) -timeout=2m
cover: test ## Run all the tests and opens the coverage report
go tool cover -html=coverage.txt
fmt: ## gofmt and goimports all go files
find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done
lint: ## Run all the linters
./bin/golangci-lint run --enable-all --disable wsl ./...
precommit: lint ## Run precommit hook
ci: build lint test ## travis-ci entrypoint
git diff .
./bin/goreleaser --snapshot --rm-dist
build: hooks ## Build a beta version of goreleaser
go build
./scripts/build-site.sh
.DEFAULT_GOAL := build
generate: ## regenerate shell code from client9/shlib
./makeshellfn.sh > shellfn.go
.PHONY: ci help generate clean
clean: ## clean up everything
go clean ./...
rm -f godownloader
rm -rf ./bin ./dist ./vendor
git gc --aggressive
hooks:
echo "make lint" > .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
# Absolutely awesome: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'