From f171bb93ccbcf0d2e74387332e7633e74ff9e3c7 Mon Sep 17 00:00:00 2001 From: Simon Tucker Date: Fri, 3 Jan 2020 15:00:55 -0800 Subject: [PATCH] Fixes readme. This closes #1. --- .gitignore | 3 ++ .travis.yml | 21 ++++++++++++++ README.md | 4 +-- build.sh | 1 + githubtasks.go | 71 +++++++++++++++++++++++++++++++++++++++++++++ githubtasks_test.go | 7 +++++ githubtasksutils.go | 4 +++ look_for_logs.sh | 20 +++++++++++++ 8 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100755 build.sh create mode 100644 githubtasks.go create mode 100644 githubtasks_test.go create mode 100644 githubtasksutils.go create mode 100755 look_for_logs.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..50269086 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*~ +githubtasks +.test diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..27ee299c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,21 @@ +language: go + +go: + - 1.9 + +branches: + only: + - master + +before_install: +- ./look_for_logs.sh +- go get github.com/axw/gocov/gocov +- go get github.com/mattn/goveralls +- go get golang.org/x/lint/golint +- go get github.com/GeertJohan/fgt +- if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; + fi + +script: +- fgt golint $(find . | grep .go$ | grep -v githubtasks.pb.go) +- $HOME/gopath/bin/goveralls -service=travis-ci -ignore=githubtasks.go -package github.com/brotherlogic/githubtasks diff --git a/README.md b/README.md index 71eddab9..674f69a7 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# recordadder -[![Coverage Status](https://coveralls.io/repos/github/brotherlogic/recordadder/badge.svg)](https://coveralls.io/github/brotherlogic/recordadder) +# githubtasks +[![Coverage Status](https://coveralls.io/repos/github/brotherlogic/githubtasks/badge.svg)](https://coveralls.io/github/brotherlogic/githubtasks) diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..9cf2f922 --- /dev/null +++ b/build.sh @@ -0,0 +1 @@ +protoc --proto_path ../../../ -I=./proto --go_out=plugins=grpc:./proto proto/githubtasks.proto diff --git a/githubtasks.go b/githubtasks.go new file mode 100644 index 00000000..776cb57b --- /dev/null +++ b/githubtasks.go @@ -0,0 +1,71 @@ +package main + +import ( + "flag" + "fmt" + "io/ioutil" + "log" + + "github.com/brotherlogic/goserver" + "golang.org/x/net/context" + "google.golang.org/grpc" + + pbg "github.com/brotherlogic/goserver/proto" +) + +//Server main server type +type Server struct { + *goserver.GoServer +} + +// Init builds the server +func Init() *Server { + s := &Server{ + GoServer: &goserver.GoServer{}, + } + return s +} + +// DoRegister does RPC registration +func (s *Server) DoRegister(server *grpc.Server) { + //Pass +} + +// ReportHealth alerts if we're not healthy +func (s *Server) ReportHealth() bool { + return true +} + +// Shutdown the server +func (s *Server) Shutdown(ctx context.Context) error { + return nil +} + +// Mote promotes/demotes this server +func (s *Server) Mote(ctx context.Context, master bool) error { + return nil +} + +// GetState gets the state of the server +func (s *Server) GetState() []*pbg.State { + return []*pbg.State{ + &pbg.State{Key: "no", Value: int64(233)}, + } +} + +func main() { + var quiet = flag.Bool("quiet", false, "Show all output") + flag.Parse() + + //Turn off logging + if *quiet { + log.SetFlags(0) + log.SetOutput(ioutil.Discard) + } + server := Init() + server.PrepServer() + server.Register = server + server.RegisterServerV2("githubtasks", false, false) + + fmt.Printf("%v", server.Serve()) +} diff --git a/githubtasks_test.go b/githubtasks_test.go new file mode 100644 index 00000000..6b3299c8 --- /dev/null +++ b/githubtasks_test.go @@ -0,0 +1,7 @@ +package main + +import "testing" + +func TestNothing(t *testing.T) { + dummy() +} diff --git a/githubtasksutils.go b/githubtasksutils.go new file mode 100644 index 00000000..19a10b69 --- /dev/null +++ b/githubtasksutils.go @@ -0,0 +1,4 @@ +package main + +func dummy() { +} diff --git a/look_for_logs.sh b/look_for_logs.sh new file mode 100755 index 00000000..a158bbef --- /dev/null +++ b/look_for_logs.sh @@ -0,0 +1,20 @@ +#!/bin/bash +grep log.Print * -Rl | grep .go$ | grep -v _test.go +RESULT=$? +if [ $RESULT != 1 ]; then + exit 1 +fi + +grep context.Background * -Rl | grep .go$ | grep -v _test.go +RESULT=$? +if [ $RESULT != 1 ]; then + exit 1 +fi + +RESULT1=$(grep "conn, err" *.go -R | wc | awk '{print $1}') +RESULT2=$(grep "conn.Close" *.go -R | wc| awk '{print $1}') + +if [ $RESULT1 != $RESULT2 ]; then + echo "Missing Closes!" + exit 1 +fi