Commit 252d84df authored by Loïck Bonniot's avatar Loïck Bonniot

[d] Update build instructions for demonstrator

parent edd6dce5
Pipeline #415 passed with stage
......@@ -22,7 +22,7 @@ Unit tests:
script:
- "ln -s $(pwd) $GOPATH/src/dfss"
- "./build/deps.sh"
- "cd $GOPATH/src/dfss && rm -rf gui && go install ./..."
- "cd $GOPATH/src/dfss && make install"
- "go test -coverprofile auth.part -v dfss/auth"
- "go test -coverprofile mgdb.part -v dfss/mgdb"
- "go test -coverprofile mails.part -v dfss/mails"
......@@ -32,7 +32,6 @@ Unit tests:
- "go test -coverprofile dfssp_contract.part -v dfss/dfssp/contract"
- "go test -coverprofile dfssp_templates.part -v dfss/dfssp/templates"
- "go test -coverprofile dfssp_common.part -v dfss/dfssp/common"
- "go test -coverprofile dfssd.part -v dfss/dfssd"
- "go test -coverprofile dfssc_common.part -v dfss/dfssc/common"
- "go test -coverprofile dfssc_security.part -v dfss/dfssc/security"
- "go test -coverprofile dfssc_user.part -v dfss/dfssc/user"
......@@ -53,7 +52,7 @@ Integration tests:
script:
- "ln -s -f $(pwd) $GOPATH/src/dfss"
- "./build/deps.sh"
- "cd $GOPATH/src/dfss && rm -rf gui && go install ./..."
- "cd $GOPATH/src/dfss && make install"
- "go test -v dfss/tests"
Code lint:
......@@ -68,9 +67,9 @@ Code lint:
- "ln -s $(pwd) $GOPATH/src/dfss"
- "go get github.com/alecthomas/gometalinter"
- "./build/deps.sh"
- "cd $GOPATH/src/dfss && rm -rf gui && go install ./..."
- "cd $GOPATH/src/dfss && make install"
- "gometalinter --install"
- "gometalinter -t --deadline=600s -j1 --skip=api --skip=fixtures --disable=aligncheck ./..."
- "gometalinter -t --deadline=600s -j1 --skip=api --skip=fixtures --skip=gui --skip=dfssd --disable=aligncheck ./..."
Deploy:
stage: deploy
......
......@@ -7,19 +7,12 @@ endif
.PHONY:
install: nocache
go install .
go install ./dfssc
go install ./dfssd
go install ./dfssp
go install ./dfsst
release: clean build_all package
clean:
rm -rf release
# GUI Build (Docker required)
# prepare_gui builds a new container from the goqt image, adding DFSS dependencies for faster builds.
# call it once or after dependency addition.
prepare_gui: nocache
......@@ -35,11 +28,24 @@ gui: nocache
docker run --rm -v ${PWD}:/go/src/dfss -w /go/src/dfss/gui dfss:builder \
go build -ldflags "-r ." -o ../bin/gui
# Release internals
# dfssd builds the demonstrator into a docker container, outputing the result in bin/ directory
dfssd: nocache
docker run --rm -v ${PWD}:/go/src/dfss -w /go/src/dfss/dfssd/gui dfss:builder \
../../bin/goqt_rcc -go gui -o application.qrc.go application.qrc
docker run --rm -v ${PWD}:/go/src/dfss -w /go/src/dfss/dfssd dfss:builder \
go build -ldflags "-r ." -o ../bin/dfssd
protobuf:
cd .. && \
protoc --go_out=plugins=grpc:. dfss/dfssc/api/client.proto && \
protoc --go_out=plugins=grpc:. dfss/dfssd/api/demonstrator.proto && \
protoc --go_out=plugins=grpc:. dfss/dfssp/api/platform.proto && \
protoc --go_out=plugins=grpc:. dfss/dfsst/api/resolution.proto
# Release internals
build_all:
go get github.com/mitchellh/gox
gox -os "linux darwin windows" -parallel 1 -output "release/dfss_${VERSION}_{{.OS}}_{{.Arch}}/{{.Dir}}" dfss/dfssc dfss/dfssd dfss/dfssp dfss/dfsst
gox -os "linux darwin windows" -parallel 1 -output "release/dfss_${VERSION}_{{.OS}}_{{.Arch}}/{{.Dir}}" dfss/dfssc dfss/dfssp dfss/dfsst
package:
echo "$(VERSION) $(REVISION)" > build/embed/VERSION
......@@ -50,11 +56,7 @@ deploy:
mkdir -p /deploy/$(VERSION)
cp release/*.tar.gz /deploy/$(VERSION)/
protobuf:
cd .. && \
protoc --go_out=plugins=grpc:. dfss/dfssc/api/client.proto && \
protoc --go_out=plugins=grpc:. dfss/dfssd/api/demonstrator.proto && \
protoc --go_out=plugins=grpc:. dfss/dfssp/api/platform.proto && \
protoc --go_out=plugins=grpc:. dfss/dfsst/api/resolution.proto
clean:
rm -rf release
nocache:
package main
import (
dapi "dfss/dfssd/api"
"testing"
)
// Test for a client-server dialing
//
// Cannot add output statement because output includes timestamp
func TestServerAndClient(t *testing.T) {
// Start a server
go func() {
err := listen("localhost:3000")
if err != nil {
t.Error("Unable to start server")
}
}()
// Start a client
go func() {
defer dapi.DClose()
// this one fails silently, so you can't really test it
dapi.DLog("This is a log message from a client")
}()
// Start another client
go func() {
defer dapi.DClose()
// this one fails silently, so you can't really test it
dapi.DLog("This is a log message from another client")
}()
}
<RCC>
<qresource prefix="/">
</qresource>
</RCC>
package main
import (
"dfss"
"flag"
"fmt"
"os"
"runtime"
"strconv"
"dfss"
"dfss/dfssd/server"
)
var (
verbose bool
port int
)
func init() {
flag.BoolVar(&verbose, "v", false, "Print verbose messages")
flag.IntVar(&port, "p", 3000, "Network port used")
flag.Usage = func() {
fmt.Println("DFSS demonstrator v" + dfss.Version)
......@@ -26,7 +29,8 @@ func init() {
fmt.Println("\nThe commands are:")
fmt.Println(" help print this help")
fmt.Println(" version print dfss client version")
fmt.Println(" start start demonstrator server")
fmt.Println(" nogui start demonstrator server without GUI")
fmt.Println(" gui start demonstrator server with GUI")
fmt.Println("\nFlags:")
flag.PrintDefaults()
......@@ -40,14 +44,15 @@ func main() {
command := flag.Arg(0)
switch command {
case "help":
flag.Usage()
case "version":
fmt.Println("v"+dfss.Version, runtime.GOOS, runtime.GOARCH)
case "start":
err := listen("localhost:3000")
case "nogui":
err := server.Listen("0.0.0.0:" + strconv.Itoa(port))
if err != nil {
os.Exit(1)
}
default:
flag.Usage()
}
}
package main
package server
import (
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/grpclog"
"log"
"net"
api "dfss/dfssd/api"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/grpclog"
)
type server struct{}
type Server struct{}
// Sendlog Handler
//
// Handle incoming log messages
func (s *server) SendLog(ctx context.Context, in *api.Log) (*api.Ack, error) {
func (s *Server) SendLog(ctx context.Context, in *api.Log) (*api.Ack, error) {
addMessage(in)
return &api.Ack{}, nil
}
// Listen with gRPG service
func listen(addrPort string) error {
func Listen(addrPort string) error {
// open tcp socket
lis, err := net.Listen("tcp", addrPort)
if err != nil {
......@@ -35,7 +35,7 @@ func listen(addrPort string) error {
// bootstrap gRPC service !
grpcServer := grpc.NewServer()
api.RegisterDemonstratorServer(grpcServer, &server{})
api.RegisterDemonstratorServer(grpcServer, &Server{})
err = grpcServer.Serve(lis)
return err
......
package main
package server
import (
"log"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment