-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
88 lines (67 loc) · 2.69 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
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
#! /usr/bin/make
CURRENT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
PROJECT_REPO := 'github.com/tinakurian'
PROJECT_NAME := 'build-tool-detector'
.DEFAULT_GOAL := all
all: clean install generate build test check
# Build configuration
BUILD_TIME=$(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
BINARY_DIR:=${PWD}/bin
BINARY:=build-tool-detector
GITUNTRACKEDCHANGES:=$(shell git status --porcelain --untracked-files=no)
ifneq ($(GITUNTRACKEDCHANGES),)
COMMIT := $(COMMIT)-dirty
endif
LDFLAGS="-X main.Commit=${COMMIT} -X main.BuildTime=${BUILD_TIME}"
LDFLAGS2="-X main.ghClientID=${ghClientID} -X main.ghClientSecret=${ghClientSecret}"
SOURCEDIR=.
SOURCES := $(shell find $(SOURCEDIR) -name '*.go')
build: clean generate $(BINARY) ## Compiles executable
$(BINARY): $(SOURCES)
@go build -ldflags ${LDFLAGS} -o ${BINARY_DIR}/${BINARY}
help: ## Hey! That's me!
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-10s\033[0m %s\n", $$1, $$2}'
.PHONY: install ## Fetches all dependencies using dep
install:
dep ensure -v
.PHONY: update ## Updates all dependencies defined for dep
update:
dep ensure -update -v
clean: ## Cleans up the project binaries and generated Goa files
@rm -rf app
@rm -rf client
@rm -rf tool
@rm -rf public/swagger
@rm -rf public/schema
@rm -rf public/js
if [ -f ${BINARY_DIR} ] ; then rm ${BINARY_DIR} ; fi
generate: clean ## (re)generates all goagen-generated files
@goagen controller -d $(PROJECT_REPO)/$(PROJECT_NAME)/design -o controllers
@goagen app -d $(PROJECT_REPO)/$(PROJECT_NAME)/design
@goagen swagger -d $(PROJECT_REPO)/$(PROJECT_NAME)/design
@goagen schema -d $(PROJECT_REPO)/$(PROJECT_NAME)/design -o public
@goagen client -d $(PROJECT_REPO)/$(PROJECT_NAME)/design
.PHONY: test
test: build ## Executes all tests
@ginkgo -r
.PHONY: format ## Removes unneeded imports and formats source code
format:
@goimports -l -w $(shell find . -type f -name '*.go' -not -path "./vendor/*")
.PHONY: check
check: ## Concurrently runs a whole bunch of static analysis tools
@gometalinter --enable=misspell --enable=gosimple --enable-gc --vendor --skip=app --skip=client --skip=tool --exclude ^app/test/ --deadline 300s ./...
.PHONY: run
run: ## runs the service locally
${BINARY_DIR}/${BINARY}
.PHONY: tools
tools: ## Installs all necessary tools
@echo "Installing gometalinter"
@go get -u github.com/alecthomas/gometalinter && gometalinter --install
@echo "Installing ginkgo"
@go get -u github.com/onsi/ginkgo/ginkgo
@echo "Installing gock"
@go get -u gopkg.in/h2non/gock.v1
@echo "Installing goimports"
@go get -u golang.org/x/tools/cmd/goimports
@echo "Installing goa"
@go get -u github.com/goadesign/goa/...