test: build example in jenkins

Add command for generating coverage
This commit is contained in:
Anthony Laibe 2021-11-01 17:23:00 +01:00
parent 268767262b
commit 94e8b9cf86
6 changed files with 37 additions and 9 deletions

5
.gitignore vendored
View File

@ -8,11 +8,16 @@ nodekey
*.so *.so
*.dylib *.dylib
# output binaries
main
go-waku
# Test binary, built with `go test -c` # Test binary, built with `go test -c`
*.test *.test
# Output of the go coverage tool, specifically when used with LiteIDE # Output of the go coverage tool, specifically when used with LiteIDE
*.out *.out
coverage.html
# Dependency directories (remove the comment below to include it) # Dependency directories (remove the comment below to include it)
# vendor/ # vendor/

View File

@ -1,4 +1,4 @@
.PHONY: all build lint test .PHONY: all build lint test coverage build-example
all: build all: build
@ -24,9 +24,28 @@ test:
generate: generate:
go generate ./waku/v2/protocol/pb/generate.go go generate ./waku/v2/protocol/pb/generate.go
coverage:
go test -count 1 -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o=coverage.html
# build a docker image for the fleet # build a docker image for the fleet
docker-image: DOCKER_IMAGE_TAG ?= latest docker-image: DOCKER_IMAGE_TAG ?= latest
docker-image: DOCKER_IMAGE_NAME ?= statusteam/go-waku:$(DOCKER_IMAGE_TAG) docker-image: DOCKER_IMAGE_NAME ?= statusteam/go-waku:$(DOCKER_IMAGE_TAG)
docker-image: docker-image:
docker build --tag $(DOCKER_IMAGE_NAME) \ docker build --tag $(DOCKER_IMAGE_NAME) \
--build-arg="GIT_COMMIT=$(shell git rev-parse HEAD)" . --build-arg="GIT_COMMIT=$(shell git rev-parse HEAD)" .
build-example-basic2:
go build examples/basic2/main.go
build-example-chat-2:
# TODO: require UI + Chat which are gone
# go build examples/chat2/main.go
build-example-filter2:
go build examples/filter2/main.go
build-example-peer-events:
go build examples/peer_events/main.go
build-example: build-example-basic2 build-example-chat-2 build-example-filter2 build-example-peer-events

4
ci/Jenkinsfile vendored
View File

@ -28,6 +28,10 @@ pipeline {
stage('Test') { stage('Test') {
steps { sh 'make test' } steps { sh 'make test' }
} }
stage('Build example') {
steps { sh 'make build-example' }
}
} }
post { post {
always { cleanWs() } always { cleanWs() }

View File

@ -40,7 +40,7 @@ func main() {
wakuNode, err := node.New(ctx, wakuNode, err := node.New(ctx,
node.WithPrivateKey(prvKey), node.WithPrivateKey(prvKey),
node.WithHostAddress([]net.Addr{hostAddr}), node.WithHostAddress([]*net.TCPAddr{hostAddr}),
node.WithWakuRelay(), node.WithWakuRelay(),
) )
if err != nil { if err != nil {
@ -93,7 +93,7 @@ func write(ctx context.Context, wakuNode *node.WakuNode, msgContent string) {
Timestamp: timestamp, Timestamp: timestamp,
} }
_, err = wakuNode.Publish(ctx, msg, nil) _, err = wakuNode.Relay().Publish(ctx, msg, nil)
if err != nil { if err != nil {
log.Error("Error sending a message: ", err) log.Error("Error sending a message: ", err)
} }
@ -107,7 +107,7 @@ func writeLoop(ctx context.Context, wakuNode *node.WakuNode) {
} }
func readLoop(ctx context.Context, wakuNode *node.WakuNode) { func readLoop(ctx context.Context, wakuNode *node.WakuNode) {
sub, err := wakuNode.Subscribe(ctx, nil) sub, err := wakuNode.Relay().Subscribe(ctx, nil)
if err != nil { if err != nil {
log.Error("Could not subscribe: ", err) log.Error("Could not subscribe: ", err)
return return

View File

@ -146,7 +146,7 @@ func write(ctx context.Context, wakuNode *node.WakuNode, msgContent string) {
Timestamp: timestamp, Timestamp: timestamp,
} }
_, err := wakuNode.Publish(ctx, msg, nil) _, err := wakuNode.Relay().Publish(ctx, msg, nil)
if err != nil { if err != nil {
log.Error("Error sending a message: ", err) log.Error("Error sending a message: ", err)
} }
@ -160,7 +160,7 @@ func writeLoop(ctx context.Context, wakuNode *node.WakuNode) {
} }
func readLoop(ctx context.Context, wakuNode *node.WakuNode) { func readLoop(ctx context.Context, wakuNode *node.WakuNode) {
sub, err := wakuNode.Subscribe(ctx, &pubSubTopic) sub, err := wakuNode.Relay().Subscribe(ctx, &pubSubTopic)
if err != nil { if err != nil {
log.Error("Could not subscribe: ", err) log.Error("Could not subscribe: ", err)
return return

View File

@ -62,7 +62,7 @@ func main() {
log.Info("### create relayNode1") log.Info("### create relayNode1")
relayNode1, err := node.New(ctx, relayNode1, err := node.New(ctx,
node.WithPrivateKey(addrsAndKeys[0].key), node.WithPrivateKey(addrsAndKeys[0].key),
node.WithHostAddress([]net.Addr{addrsAndKeys[0].addr}), node.WithHostAddress([]*net.TCPAddr{addrsAndKeys[0].addr}),
node.WithWakuRelay(), node.WithWakuRelay(),
//node.WithConnStatusChan(connStatusChan), //node.WithConnStatusChan(connStatusChan),
node.WithWakuStore(true, false), node.WithWakuStore(true, false),
@ -198,7 +198,7 @@ func write(ctx context.Context, wakuNode *node.WakuNode, msgContent string) {
Timestamp: timestamp, Timestamp: timestamp,
} }
_, err = wakuNode.Publish(ctx, msg, nil) _, err = wakuNode.Relay().Publish(ctx, msg, nil)
if err != nil { if err != nil {
log.Error("Error sending a message: ", err) log.Error("Error sending a message: ", err)
} }
@ -213,7 +213,7 @@ func writeLoop(ctx context.Context, wakuNode *node.WakuNode) {
} }
func readLoop(ctx context.Context, wakuNode *node.WakuNode) { func readLoop(ctx context.Context, wakuNode *node.WakuNode) {
sub, err := wakuNode.Subscribe(ctx, &pubSubTopic) sub, err := wakuNode.Relay().Subscribe(ctx, &pubSubTopic)
if err != nil { if err != nil {
log.Error("Could not subscribe: ", err) log.Error("Could not subscribe: ", err)
return return