[TASK] add gitlab-ci
This commit is contained in:
		
							parent
							
								
									bcfdc26bb9
								
							
						
					
					
						commit
						40ac491770
					
				| 
						 | 
					@ -0,0 +1,34 @@
 | 
				
			||||||
 | 
					image: golang:latest
 | 
				
			||||||
 | 
					stages:
 | 
				
			||||||
 | 
					  - build
 | 
				
			||||||
 | 
					  - test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					before_script:
 | 
				
			||||||
 | 
					  - mkdir -p /go/src/git.sum7.eu/genofire/
 | 
				
			||||||
 | 
					  - cp -R /builds/genofire/hook2xmpp /go/src/git.sum7.eu/genofire/logmania
 | 
				
			||||||
 | 
					  - cd /go/src/git.sum7.eu/genofire/hook2xmpp
 | 
				
			||||||
 | 
					  - go get -d -t ./...
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					build-my-project:
 | 
				
			||||||
 | 
					  stage: build
 | 
				
			||||||
 | 
					  script:
 | 
				
			||||||
 | 
					    - go install git.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 ./...
 | 
				
			||||||
| 
						 | 
					@ -1 +1,5 @@
 | 
				
			||||||
# hook2xmpp [](https://circleci.com/gh/genofire/hook2xmpp/tree/master) [](https://coveralls.io/github/genofire/hook2xmpp?branch=master) [](https://goreportcard.com/report/github.com/genofire/hook2xmpp) [](https://godoc.org/github.com/genofire/hook2xmpp)
 | 
					# hook2xmpp
 | 
				
			||||||
 | 
					[](https://dev.sum7.eu/genofire/hs_masterthesis/pipelines)
 | 
				
			||||||
 | 
					[](https://goreportcard.com/report/dev.sum7.eu/genofire/logmania)
 | 
				
			||||||
 | 
					[](https://godoc.org/dev.sum7.eu/genofire/logmania)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										35
									
								
								circle.yml
								
								
								
								
							
							
						
						
									
										35
									
								
								circle.yml
								
								
								
								
							| 
						 | 
					@ -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
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,4 @@
 | 
				
			||||||
 | 
					log_level = 50
 | 
				
			||||||
webserver_bind = ":8080"
 | 
					webserver_bind = ":8080"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[xmpp]
 | 
					[xmpp]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										14
									
								
								deploy.sh
								
								
								
								
							
							
						
						
									
										14
									
								
								deploy.sh
								
								
								
								
							| 
						 | 
					@ -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"
 | 
					 | 
				
			||||||
							
								
								
									
										3
									
								
								main.go
								
								
								
								
							
							
						
						
									
										3
									
								
								main.go
								
								
								
								
							| 
						 | 
					@ -28,6 +28,8 @@ func main() {
 | 
				
			||||||
		log.Panicf("error on read config: %s", err)
 | 
							log.Panicf("error on read config: %s", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						log.SetLevel(config.LogLevel)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// load config
 | 
						// load config
 | 
				
			||||||
	options := xmpp.Options{
 | 
						options := xmpp.Options{
 | 
				
			||||||
		Host:          config.XMPP.Host,
 | 
							Host:          config.XMPP.Host,
 | 
				
			||||||
| 
						 | 
					@ -90,7 +92,6 @@ func main() {
 | 
				
			||||||
	log.Infof("started hock2xmpp with %s", client.JID())
 | 
						log.Infof("started hock2xmpp with %s", client.JID())
 | 
				
			||||||
	notify("startup of hock2xmpp")
 | 
						notify("startup of hock2xmpp")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
	// Wait for system signal
 | 
						// Wait for system signal
 | 
				
			||||||
	sigs := make(chan os.Signal, 1)
 | 
						sigs := make(chan os.Signal, 1)
 | 
				
			||||||
	signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
 | 
						signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,9 @@
 | 
				
			||||||
package runtime
 | 
					package runtime
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import "dev.sum7.eu/genofire/golang-lib/database"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Config struct {
 | 
					type Config struct {
 | 
				
			||||||
 | 
						LogLevel      logger.Level    `toml:"log_level"`
 | 
				
			||||||
	WebserverBind string `toml:"webserver_bind"`
 | 
						WebserverBind string `toml:"webserver_bind"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	XMPP struct {
 | 
						XMPP struct {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue