-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
63 lines (47 loc) · 1.57 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
61
62
63
BIN="./bin"
SRC=$(shell find . -name "*.go")
ifeq (, $(shell which golangci-lint))
$(warning "could not find golangci-lint in $(PATH), run: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh")
endif
ifeq (, $(shell which richgo))
$(warning "could not find richgo in $(PATH), run: go get github.com/kyoh86/richgo")
endif
BUILD = build
BINARY = chipku
LDFLAGS = "-s -w"
.PHONY: fmt lint test install_deps clean run
default: all
all: fmt test
fmt:
$(info **************** checking formatting **************)
@test -z $(shell gofmt -l $(SRC)) || (gofmt -d $(SRC); exit 1)
lint:
$(info **************** running lint tools ***************)
golangci-lint run -v
richtest: install_deps
$(info **************** running tests - rich ***********)
richgo test -v ./...
test: install_deps
$(info **************** running tests ********************)
go test -v ./...
install_deps:
$(info **************** downloading dependencies *********)
go get -v ./...
build: clean
$(info **************** building binaries ****************)
mkdir $(BUILD)
go build -v -ldflags=$(LDFLAGS) -o $(BUILD)/$(BINARY)
build-race: clean
$(info **************** building binaries ****************)
mkdir $(BUILD)
go build -v -race -ldflags=$(LDFLAGS) -o $(BUILD)/$(BINARY)-race
clean:
$(info **************** house keeping ********************)
rm -rf $(BIN)
rm -rf $(BUILD)
up:
$(info **************** docker build + up ****************)
docker-compose up --build --remove-orphans --detach
run:
$(info **************** run *****************************)
go run . serve