@@ -19,10 +19,9 @@ all: deps build
1919# Deps
2020
2121build-deps :
22- @command -v govendor > /dev/null || go get " github.com/kardianos/govendor"
2322
24- deps : build-deps
25- govendor sync -v
23+ deps :
24+ go mod download
2625
2726dev-deps : deps
2827 @command -v protoc-gen-grpc-gateway > /dev/null || go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
@@ -32,36 +31,6 @@ dev-deps: deps
3231 @command -v golint > /dev/null || go get golang.org/x/lint/golint
3332 @command -v forego > /dev/null || go get github.com/ddollar/forego
3433
35- # Protobuf
36-
37- PROTO_FILES = $(shell find api -name "* .proto" -and -not -name ".git")
38- COMPILED_PROTO_FILES = $(patsubst api% .proto, api% .pb.go, $(PROTO_FILES ) )
39- PROTOC_IMPORTS = -I/usr/local/include -I$(GO_PATH ) /src -I$(PWD ) /vendor -I$(PARENT_DIRECTORY ) \
40- -I$(GO_PATH ) /src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis
41- PROTOC = protoc $(PROTOC_IMPORTS ) \
42- --gogottn_out=plugins=grpc:$(GO_SRC ) \
43- --grpc-gateway_out=:$(GO_SRC ) ` pwd ` /
44-
45- protos-clean :
46- rm -f $(COMPILED_PROTO_FILES )
47-
48- protos : $(COMPILED_PROTO_FILES )
49-
50- api/% .pb.go : api/% .proto
51- $(PROTOC ) $<
52-
53- protodoc : $(PROTO_FILES )
54- protoc $(PROTOC_IMPORTS ) --ttndoc_out=logtostderr=true,.lorawan.DevAddrManager=all:$(GO_SRC ) ` pwd` /api/protocol/lorawan/device_address.proto
55- protoc $(PROTOC_IMPORTS ) --ttndoc_out=logtostderr=true,.handler.ApplicationManager=all:$(GO_SRC ) ` pwd` /api/handler/handler.proto
56- protoc $(PROTOC_IMPORTS ) --ttndoc_out=logtostderr=true,.discovery.Discovery=all:$(GO_SRC ) ` pwd` /api/discovery/discovery.proto
57-
58- # Mocks
59-
60- mocks :
61- mockgen -source=./api/protocol/lorawan/device.pb.go -package lorawan DeviceManagerClient > api/protocol/lorawan/device_mock.go
62- mockgen -source=./api/networkserver/networkserver.pb.go -package networkserver NetworkServerClient > api/networkserver/networkserver_mock.go
63- mockgen -source=./api/discovery/client.go -package discovery Client > api/discovery/client_mock.go
64-
6534dev-certs :
6635 ttn discovery gen-cert localhost 127.0.0.1 ::1 discovery --config ./.env/discovery/dev.yml
6736 ttn router gen-cert localhost 127.0.0.1 ::1 router --config ./.env/router/dev.yml
@@ -72,44 +41,39 @@ dev-certs:
7241# Go Test
7342
7443GO_FILES = $(shell find . -name "* .go" | grep -vE ".git|.env|vendor|.pb.go|_mock.go")
75- GO_PACKAGES = $(shell find . -name "* .go" | grep -vE ".git|.env|vendor" | sed 's:/[^/]* $$::' | sort | uniq)
76- GO_TEST_PACKAGES = $(shell find . -name "* _test.go" | grep -vE ".git|.env|vendor" | sed 's:/[^/]* $$::' | sort | uniq)
77- GO_COVER_PACKAGES = $(shell find . -name "* _test.go" | grep -vE ".git|.env|vendor|ttnctl|cmd|api" | sed 's:/[^/]* $$::' | sort | uniq)
7844
79- GO_COVER_FILE ?= coverage.out
80- GO_COVER_DIR ?= .cover
81- GO_COVER_FILES = $(patsubst ./% , $(GO_COVER_DIR ) /% .out, $(shell echo "$(GO_COVER_PACKAGES ) ") )
45+ GO_COVER_FILES = ` find . -name " coverage.out" `
8246
8347test : $(GO_FILES )
84- go test $(GO_TEST_PACKAGES )
48+ go test ./...
49+ pushd api > /dev/null; go test ./...; popd > /dev/null
50+ pushd core/types > /dev/null; go test ./...; popd > /dev/null
51+ pushd mqtt > /dev/null; go test ./...; popd > /dev/null
52+ pushd utils/errors > /dev/null; go test ./...; popd > /dev/null
53+ pushd utils/random > /dev/null; go test ./...; popd > /dev/null
54+ pushd utils/security > /dev/null; go test ./...; popd > /dev/null
55+ pushd utils/testing > /dev/null; go test ./...; popd > /dev/null
8556
8657cover-clean :
87- rm -rf $(GO_COVER_DIR ) $( GO_COVER_FILE )
58+ rm -f $(GO_COVER_FILES ) coverage.out.merged
8859
8960cover-deps :
9061 @command -v goveralls > /dev/null || go get github.com/mattn/goveralls
9162
92- cover : $(GO_COVER_FILE )
93-
94- $(GO_COVER_FILE ) : cover-clean $(GO_COVER_FILES )
95- echo " mode: set" > $(GO_COVER_FILE )
96- cat $(GO_COVER_FILES ) | grep -vE " mode: set|/server.go|/manager_server.go" | sort >> $(GO_COVER_FILE )
97-
98- $(GO_COVER_DIR ) /% .out : %
99- @mkdir -p " $( GO_COVER_DIR) /$<"
100- go test -cover -coverprofile=" $@ " " ./$<"
101-
102- coveralls : cover-deps $(GO_COVER_FILE )
103- goveralls -coverprofile=$(GO_COVER_FILE ) -service=travis-ci -repotoken $$ COVERALLS_TOKEN
104-
105- fmt :
106- [[ -z " ` echo " $( GO_PACKAGES) " | xargs go fmt | tee -a /dev/stderr` " ]]
107-
108- vet :
109- echo $(GO_PACKAGES ) | xargs go vet
110-
111- lint :
112- for pkg in ` echo $( GO_PACKAGES) ` ; do golint $$ pkg | grep -vE ' mock|.pb.go' ; done
63+ cover : cover-clean $(GO_FILES )
64+ go test -coverprofile=coverage.out ./...
65+ pushd api > /dev/null; go test -coverprofile=coverage.out ./...; popd > /dev/null
66+ pushd core/types > /dev/null; go test -coverprofile=coverage.out ./...; popd > /dev/null
67+ pushd mqtt > /dev/null; go test -coverprofile=coverage.out ./...; popd > /dev/null
68+ pushd utils/errors > /dev/null; go test -coverprofile=coverage.out ./...; popd > /dev/null
69+ pushd utils/random > /dev/null; go test -coverprofile=coverage.out ./...; popd > /dev/null
70+ pushd utils/security > /dev/null; go test -coverprofile=coverage.out ./...; popd > /dev/null
71+ pushd utils/testing > /dev/null; go test -coverprofile=coverage.out ./...; popd > /dev/null
72+ echo " mode: set" > coverage.out.merged
73+ cat $(GO_COVER_FILES ) | grep -vE " mode: set|/server.go|/manager_server.go" | sort > coverage.out.merged
74+
75+ coveralls : cover-deps cover
76+ goveralls -coverprofile=coverage.out.merged -service=travis-ci -repotoken $$ COVERALLS_TOKEN
11377
11478# Go Build
11579
0 commit comments