-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (48 loc) · 1.5 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
54
55
56
57
58
59
60
TOPDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
BIN := gotemplate
PKG := github.com/i02sopop/$(BIN)
VERSION := $(shell git describe --tags --always --dirty)
BASEIMAGE := alpine
IMAGE := $(REGISTRY)/$(BIN):$(VERSION)
.PHONY: build
build: build-dirs
@GOARCH="${ARCH}" go build -ldflags "-X ${PKG}/pkg/version.VERSION=${VERSION}" -o $(TOPDIR)/bin/$(BIN) ./cmd/$(BIN)/...
DOTFILE_IMAGE = $(subst /,_,$(IMAGE))-$(VERSION)
.PHONY: container
container:
@sed \
-e 's|ARG_BIN|$(BIN)|g' \
-e 's|ARG_ARCH|$(ARCH)|g' \
-e 's|ARG_FROM|$(BASEIMAGE)|g' \
$(TOPDIR)/Dockerfile.in > $(TOPDIR)/.dockerfile-$(ARCH)
@docker build -t $(IMAGE):$(VERSION) -f $(TOPDIR)/.dockerfile-$(ARCH) .
@docker images -q $(IMAGE):$(VERSION) > $@
.PHONY: container-name
container-name:
@echo "container: $(IMAGE):$(VERSION)"
.PHONY: version
version:
@echo $(VERSION)
.PHONY: test
test: build-dirs
@go test -v ./... -race -coverprofile cover.out
@go tool cover -func "cover.out"
.PHONY: test-update
test-update:
@go test -v ./... -race -tags=update
.PHONY: lint
lint:
@golangci-lint run -c $(PWD)/.golangci.yaml
.PHONY: update-lint
update-lint:
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/local/bin
.PHONY: build-dirs
build-dirs:
@mkdir -p $(TOPDIR)/bin
.PHONY: clean
clean:
@rm -rf $(TOPDIR)/bin
@rm -fr $(TOPDIR)/cpu-*.log $(TOPDIR)/mem-*.log block-*.log $(TOPDIR)/gotemplate.test
.PHONY: run
run:
@bin/$(BIN) -alsologtostderr=true