[TASK] add gitlab-ci

This commit is contained in:
Martin/Geno 2019-02-14 01:32:27 +01:00
parent bcfdc26bb9
commit acce9c0604
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
7 changed files with 45 additions and 51 deletions

34
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,34 @@
image: golang:latest
stages:
- build
- test
before_script:
- mkdir -p /go/src/dev.sum7.eu/genofire/
- cp -R /builds /go/src/dev.sum7.eu/genofire/logmania/hook2xmpp
- 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 ./...

View File

@ -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)

View File

@ -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

View File

@ -1,3 +1,4 @@
log_level = 50
webserver_bind = ":8080"
[xmpp]

View File

@ -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"

View File

@ -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)

View File

@ -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 {