diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..e80b984 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,34 @@ +image: golang:latest +stages: + - build + - test + +before_script: + - mkdir -p /go/src/dev.sum7.eu/genofire/ + - cp -R /builds/genofire/hook2xmpp /go/src/dev.sum7.eu/genofire/logmania + - cd /go/src/dev.sum7.eu/genofire/hook2xmpp + - go get -d -t ./... + +build-my-project: + stage: build + script: + - go install dev.sum7.eu/genofire/hook2xmpp + artifacts: + paths: + - /go/bin/hook2xmpp + +test-my-project: + stage: test + script: + - ./.ci/check-gofmt + - ./.ci/check-testfiles + - ./.ci/check-misspell + - go test $(go list ./... | grep -v /vendor/) -v -coverprofile .testCoverage.txt + artifacts: + paths: + - .testCoverage.txt + +test-race-my-project: + stage: test + script: + - go test -race ./... diff --git a/README.md b/README.md index 0223ff6..e3db339 100644 --- a/README.md +++ b/README.md @@ -1 +1,5 @@ -# hook2xmpp [![CircleCI](https://circleci.com/gh/genofire/hook2xmpp/tree/master.svg?style=shield)](https://circleci.com/gh/genofire/hook2xmpp/tree/master) [![Coverage Status](https://coveralls.io/repos/github/genofire/hook2xmpp/badge.svg?branch=master)](https://coveralls.io/github/genofire/hook2xmpp?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/genofire/hook2xmpp)](https://goreportcard.com/report/github.com/genofire/hook2xmpp) [![GoDoc](https://godoc.org/github.com/genofire/hook2xmpp?status.svg)](https://godoc.org/github.com/genofire/hook2xmpp) +# hook2xmpp +[![Build Status](https://dev.sum7.eu/genofire/hs_masterthesis/badges/master/build.svg)](https://dev.sum7.eu/genofire/hs_masterthesis/pipelines) +[![Go Report Card](https://goreportcard.com/badge/dev.sum7.eu/genofire/hook2xmpp)](https://goreportcard.com/report/dev.sum7.eu/genofire/logmania) +[![GoDoc](https://godoc.org/dev.sum7.eu/genofire/hook2xmpp?status.svg)](https://godoc.org/dev.sum7.eu/genofire/logmania) + diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 58adc9a..0000000 --- a/circle.yml +++ /dev/null @@ -1,35 +0,0 @@ -notify: - webhooks: - - url: https://hook2xmpp.pub.warehost.de/circleci - -machine: - environment: - GOROOT: "" - PATH: "/usr/local/go/bin:/usr/local/go_workspace/bin:~/.go_workspace/bin:${PATH}" - GOPATH: "${HOME}/.go_workspace" - -dependencies: - override: - - mkdir -p ~/.go_workspace/src/github.com/${CIRCLE_PROJECT_USERNAME} - - ln -s ${HOME}/${CIRCLE_PROJECT_REPONAME} ${HOME}/.go_workspace/src/github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME} - - go get -t -d -v ./... - - go install github.com/genofire/hook2xmpp/cmd/hook2xmpp - post: - - cp ~/.go_workspace/bin/hook2xmpp hook2xmpp.bin - - tar -cvzf hook2xmpp-builded.tar.gz hook2xmpp.bin config_example.conf - - mv hook2xmpp-builded.tar.gz $CIRCLE_ARTIFACTS - - - -test: - pre: - - go get github.com/mattn/goveralls - - go get golang.org/x/tools/cmd/cover - override: - - ./.test-coverage circle-ci - -deployment: - staging: - branch: master - commands: - - ./deploy.sh $HOST_FOR_STAGING $PORT_FOR_STAGING diff --git a/config_example.conf b/config_example.conf index 7f6b2b8..82fd3b7 100644 --- a/config_example.conf +++ b/config_example.conf @@ -1,3 +1,4 @@ +log_level = 50 webserver_bind = ":8080" [xmpp] diff --git a/deploy.sh b/deploy.sh deleted file mode 100755 index d49bad2..0000000 --- a/deploy.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -host=$1 -port=$2 -remote="circleci@${host}" -echo "deploying..." -ssh -p $port $remote sudo systemctl stop hook2xmpp; -RETVAL=$? -[ $RETVAL -ne 0 ] && exit 1 -scp -q -P $port ~/.go_workspace/bin/hook2xmpp $remote:~/bin/hook2xmpp; -RETVAL=$? -ssh -p $port $remote sudo systemctl start hook2xmpp; -[ $RETVAL -eq 0 ] && RETVAL=$? -[ $RETVAL -ne 0 ] && exit 1 -echo "deployed" diff --git a/main.go b/main.go index b8f57d4..4e56767 100644 --- a/main.go +++ b/main.go @@ -28,6 +28,8 @@ func main() { log.Panicf("error on read config: %s", err) } + log.SetLevel(config.LogLevel) + // load config options := xmpp.Options{ Host: config.XMPP.Host, @@ -90,7 +92,6 @@ func main() { log.Infof("started hock2xmpp with %s", client.JID()) notify("startup of hock2xmpp") - // Wait for system signal sigs := make(chan os.Signal, 1) signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) diff --git a/runtime/config.go b/runtime/config.go index ac6fee8..2722eb8 100644 --- a/runtime/config.go +++ b/runtime/config.go @@ -1,6 +1,9 @@ package runtime +import "dev.sum7.eu/genofire/golang-lib/database" + type Config struct { + LogLevel logger.Level `toml:"log_level"` WebserverBind string `toml:"webserver_bind"` XMPP struct {