-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
51 lines (40 loc) · 1.41 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
# env
export GO111MODULE=on
export CGO_ENABLED=0
# project metadta
NAME := pftaskqueue
REVISION := $(shell git rev-parse --short HEAD)
IMAGE_PREFIX ?= pftaskqueue/
LDFLAGS := -ldflags="-s -w -X github.com/pfnet-research/pftaskqueue/cmd.Version=dev -X github.com/pfnet-research/pftaskqueue/cmd.Revision=$(REVISION) -extldflags \"-static\""
OUTDIR ?= ./dist
.DEFAULT_GOAL := build
.PHONY: setup
setup:
npm install --prefix=.dev markdown-toc && \
cd $(shell go env GOPATH) && \
go install golang.org/x/tools/cmd/goimports@latest && \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.55.2 && \
go install github.com/elastic/go-licenser@latest
.PHONY: fmt
fmt: build-readme-toc
$(shell go env GOPATH)/bin/goimports -w cmd/ pkg/
$(shell go env GOPATH)/bin/go-licenser --licensor "Preferred Networks, Inc."
.PHONY: lint
lint: fmt
$(shell go env GOPATH)/bin/golangci-lint run --config .golangci.yml --deadline 30m
git diff --exit-code README.md
.PHONY: build-readme-toc
build-readme-toc:
.dev/node_modules/markdown-toc/cli.js -i README.md
.PHONY: build
build: fmt lint
go build -tags netgo -installsuffix netgo $(LDFLAGS) -o $(OUTDIR)/$(NAME) .
.PHONY: build-only
build-only:
go build -tags netgo -installsuffix netgo $(LDFLAGS) -o $(OUTDIR)/$(NAME) .
.PHONY: test
test:
go test ./...
.PHONY: clean
clean:
rm -rf "$(OUTDIR)"