-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
44 lines (33 loc) · 977 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
33
34
35
36
37
38
39
40
41
42
43
44
SHELL=bash
BUILD=build
BUILD_ARCH=$(BUILD)/$(GOOS)-$(GOARCH)
BIN_DIR?=.
export GOOS?=$(shell go env GOOS)
export GOARCH?=$(shell go env GOARCH)
BUILD_TIME=$(shell date +%s)
GIT_COMMIT=$(shell git rev-parse HEAD)
VERSION ?= $(shell git tag --points-at HEAD | grep ^v | head -n 1)
.PHONY: all
all: audit test build
.PHONY: lint
lint:
golangci-lint run ./...
.PHONY: audit
audit:
set -o pipefail; go list -m all | nancy sleuth
.PHONY: build
build:
@mkdir -p $(BUILD_ARCH)/$(BIN_DIR)
go build -o $(BUILD_ARCH)/$(BIN_DIR)/dp-api-router -ldflags="-X 'main.BuildTime=$(BUILD_TIME)' -X 'main.GitCommit=$(GIT_COMMIT)' -X 'main.Version=$(VERSION)'" main.go
.PHONY: test
test:
go test -count=1 -race -cover ./...
.PHONY: debug
debug:
HUMAN_LOG=1 go run -race -ldflags="-X 'main.BuildTime=$(BUILD_TIME)' -X 'main.GitCommit=$(GIT_COMMIT)' -X 'main.Version=$(VERSION)'" main.go
.PHONY: generate
generate:
go generate -v ./...
.PHONY: test-component
test-component:
exit 0