-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
45 lines (35 loc) · 1.33 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
PKG_DIR := "./pkg"
TEST_DIR := "./internal"
OUTPUT_CLIENT := "${PKG_DIR}/client"
OUTPUT_MODELS := "${PKG_DIR}/models"
# ====================================================================================
# Colors
RED := $(shell printf "\033[31m")
GREEN := $(shell printf "\033[32m")
BLUE := $(shell printf "\033[34m")
CNone := $(shell printf "\033[0m")
# ====================================================================================
# Logger
TIME_SHORT = `date +%H:%M:%S`
TIME = $(TIME_SHORT)
INFO = echo ${TIME} ${BLUE}[ .. ]${CNone}
OK = echo ${TIME} ${GREEN}[ OK ]${CNone}
FAIL = (echo ${TIME} ${RED}[FAIL]${CNone} && false)
# ====================================================================================
# Targets
clean:
@$(INFO) Removing generated client
-@rm -rf pkg/models pkg/client
@$(OK) Removed generated client
generate:
@$(INFO) Generating go resources
@go generate ${PKG_DIR} || $(FAIL)
@$(OK) Successfully generated go resources
test:
@$(INFO) go test unit-tests
@CGO_ENABLED=0 go test ${TEST_DIR} || $(FAIL)
@$(OK) go test unit-tests
# ensure generate target doesn't create a diff
check-diff: clean generate
@$(INFO) checking that branch is clean
@if git status --porcelain | grep . ; then $(FAIL); else $(OK) branch is clean; fi