-
Notifications
You must be signed in to change notification settings - Fork 10
/
makefile
59 lines (44 loc) · 1.92 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
GIT_COMMIT=$(shell git describe --always --long --dirty)
GOLANGCI_LINT_VERSION?=v1.47.3
TEST_TIMEOUT?=15m
default: fmt build
all: fmt imports build
tools:
@echo "==> installing required tooling..."
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
sh -s -- -b $(shell go env GOPATH)/bin ${GOLANGCI_LINT_VERSION}
fmt:
@echo "==> Fixing source code with gofmt..."
find . -name '*.go' | grep -v vendor | xargs gofmt -s -w
fumpt:
@echo "==> Fixing source code with Gofumpt..."
# This logic should match the search logic in scripts/gofmtcheck.sh
find . -name '*.go' | grep -v vendor | xargs gofumpt -s -w
imports:
@echo "==> Fixing imports code with goimports..."
goimports -w .
test: build
go test ./... -timeout ${TEST_TIMEOUT}
build:
@echo "==> building..."
go build -ldflags "-X github.com/katbyte/tctest/lib/version.GitCommit=${GIT_COMMIT}"
goimports:
@echo "==> Fixing imports code with goimports..."
@find . -name '*.go' | grep -v vendor | grep -v generator-resource-id | while read f; do ./scripts/goimport-file.sh "$$f"; done
lint:
@echo "==> Checking source code against linters..."
golangci-lint run ./...
depscheck:
@echo "==> Checking source code with go mod tidy..."
@go mod tidy
@git diff --exit-code -- go.mod go.sum || \
(echo; echo "Unexpected difference in go.mod/go.sum files. Run 'go mod tidy' command or revert any go.mod/go.sum changes and commit."; exit 1)
@echo "==> Checking source code with go mod vendor..."
@go mod vendor
@git diff --compact-summary --exit-code -- vendor || \
(echo; echo "Unexpected difference in vendor/ directory. Run 'go mod vendor' command or revert any go.mod/go.sum/vendor changes and commit."; exit 1)
install:
@echo "==> installing..."
go install -ldflags "-X github.com/katbyte/tctest/lib/version.GitCommit=${GIT_COMMIT}" .
check-all: build test lint depscheck
.PHONY: fmt imports build lint depscheck check-all install tools