| 1 |
export GO111MODULE := on |
| 2 |
export PATH := ./bin:$(PATH) |
| 3 |
|
| 4 |
ci: bootstrap lint cover |
| 5 |
.PHONY: ci |
| 6 |
|
| 7 |
################################################# |
| 8 |
# Bootstrapping for base golang package and tool deps |
| 9 |
################################################# |
| 10 |
|
| 11 |
bootstrap: |
| 12 |
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.21.0 |
| 13 |
.PHONY: bootstrap |
| 14 |
|
| 15 |
mod-update: |
| 16 |
go get -u -m |
| 17 |
go mod tidy |
| 18 |
|
| 19 |
mod-tidy: |
| 20 |
go mod tidy |
| 21 |
|
| 22 |
.PHONY: $(CMD_PKGS) |
| 23 |
.PHONY: mod-update mod-tidy |
| 24 |
|
| 25 |
################################################# |
| 26 |
# Test and linting |
| 27 |
################################################# |
| 28 |
# Run all the linters |
| 29 |
lint: |
| 30 |
bin/golangci-lint run ./... |
| 31 |
.PHONY: lint |
| 32 |
|
| 33 |
test: |
| 34 |
CGO_ENABLED=0 go test $$(go list ./... | grep -v generated) |
| 35 |
.PHONY: test |
| 36 |
|
| 37 |
COVER_TEST_PKGS:=$(shell find . -type f -name '*_test.go' | rev | cut -d "/" -f 2- | rev | grep -v generated | sort -u) |
| 38 |
$(COVER_TEST_PKGS:=-cover): %-cover: all-cover.txt |
| 39 |
@CGO_ENABLED=0 go test -v [email protected] -covermode=atomic ./$* |
| 40 |
@if [ -f [email protected] ]; then \ |
| 41 |
grep -v "mode: atomic" < [email protected] >> all-cover.txt; \ |
| 42 |
rm [email protected]; \ |
| 43 |
fi |
| 44 |
|
| 45 |
all-cover.txt: |
| 46 |
echo "mode: atomic" > all-cover.txt |
| 47 |
|
| 48 |
cover: all-cover.txt $(COVER_TEST_PKGS:=-cover) |
| 49 |
.PHONY: cover all-cover.txt |