-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
40 lines (34 loc) · 1.13 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
export PATH := $(abspath ./vendor/bin):$(PATH)
BASE_PACKAGE_NAME = github.com/omegion/db-backup
GIT_VERSION = $(shell git describe --tags --always 2> /dev/null || echo 0.0.0)
LDFLAGS = -ldflags "-buildid=$(GIT_VERSION)"
BUFFER := $(shell mktemp)
REPORT_DIR = dist/report
COVER_PROFILE = $(REPORT_DIR)/coverage.out
TARGETOS = darwin
TARGETARCH = amd64
BINARY_NAME = dist/db-backup
.PHONY: build
build:
CGO_ENABLED=0 GOOS="$(TARGETOS)" GOARCH="$(TARGETARCH)" go build $(LDFLAGS) -a -installsuffix cgo -o $(BINARY_NAME) main.go
.PHONY: lint
lint:
@echo "Checking code style"
gofmt -l . | tee $(BUFFER)
@! test -s $(BUFFER)
go vet ./...
# golangci-lint
go install github.com/golangci/golangci-lint/cmd/[email protected]
@golangci-lint --version
golangci-lint run
.PHONY: test
test:
@echo "Running unit tests"
mkdir -p $(REPORT_DIR)
go test -covermode=count -coverprofile=$(COVER_PROFILE) -tags test -failfast ./...
go tool cover -html=$(COVER_PROFILE) -o $(REPORT_DIR)/coverage.html
.PHONY: cut-tag
cut-tag:
@echo "Cutting $(version)"
git tag $(version)
git push origin $(version)