-
Notifications
You must be signed in to change notification settings - Fork 27
/
Makefile
62 lines (44 loc) · 1.62 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
PROJECT=tichi
GOPATH ?= $(shell go env GOPATH)
# Ensure GOPATH is set before running build process.
ifeq "$(GOPATH)" ""
$(error Please set the environment variable GOPATH before running `make`)
endif
FAIL_ON_STDOUT := awk '{ print } END { if (NR > 0) { exit 1 } }'
CURDIR := $(shell pwd)
path_to_add := $(addsuffix /bin,$(subst :,/bin:,$(GOPATH))):$(PWD)/tools/bin
export PATH := $(path_to_add):$(PATH)
GO := GO111MODULE=on go
GOBUILD := $(GO) build
GOTEST := $(GO) test
PACKAGE_LIST := go list ./...
PACKAGES := $$($(PACKAGE_LIST))
PACKAGE_DIRECTORIES := $(PACKAGE_LIST) | sed 's|github.com/ti-community-infra/$(PROJECT)/||'
FILES := $$(find $$($(PACKAGE_DIRECTORIES)) -name "*.go")
.PHONY: clean test cover fmt tidy staticcheck dev check label-dumpling-checks
dev: check staticcheck test
check: fmt tidy
clean:
$(GO) clean -i ./...
rm -rf *.out
test:
$(GOTEST) $(PACKAGES)
@>&2 echo "Great, all tests passed."
cover:
rm -rf coverage.txt
$(GOTEST) $(PACKAGES) -race -coverprofile=coverage.txt -covermode=atomic
echo "Uploading coverage results..."
@curl -s https://codecov.io/bash | bash > codecov_upload.log
fmt:
@echo "gofmt (simplify)"
@gofmt -s -l -w $(FILES) 2>&1 | $(FAIL_ON_STDOUT)
tidy:
@echo "go mod tidy"
./tools/check/check-tidy.sh
staticcheck: tools/bin/golangci-lint
tools/bin/golangci-lint run $$($(PACKAGE_DIRECTORIES)) --timeout 500s
tools/bin/golangci-lint:
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b ./tools/bin v1.59.1
label-dumpling-checks:
@echo "label-dumpling checks"
./scripts/label-dumpling-checks.sh