-
Notifications
You must be signed in to change notification settings - Fork 201
/
Makefile
57 lines (45 loc) · 1.58 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
############################# Main targets #############################
# Run all checks, build, and test.
install: clean staticcheck errcheck workflowcheck bins test
########################################################################
##### Variables ######
UNIT_TEST_DIRS := $(sort $(dir $(shell find . -name "*_test.go")))
MAIN_FILES := $(shell find . -name "main.go")
MOD_FILES_DIR := $(sort $(dir $(shell find . -name "go.mod")))
TEST_TIMEOUT := 20s
COLOR := "\e[1;36m%s\e[0m\n"
BIN_DIR := $(shell pwd)/bin
define NEWLINE
endef
##### Targets ######
bins:
@printf $(COLOR) "Build samples..."
$(foreach MAIN_FILE,$(MAIN_FILES), cd $(shell dirname "$(MAIN_FILE)") && go build -o $(BIN_DIR)/$(shell dirname "$(MAIN_FILE)") $(NEWLINE))
test:
@printf $(COLOR) "Run unit tests..."
@rm -f test.log
$(foreach UNIT_TEST_DIR,$(UNIT_TEST_DIRS),\
@go test -timeout $(TEST_TIMEOUT) -race $(UNIT_TEST_DIR) | tee -a test.log \
$(NEWLINE))
@! grep -q "^--- FAIL" test.log
staticcheck:
@printf $(COLOR) "Run static check..."
@go install honnef.co/go/tools/cmd/staticcheck@latest
@staticcheck ./...
errcheck:
@printf $(COLOR) "Run error check..."
@go install github.com/kisielk/errcheck@latest
@errcheck ./...
workflowcheck:
@printf $(COLOR) "Run workflow check..."
@go install go.temporal.io/sdk/contrib/tools/workflowcheck@latest
@workflowcheck -show-pos ./...
update-sdk:
$(foreach MOD_FILES_DIR,$(MOD_FILES_DIR),\
cd $(MOD_FILES_DIR) && \
go get -u go.temporal.io/sdk@latest && \
go mod tidy \
$(NEWLINE))
clean:
rm -rf bin
ci-build: staticcheck errcheck workflowcheck bins test