-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·120 lines (101 loc) · 3.58 KB
/
Copy pathMakefile
File metadata and controls
executable file
·120 lines (101 loc) · 3.58 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
SHELL := /bin/bash
MAKEFLAGS := --silent
GO_VERSION := $(shell go version | cut -d' ' -f3 | cut -d. -f2)
GQLGEN_INSTALLED := $(shell command -v gqlgen 2> /dev/null)
# TODO Check out https://github.com/genuinetools/img/blob/master/Makefile to borrow some targets
## Default is to run this in development mode for testing the website
default: run
## Setup this directory for development use (pull latest code, ensure dependencies are updated)
setup-devl: pull dep
## Make sure we have the latest code
pull:
git pull
## Remove vendor'd libraries and all other generated artifacts
clean:
rm -f Gopkg.lock Gopkg.toml
rm -rf vendor
## See if 99designs' gqlgen is installed
check-gqlgen-installed:
ifndef GQLGEN_INSTALLED
echo "gqlgen command is not available, installing it now using 'go get github.com/99designs/gqlgen'"
go get github.com/99designs/gqlgen
endif
## Check all development dependencies
check-devl-dependencies: check-gqlgen-installed
## Initialize the development environment
init-devl: check-devl-dependencies
dep init
## Update all dependencies -- we've removed "[prune] unused-packages = true" from Gopkg.toml
dep:
dep ensure
dep ensure -update
## Generate the GraphQL models and resolvers in graph subpackage, using gqlgen.yml as spec
generate-graphql: check-gqlgen-installed
ifdef GQLGEN_INSTALLED
gqlgen
endif
## Generate all code (such as the GraphQL subpackage)
generate-all: generate-graphql
.ONESHELL:
## Run the daemon
run: generate-all
export JAEGER_SERVICE_NAME="Lectio Daemon"
export JAEGER_AGENT_HOST=yorktown
export JAEGER_REPORTER_LOG_SPANS=true
export JAEGER_SAMPLER_TYPE=const
export JAEGER_SAMPLER_PARAM=1
go run main.go
.ONESHELL:
## Run test suite
test: generate-all
export JAEGER_SERVICE_NAME="Lectio Daemon Test Suite"
export JAEGER_AGENT_HOST=yorktown
export JAEGER_REPORTER_LOG_SPANS=true
export JAEGER_SAMPLER_TYPE=const
export JAEGER_SAMPLER_PARAM=1
cd server && go test -v
## Check to see if gofmt is required for any files
fmt:
echo gofmt -l .
OUTPUT=`gofmt -l . 2>&1`; \
if [ "$$OUTPUT" ]; then \
echo "gofmt must be run on the following files:"; \
echo "$$OUTPUT"; \
exit 1; \
fi
## Run go-vet on the files in this project. Only run on go1.5+
vet:
go tool vet -atomic -bool -copylocks -nilfunc -printf -shadow -rangeloops -unreachable -unsafeptr -unusedresult .
## Run linter on the files in this project. Only run on go1.5+
# go get github.com/golang/lint/golint
# Capture output and force failure when there is non-empty output
# Only run on go1.5+
lint:
echo golint ./...
OUTPUT=`golint ./... 2>&1`; \
if [ "$$OUTPUT" ]; then \
echo "golint errors:"; \
echo "$$OUTPUT"; \
exit 1; \
fi
## Validate the files in this project (run fmt, vet, lint)
# TODO check out https://github.com/golangci/awesome-go-linters for more validators
validate: fmt vet lint
TARGET_MAX_CHAR_NUM=20
## All targets should have a ## Help text above the target and they'll be automatically collected
## Show help, using auto generator from https://gist.github.com/prwhite/8168133
help:
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)