Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
htdvisser committed May 21, 2019
2 parents fc5709a + 78600a8 commit 60b8cc5
Show file tree
Hide file tree
Showing 51 changed files with 1,283 additions and 5,842 deletions.
19 changes: 5 additions & 14 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,18 @@ stages:
- package

variables:
GO111MODULE: 'on'
CONTAINER_NAME: thethingsnetwork/ttn
PLATFORMS: linux-386 linux-amd64 linux-arm darwin-amd64 windows-386 windows-amd64

cache:
key: "$CI_PROJECT_PATH"
paths:
- .govendor

before_script:
- mkdir -p $(pwd)/.govendor
- rm -rf $GOPATH
- mkdir -p $GOPATH/.cache && ln -s $(pwd)/.govendor $GOPATH/.cache/govendor
- mkdir -p $GOPATH/src/github.com/TheThingsNetwork && ln -s $(pwd) $GOPATH/src/github.com/TheThingsNetwork/ttn
- /go/pkg/mod

tests:
stage: test
image: golang:1.11
image: golang:1.12
services:
- thethingsnetwork/rabbitmq
- redis
Expand All @@ -30,23 +25,19 @@ tests:
MQTT_ADDRESS: thethingsnetwork__rabbitmq:1883
AMQP_ADDRESS: thethingsnetwork__rabbitmq:5672
script:
- pushd $GOPATH/src/github.com/TheThingsNetwork/ttn
- make deps
- make test
- popd

binaries:
stage: build
image: golang:1.11
image: golang:1.12
script:
- mkdir release
- export CI_BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
- echo "date $CI_BUILD_DATE" >> release/info
- echo "commit $CI_BUILD_REF" >> release/info
- pushd $GOPATH/src/github.com/TheThingsNetwork/ttn
- make deps
- for platform in $PLATFORMS; do $(echo $platform | awk -F '-' '{print "export GOOS=" $1 " GOARCH=" $2}') && make build; done
- popd
artifacts:
paths:
- release/
Expand All @@ -57,7 +48,7 @@ sign:
- master@thethingsnetwork/ttn
- develop@thethingsnetwork/ttn
stage: sign
image: golang:1.11
image: golang:1.12
script:
- pushd release
- shasum -a 256 $(ls) > checksums
Expand Down
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ services:
- docker

go:
- "1.11"
- "1.12.x"

env:
global:
- GOPROXY=https://proxy.golang.org
- GO111MODULE=on

cache:
directories:
- $HOME/gopath/pkg/mod

install:
- make deps
Expand Down
88 changes: 26 additions & 62 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ all: deps build
# Deps

build-deps:
@command -v govendor > /dev/null || go get "github.com/kardianos/govendor"

deps: build-deps
govendor sync -v
deps:
go mod download

dev-deps: deps
@command -v protoc-gen-grpc-gateway > /dev/null || go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
Expand All @@ -32,36 +31,6 @@ dev-deps: deps
@command -v golint > /dev/null || go get golang.org/x/lint/golint
@command -v forego > /dev/null || go get github.com/ddollar/forego

# Protobuf

PROTO_FILES = $(shell find api -name "*.proto" -and -not -name ".git")
COMPILED_PROTO_FILES = $(patsubst api%.proto, api%.pb.go, $(PROTO_FILES))
PROTOC_IMPORTS= -I/usr/local/include -I$(GO_PATH)/src -I$(PWD)/vendor -I$(PARENT_DIRECTORY) \
-I$(GO_PATH)/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis
PROTOC = protoc $(PROTOC_IMPORTS) \
--gogottn_out=plugins=grpc:$(GO_SRC) \
--grpc-gateway_out=:$(GO_SRC) `pwd`/

protos-clean:
rm -f $(COMPILED_PROTO_FILES)

protos: $(COMPILED_PROTO_FILES)

api/%.pb.go: api/%.proto
$(PROTOC)$<

protodoc: $(PROTO_FILES)
protoc $(PROTOC_IMPORTS) --ttndoc_out=logtostderr=true,.lorawan.DevAddrManager=all:$(GO_SRC) `pwd`/api/protocol/lorawan/device_address.proto
protoc $(PROTOC_IMPORTS) --ttndoc_out=logtostderr=true,.handler.ApplicationManager=all:$(GO_SRC) `pwd`/api/handler/handler.proto
protoc $(PROTOC_IMPORTS) --ttndoc_out=logtostderr=true,.discovery.Discovery=all:$(GO_SRC) `pwd`/api/discovery/discovery.proto

# Mocks

mocks:
mockgen -source=./api/protocol/lorawan/device.pb.go -package lorawan DeviceManagerClient > api/protocol/lorawan/device_mock.go
mockgen -source=./api/networkserver/networkserver.pb.go -package networkserver NetworkServerClient > api/networkserver/networkserver_mock.go
mockgen -source=./api/discovery/client.go -package discovery Client > api/discovery/client_mock.go

dev-certs:
ttn discovery gen-cert localhost 127.0.0.1 ::1 discovery --config ./.env/discovery/dev.yml
ttn router gen-cert localhost 127.0.0.1 ::1 router --config ./.env/router/dev.yml
Expand All @@ -72,44 +41,39 @@ dev-certs:
# Go Test

