-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
53 lines (41 loc) · 1.3 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
NAME=github.com/odpf/entropy
VERSION=$(shell git describe --tags --always --first-parent 2>/dev/null)
COMMIT=$(shell git rev-parse --short HEAD)
BUILD_TIME=$(shell date)
COVERAGE_DIR=coverage
BUILD_DIR=dist
EXE=entropy
.PHONY: all build clean tidy format test test-coverage
all: clean test build format lint
tidy:
@echo "Tidy up go.mod..."
@go mod tidy -v
install:
@echo "Installing Entropy to ${GOBIN}..."
@go install
format:
@echo "Running gofumpt..."
@gofumpt -l -w .
lint:
@echo "Running lint checks using golangci-lint..."
@golangci-lint run
clean: tidy
@echo "Cleaning up build directories..."
@rm -rf ${COVERAGE_DIR} ${BUILD_DIR}
@echo "Running go-generate..."
@go generate ./...
test: tidy
@mkdir -p ${COVERAGE_DIR}
@echo "Running unit tests..."
@go test ./... -coverprofile=${COVERAGE_DIR}/coverage.out
test-coverage: test
@echo "Generating coverage report..."
@go tool cover -html=${COVERAGE_DIR}/coverage.out
build: clean
@mkdir -p ${BUILD_DIR}
@echo "Running build for '${VERSION}' in '${BUILD_DIR}/'..."
@CGO_ENABLED=0 go build -ldflags '-X "${NAME}/pkg/version.Version=${VERSION}" -X "${NAME}/pkg/version.Commit=${COMMIT}" -X "${NAME}/pkg/version.BuildTime=${BUILD_TIME}"' -o ${BUILD_DIR}/${EXE}
download:
@go mod download
setup:
@go install github.com/vektra/mockery/[email protected]