-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
92 lines (66 loc) · 1.97 KB
/
Makefile
File metadata and controls
92 lines (66 loc) · 1.97 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# PID = /tmp/awesome-golang-project.pid
# GO_FILES = $(wildcard *.go)
# APP = ./app
# serve: restart
# @fswatch -o . | xargs -n1 -I{} make restart || make kill
# kill:
# @kill `cat $(PID)` || true
# before:
# @echo "actually do nothing"
# $(APP): $(GO_FILES)
# @go build $? -o $@
# restart: kill before $(APP)
# @app & echo $$! > $(PID)
# .PHONY: serve restart kill before # let's go to reserve rules names
SHELL := /bin/bash
# The name of the executable (default is current directory name)
TARGET := $(shell echo $${PWD\#\#*/})
.DEFAULT_GOAL: $(TARGET)
# These will be provided to the target
VERSION := 1.0.0
BUILD := `git rev-parse HEAD`
# Use linker flags to provide version/build settings to the target
LDFLAGS=-ldflags "-X=main.Version=$(VERSION) -X=main.Build=$(BUILD)"
# go source files, ignore vendor directory
SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
.PHONY: all build clean install uninstall fmt simplify check run
all: check install
$(TARGET): $(SRC)
@go build $(LDFLAGS) -o $(TARGET)
init:
@glide install
@go get -u github.com/jteeuwen/go-bindata/...
@go get golang.org/x/tools/cmd/goimports
build: $(TARGET)
@true
clean:
@rm -f $(TARGET)
install:
@go install $(LDFLAGS)
uninstall: clean
@rm -f $$(which ${TARGET})
fmt:
@gofmt -l -w $(SRC)
simplify:
@gofmt -s -l -w $(SRC)
check:
@test -z $(shell gofmt -l main.go | tee /dev/stderr) || echo "[WARN] Fix formatting issues with 'make fmt'"
@for d in $$(go list ./... | grep -v /vendor/); do golint $${d}; done
@go tool vet ${SRC}
run: install
@$(TARGET)
dev:
fresh
test:
@go test -v ./...
gql:
@go run scripts/gqlgen.go
deploy:
@docker build -t gcr.io/nithi-project/gqlgen-clean-example-go .
@gcloud docker -- push gcr.io/nithi-project/gqlgen-clean-example-go
deploy-debug:
@docker build -t gcr.io/nithi-project/gqlgen-clean-example-go -f Dockerfile.debug .
@gcloud docker -- push gcr.io/nithi-project/gqlgen-clean-example-go
mock:
@sh script/mock.sh
gen: gql mock