This repository was archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
47 lines (41 loc) · 1.43 KB
/
Makefile
File metadata and controls
47 lines (41 loc) · 1.43 KB
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
quality: format lint sec tidy
# Run go mod tidy and check go.sum is unchanged
PHONY+= tidy
tidy:
@echo "🔘 Checking that go mod tidy does not make a change..."
@cp go.sum go.sum.bak
@go mod tidy
@diff go.sum go.sum.bak && rm go.sum.bak || (echo "🔴 go mod tidy would make a change, exiting"; exit 1)
@echo "✅ Checking go mod tidy complete"
# Format go code and error if any changes are made
PHONY+= format
format:
@echo "🔘 Checking that go fmt does not make any changes..."
@test -z $$(go fmt ./...) || (echo "🔴 go fmt would make a change, exiting"; exit 1)
@echo "✅ Checking go fmt complete"
PHONY+= lint
lint: $(GOPATH)/bin/golangci-lint
@echo "🔘 Linting $(1) (`date '+%H:%M:%S'`)"
@lint=`golint ./...`; \
if [ "$$lint" != "" ]; \
then echo "🔴 Lint found by golint"; echo "$$lint"; exit 1;\
fi
@lint=`go vet ./...`; \
if [ "$$lint" != "" ]; \
then echo "🔴 Lint found by go vet"; echo "$$lint"; exit 1;\
fi
@lint=`golangci-lint run`; \
if [ "$$lint" != "" ]; \
then echo "🔴 Lint found by golangci-lint"; echo "$$lint"; exit 1;\
fi
@echo "✅ Lint-free (`date '+%H:%M:%S'`)"
PHONY+= sec
sec: $(GOPATH)/bin/gosec
@echo "🔘 Checking for security problems ... (`date '+%H:%M:%S'`)"
@sec=`gosec -exclude-dir=testutils -quiet ./...`; \
if [ "$$sec" != "" ]; \
then echo "🔴 Problems found"; echo "$$sec"; exit 1;\
else echo "✅ No problems found (`date '+%H:%M:%S'`)"; \
fi
default: quality
.PHONY: $(PHONY)