forked from ligato/bgp-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
105 lines (88 loc) · 2.79 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
include Makeroutines.mk
COVER_DIR=/tmp/
# run all tests with coverage
define test_cover_only
@echo "# running unit tests with coverage analysis"
@go test -covermode=count -coverprofile=${COVER_DIR}coverage_unit1.out ./bgp
@go test -covermode=count -coverprofile=${COVER_DIR}coverage_unit2.out ./bgp/gobgp
@echo "# merging coverage results"
@gocovmerge ${COVER_DIR}coverage_unit1.out ${COVER_DIR}coverage_unit2.out > ${COVER_DIR}coverage.out
@echo "# coverage data generated into ${COVER_DIR}coverage.out"
@echo "# done"
endef
# verify that links in markdown files are valid
# requires npm install -g markdown-link-check
define check_links_only
@echo "# checking links"
@./scripts/check_links.sh
@echo "# done"
endef
# build all binaries
build:
@echo "# building"
@go build -a ./bgp/...
@echo "# done"
# get required tools
get-tools:
@go get -u -f "github.com/alecthomas/gometalinter"
@gometalinter --install
@go get -u -f "github.com/wadey/gocovmerge"
# install dependencies
install-dep:
@echo "# install dependencies"
$(call install_dependencies)
$(fix_sirupsen_case_sensitivity_problem)
# update dependencies
update-dep:
@echo "# update dependencies"
$(call update_dependencies)
$(fix_sirupsen_case_sensitivity_problem)
# run checkstyle
checkstyle:
@echo "# running code analysis"
@gometalinter --vendor --exclude=vendor --deadline 1m --enable-gc --disable=aligncheck --disable=gotype --disable=gotypex --exclude=mock ./...
@echo "# done"
check_links:
$(call check_links_only)
# run all tests
test:
@echo "# running unit tests"
@go test $$(go list ./... | grep -v /vendor/)
# run tests with coverage report
test-cover:
$(call test_cover_only)
# get coverage percentage in console(without report)
test-cover-without-report:
@echo "# getting test coverage"
@go test -cover $$(go list ./... | grep -v /vendor/)
# build examples
build-examples:
@echo "# building plugin examples"
@cd examples/gobgp_watch_plugin && go build
# run examples
run-examples:
@make build-examples
@echo "# running examples"
@./scripts/run_gobgp_watcher_examples.sh
@echo "# done"
# run checkstyle
clean:
@echo "# cleaning"
@rm -f examples/gobgp_watch_plugin/gobgp_watch_plugin
@rm -f docker/gobgp_route_reflector/gobgp-client-in-host/gobgp-client-in-host
@rm -f docker/gobgp_route_reflector/usage_scripts/gobgp-client-in-host/log
@rm -f log
@echo "# done"
#run all
all:
@echo "# running all"
@make get-tools
@make install-dep
@make update-dep
@make checkstyle
@make build
@make test-cover
@make build-examples
@make run-examples
@make clean
.PHONY: build get-tools install-dep update-dep checkstyle test test-cover test-cover-without-report build-examples run-examples clean all check_links