This repository has been archived by the owner on Oct 16, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
104 lines (81 loc) · 2.63 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
SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
include $(SELF_DIR)/.ci/common.mk
SHELL=/bin/bash -o pipefail
html_report := coverage.html
test := .ci/test-cover.sh
test_ci_integration := .ci/test-integration.sh
convert-test-data := .ci/convert-test-data.sh
coverfile := cover.out
coverage_xml := coverage.xml
junit_xml := junit.xml
test_log := test.log
lint_check := .ci/lint.sh
metalint_check := .ci/metalint.sh
metalint_config := .metalinter.json
metalint_exclude := .excludemetalint
BUILD := $(abspath ./bin)
LINUX_AMD64_ENV := GOOS=linux GOARCH=amd64 CGO_ENABLED=0
VENDOR_ENV := GO15VENDOREXPERIMENT=1
SERVICES := \
m3nsch_server \
m3nsch_client \
.PHONY: setup
setup:
mkdir -p $(BUILD)
define SERVICE_RULES
.PHONY: $(SERVICE)
$(SERVICE): setup
@echo Building $(SERVICE)
$(VENDOR_ENV) go build -o $(BUILD)/$(SERVICE) ./$(SERVICE)/.
.PHONY: $(SERVICE)-linux-amd64
$(SERVICE)-linux-amd64:
$(LINUX_AMD64_ENV) make $(SERVICE)
endef
.PHONY: services
services: $(SERVICES)
.PHONY: services-linux-amd64
services-linux-amd64:
$(LINUX_AMD64_ENV) make services
$(foreach SERVICE,$(SERVICES),$(eval $(SERVICE_RULES)))
.PHONY: lint
lint:
@which golint > /dev/null || go get -u github.com/golang/lint/golint
$(VENDOR_ENV) $(lint_check)
.PHONY: metalint
metalint: install-metalinter
@($(metalint_check) $(metalint_config) $(metalint_exclude) && echo "metalinted successfully!") || (echo "metalinter failed" && exit 1)
.PHONY: test-internal
test-internal:
@which go-junit-report > /dev/null || go get -u github.com/sectioneight/go-junit-report
@$(VENDOR_ENV) $(test) $(coverfile) | tee $(test_log)
.PHONY: test-xml
test-xml: test-internal
go-junit-report < $(test_log) > $(junit_xml)
gocov convert $(coverfile) | gocov-xml > $(coverage_xml)
@$(convert-test-data) $(coverage_xml)
@rm $(coverfile) &> /dev/null
.PHONY: test
test: test-internal
gocov convert $(coverfile) | gocov report
.PHONY: testhtml
testhtml: test-internal
gocov convert $(coverfile) | gocov-html > $(html_report) && open $(html_report)
@rm -f $(test_log) &> /dev/null
.PHONY: test-ci-unit
test-ci-unit: test-internal
@which goveralls > /dev/null || go get -u -f github.com/mattn/goveralls
goveralls -coverprofile=$(coverfile) -service=travis-ci || echo -e "\x1b[31mCoveralls failed\x1b[m"
.PHONY: test-ci-integration
test-ci-integration:
@$(VENDOR_ENV) $(test_ci_integration)
.PHONY: clean
clean:
echo Cleaning build artifacts...
go clean
rm -rf $(BUILD)
@rm -f *.html *.xml *.out *.test
echo
.PHONY: all
all: lint metalint test-ci-unit services
@echo "Making all"
.DEFAULT_GOAL := all