GO_FILES = $(shell find . -name "*.go" | grep -vE ".git|.env|vendor|.pb.go|_mock.go")
GO_PACKAGES = $(shell find . -name "*.go" | grep -vE ".git|.env|vendor" | sed 's:/[^/]*$$::' | sort | uniq)
GO_TEST_PACKAGES = $(shell find . -name "*_test.go" | grep -vE ".git|.env|vendor" | sed 's:/[^/]*$$::' | sort | uniq)
GO_COVER_PACKAGES = $(shell find . -name "*_test.go" | grep -vE ".git|.env|vendor|ttnctl|cmd|api" | sed 's:/[^/]*$$::' | sort | uniq)

GO_COVER_FILE ?= coverage.out
GO_COVER_DIR ?= .cover
GO_COVER_FILES = $(patsubst ./%, $(GO_COVER_DIR)/%.out, $(shell echo "$(GO_COVER_PACKAGES)"))
GO_COVER_FILES = `find . -name "coverage.out"`

test: $(GO_FILES)
go test $(GO_TEST_PACKAGES)
go test ./...
pushd api > /dev/null; go test ./...; popd > /dev/null
pushd core/types > /dev/null; go test ./...; popd > /dev/null
pushd mqtt > /dev/null; go test ./...; popd > /dev/null
pushd utils/errors > /dev/null; go test ./...; popd > /dev/null
pushd utils/random > /dev/null; go test ./...; popd > /dev/null
pushd utils/security > /dev/null; go test ./...; popd > /dev/null
pushd utils/testing > /dev/null; go test ./...; popd > /dev/null

cover-clean:
rm -rf $(GO_COVER_DIR) $(GO_COVER_FILE)
rm -f $(GO_COVER_FILES) coverage.out.merged

cover-deps:
@command -v goveralls > /dev/null || go get github.com/mattn/goveralls

cover: $(GO_COVER_FILE)

$(GO_COVER_FILE): cover-clean $(GO_COVER_FILES)
echo "mode: set" > $(GO_COVER_FILE)
cat $(GO_COVER_FILES) | grep -vE "mode: set|/server.go|/manager_server.go" | sort >> $(GO_COVER_FILE)

$(GO_COVER_DIR)/%.out: %
@mkdir -p "$(GO_COVER_DIR)/$<"
go test -cover -coverprofile="$@" "./$<"

coveralls: cover-deps $(GO_COVER_FILE)
goveralls -coverprofile=$(GO_COVER_FILE) -service=travis-ci -repotoken $$COVERALLS_TOKEN

fmt:
[[ -z "`echo "$(GO_PACKAGES)" | xargs go fmt | tee -a /dev/stderr`" ]]

vet:
echo $(GO_PACKAGES) | xargs go vet

lint:
for pkg in `echo $(GO_PACKAGES)`; do golint $$pkg | grep -vE 'mock|.pb.go'; done
cover: cover-clean $(GO_FILES)
go test -coverprofile=coverage.out ./...
pushd api > /dev/null; go test -coverprofile=coverage.out ./...; popd > /dev/null
pushd core/types > /dev/null; go test -coverprofile=coverage.out ./...; popd > /dev/null
pushd mqtt > /dev/null; go test -coverprofile=coverage.out ./...; popd > /dev/null
pushd utils/errors > /dev/null; go test -coverprofile=coverage.out ./...; popd > /dev/null
pushd utils/random > /dev/null; go test -coverprofile=coverage.out ./...; popd > /dev/null
pushd utils/security > /dev/null; go test -coverprofile=coverage.out ./...; popd > /dev/null
pushd utils/testing > /dev/null; go test -coverprofile=coverage.out ./...; popd > /dev/null
echo "mode: set" > coverage.out.merged
cat $(GO_COVER_FILES) | grep -vE "mode: set|/server.go|/manager_server.go" | sort > coverage.out.merged

coveralls: cover-deps cover
goveralls -coverprofile=coverage.out.merged -service=travis-ci -repotoken $$COVERALLS_TOKEN

# Go Build

Expand Down
20 changes: 20 additions & 0 deletions api/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module github.com/TheThingsNetwork/ttn/api

go 1.11

require (
github.com/StackExchange/wmi v0.0.0-20181212234831-e0a55b97c705 // indirect
github.com/TheThingsNetwork/api v0.0.0-20190516085542-c732802571cf
github.com/TheThingsNetwork/go-utils v0.0.0-20190516083235-bdd4967fab4e
github.com/TheThingsNetwork/ttn/utils/errors v0.0.0-20190516081709-034d40b328bd
github.com/apex/log v1.1.0
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/juju/ratelimit v1.0.1
github.com/mwitkow/go-grpc-middleware v1.0.0
github.com/shirou/gopsutil v2.18.12+incompatible
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3
golang.org/x/net v0.0.0-20190514140710-3ec191127204
google.golang.org/grpc v1.20.1
)
Loading

0 comments on commit 60b8cc5

Please sign in to comment.