-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathMakefile
More file actions
36 lines (29 loc) · 976 Bytes
/
Makefile
File metadata and controls
36 lines (29 loc) · 976 Bytes
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
MINIMUM_COVERAGE=80
MAXIMUM_COMPLEXITY=15
GO_VER?=latest
DOCKER:=$(shell if which podman >/dev/null; then echo podman; else echo docker; fi)
ifeq ($(CI),true)
RUN:=$(DOCKER) run --rm -w $(CURDIR) -v $(CURDIR):$(CURDIR) gotools:$(GO_VER)
else
RUN:=$(DOCKER) run --rm -w $(CURDIR) -v $(CURDIR):$(CURDIR):Z gotools:$(GO_VER)
endif
COV=/tmp/test.out
.PHONY: all
all: gotools
$(RUN) /usr/bin/make all-go
all-go: test lint
lint:
go vet ./...
go list ./... | xargs -L1 golint -set_exit_status
staticcheck ./...
gosec ./...
#govulncheck ./...
osv-scanner .
gocyclo -over $(MAXIMUM_COMPLEXITY) ./
@if [ `go tool cover -func=$(COV) | tail -n1 | rev | cut -f1 | rev | cut -d. -f1` -lt $(MINIMUM_COVERAGE) ]; then echo "Error: Coverage too low."; false; fi
test:
go test -race -coverprofile=$(COV) ./...
.PHONY: gotools
gotools:
$(DOCKER) pull docker.io/library/golang:$(GO_VER) || true # Try to use the latest of the desired Go version
$(DOCKER) build . --tag gotools