-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
32 lines (23 loc) · 953 Bytes
/
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
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
BIN_DIR := $(abspath $(ROOT_DIR)/bin)
IMG ?= audit-scanner:latest
GOLANGCI_LINT_VER := v1.60.1
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $(BIN_DIR)/$(GOLANGCI_LINT_BIN)
all: build
$(GOLANGCI_LINT): ## Install golangci-lint.
GOBIN=$(BIN_DIR) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VER)
fmt: ## Run go fmt against code.
go fmt ./...
vet: ## Run go vet against code.
go vet -tags=testing ./...
lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run
.PHONY: unit-tests
unit-tests: fmt vet ## Run unit tests.
go test ./... -tags=testing -race -test.v -coverprofile=coverage/unit-tests/coverage.txt -covermode=atomic
build: fmt vet lint ## Build audit-scanner binary.
CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o bin/audit-scanner .
.PHONY: docker-build
docker-build: unit-tests
DOCKER_BUILDKIT=1 docker build -t ${IMG} .