try gitlab-ci
This commit is contained in:
		
							parent
							
								
									5c906df45d
								
							
						
					
					
						commit
						d84fd1cfbd
					
				|  | @ -0,0 +1,8 @@ | ||||||
|  | #!/bin/bash | ||||||
|  | 
 | ||||||
|  | result="$(gofmt -s -l . | grep -v '^vendor/' )" | ||||||
|  | if [ -n "$result" ]; then | ||||||
|  |   echo "Go code is not formatted, run 'gofmt -s -w .'" >&2 | ||||||
|  |   echo "$result" | ||||||
|  |   exit 1 | ||||||
|  | fi | ||||||
|  | @ -0,0 +1,25 @@ | ||||||
|  | #!/usr/bin/env python | ||||||
|  | # checks if every desired package has test files | ||||||
|  | 
 | ||||||
|  | import os | ||||||
|  | import re | ||||||
|  | import sys | ||||||
|  | 
 | ||||||
|  | source_re = re.compile(".*\.go") | ||||||
|  | test_re   = re.compile(".*_test\.go") | ||||||
|  | missing   = False | ||||||
|  | 
 | ||||||
|  | for root, dirs, files in os.walk("."): | ||||||
|  |   # ignore some paths | ||||||
|  |   if root == "." or root.startswith("./vendor") or root.startswith("./."): | ||||||
|  |     continue | ||||||
|  | 
 | ||||||
|  |   # source files but not test files? | ||||||
|  |   if len(filter(source_re.match, files)) > 0 and len(filter(test_re.match, files)) == 0: | ||||||
|  |     print("no test files for {}".format(root)) | ||||||
|  |     missing = True | ||||||
|  | 
 | ||||||
|  | if missing: | ||||||
|  |   sys.exit(1) | ||||||
|  | else: | ||||||
|  |   print("every package has test files") | ||||||
|  | @ -0,0 +1,34 @@ | ||||||
|  | image: golang:latest | ||||||
|  | stages: | ||||||
|  |   - build | ||||||
|  |   - test | ||||||
|  | 
 | ||||||
|  | before_script: | ||||||
|  |   - mkdir -p /go/src/git.sum7.eu/genofire/ | ||||||
|  |   - cp -R /builds/genofire/logmania /go/src/git.sum7.eu/genofire/logmania | ||||||
|  |   - cd /go/src/git.sum7.eu/genofire/logmania | ||||||
|  |   - go get -d -t ./... | ||||||
|  | 
 | ||||||
|  | build-my-project: | ||||||
|  |   stage: build | ||||||
|  |   script: | ||||||
|  |     - go install git.sum7.eu/genofire/logmania | ||||||
|  |   artifacts: | ||||||
|  |     paths: | ||||||
|  |       - /go/bin/logmania | ||||||
|  | 
 | ||||||
|  | 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,33 +0,0 @@ | ||||||
| #!/bin/bash |  | ||||||
| # Issue:  https://github.com/mattn/goveralls/issues/20 |  | ||||||
| # Source: https://github.com/uber/go-torch/blob/63da5d33a225c195fea84610e2456d5f722f3963/.test-cover.sh |  | ||||||
| CI=$1 |  | ||||||
| echo "run for $CI" |  | ||||||
| 
 |  | ||||||
| if [ "$CI" == "circle-ci" ]; then |  | ||||||
|   cd ${GOPATH}/src/github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME} |  | ||||||
| fi |  | ||||||
| 
 |  | ||||||
| echo "mode: count" > profile.cov |  | ||||||
| FAIL=0 |  | ||||||
| 
 |  | ||||||
| # Standard go tooling behavior is to ignore dirs with leading underscors |  | ||||||
| for dir in $(find . -maxdepth 10 -not -path './vendor/*' -not -path './.git*' -not -path '*/_*' -type d); |  | ||||||
| do |  | ||||||
|   if ls $dir/*.go &> /dev/null; then |  | ||||||
|     go test -v -covermode=count -coverprofile=profile.tmp $dir || FAIL=$? |  | ||||||
|     if [ -f profile.tmp ] |  | ||||||
|     then |  | ||||||
|       tail -n +2 < profile.tmp >> profile.cov |  | ||||||
|       rm profile.tmp |  | ||||||
|     fi |  | ||||||
|   fi |  | ||||||
| done |  | ||||||
| 
 |  | ||||||
| # Failures have incomplete results, so don't send |  | ||||||
| if [ "$FAIL" -eq 0 ]; then |  | ||||||
|   goveralls -v -coverprofile=profile.cov -service=$CI -repotoken=$COVERALLS_REPO_TOKEN |  | ||||||
|   bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN -f profile.cov |  | ||||||
| fi |  | ||||||
| 
 |  | ||||||
| exit $FAIL |  | ||||||
|  | @ -11,7 +11,7 @@ func NewFilter(db *database.DB) *Command { | ||||||
| 		Name:        "filter", | 		Name:        "filter", | ||||||
| 		Description: "list and configurate regex filter for channel by message content", | 		Description: "list and configurate regex filter for channel by message content", | ||||||
| 		Commands: []*Command{ | 		Commands: []*Command{ | ||||||
| 			&Command{ | 			{ | ||||||
| 				Name:        "add", | 				Name:        "add", | ||||||
| 				Description: "add regex filter for channel:  [channel] regex", | 				Description: "add regex filter for channel:  [channel] regex", | ||||||
| 				Action: func(from string, params []string) string { | 				Action: func(from string, params []string) string { | ||||||
|  | @ -32,7 +32,7 @@ func NewFilter(db *database.DB) *Command { | ||||||
| 					return fmt.Sprintf("add regex for \"%s\" to %s", of, regex) | 					return fmt.Sprintf("add regex for \"%s\" to %s", of, regex) | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			&Command{ | 			{ | ||||||
| 				Name:        "del", | 				Name:        "del", | ||||||
| 				Description: "del regex filter for channel:  [channel] regex", | 				Description: "del regex filter for channel:  [channel] regex", | ||||||
| 				Action: func(from string, params []string) string { | 				Action: func(from string, params []string) string { | ||||||
|  | @ -50,7 +50,7 @@ func NewFilter(db *database.DB) *Command { | ||||||
| 					return "deleted" | 					return "deleted" | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			&Command{ | 			{ | ||||||
| 				Name:        "all", | 				Name:        "all", | ||||||
| 				Description: "list of all channels", | 				Description: "list of all channels", | ||||||
| 				Action: func(from string, params []string) string { | 				Action: func(from string, params []string) string { | ||||||
|  | @ -64,7 +64,7 @@ func NewFilter(db *database.DB) *Command { | ||||||
| 					return msg | 					return msg | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			&Command{ | 			{ | ||||||
| 				Name:        "channel", | 				Name:        "channel", | ||||||
| 				Description: "list of given channel: channel", | 				Description: "list of given channel: channel", | ||||||
| 				Action: func(from string, params []string) string { | 				Action: func(from string, params []string) string { | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ func NewHostname(db *database.DB) *Command { | ||||||
| 		Name:        "hostname", | 		Name:        "hostname", | ||||||
| 		Description: "alternative short (host)names for long IP-Addresses or URLs (and time of last recieved input)", | 		Description: "alternative short (host)names for long IP-Addresses or URLs (and time of last recieved input)", | ||||||
| 		Commands: []*Command{ | 		Commands: []*Command{ | ||||||
| 			&Command{ | 			{ | ||||||
| 				Name:        "set", | 				Name:        "set", | ||||||
| 				Description: "set or replace a hostname: IPAddress/Hostname NewHostname", | 				Description: "set or replace a hostname: IPAddress/Hostname NewHostname", | ||||||
| 				Action: func(from string, params []string) string { | 				Action: func(from string, params []string) string { | ||||||
|  | @ -31,7 +31,7 @@ func NewHostname(db *database.DB) *Command { | ||||||
| 					return fmt.Sprintf("set for %s the hostname %s", addr, name) | 					return fmt.Sprintf("set for %s the hostname %s", addr, name) | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			&Command{ | 			{ | ||||||
| 				Name:        "del", | 				Name:        "del", | ||||||
| 				Description: "delete a hostname: IPAddress/Hostname", | 				Description: "delete a hostname: IPAddress/Hostname", | ||||||
| 				Action: func(from string, params []string) string { | 				Action: func(from string, params []string) string { | ||||||
|  |  | ||||||
|  | @ -13,7 +13,7 @@ func NewPriority(db *database.DB) *Command { | ||||||
| 		Name:        "priority", | 		Name:        "priority", | ||||||
| 		Description: "list and configurate priority in channel", | 		Description: "list and configurate priority in channel", | ||||||
| 		Commands: []*Command{ | 		Commands: []*Command{ | ||||||
| 			&Command{ | 			{ | ||||||
| 				Name:        "set", | 				Name:        "set", | ||||||
| 				Description: "set max priority of channel: [channel] Priority", | 				Description: "set max priority of channel: [channel] Priority", | ||||||
| 				Action: func(from string, params []string) string { | 				Action: func(from string, params []string) string { | ||||||
|  | @ -43,7 +43,7 @@ func NewPriority(db *database.DB) *Command { | ||||||
| 					return fmt.Sprintf("set filter for %s to %s", to, max.String()) | 					return fmt.Sprintf("set filter for %s to %s", to, max.String()) | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			&Command{ | 			{ | ||||||
| 				Name:        "all", | 				Name:        "all", | ||||||
| 				Description: "list of all channels", | 				Description: "list of all channels", | ||||||
| 				Action: func(from string, params []string) string { | 				Action: func(from string, params []string) string { | ||||||
|  | @ -54,7 +54,7 @@ func NewPriority(db *database.DB) *Command { | ||||||
| 					return msg | 					return msg | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			&Command{ | 			{ | ||||||
| 				Name:        "channel", | 				Name:        "channel", | ||||||
| 				Description: "list of given channel: channel", | 				Description: "list of given channel: channel", | ||||||
| 				Action: func(from string, params []string) string { | 				Action: func(from string, params []string) string { | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ func NewReplace(db *database.DB) *Command { | ||||||
| 		Name:        "replace", | 		Name:        "replace", | ||||||
| 		Description: "list and configurate replace content of message for channel", | 		Description: "list and configurate replace content of message for channel", | ||||||
| 		Commands: []*Command{ | 		Commands: []*Command{ | ||||||
| 			&Command{ | 			{ | ||||||
| 				Name:        "add", | 				Name:        "add", | ||||||
| 				Description: "add regex replace for channel:  [channel] regex replace", | 				Description: "add regex replace for channel:  [channel] regex replace", | ||||||
| 				Action: func(from string, params []string) string { | 				Action: func(from string, params []string) string { | ||||||
|  | @ -34,7 +34,7 @@ func NewReplace(db *database.DB) *Command { | ||||||
| 					return fmt.Sprintf("add replace in \"%s\" for \"%s\" to \"%s\"", of, regex, value) | 					return fmt.Sprintf("add replace in \"%s\" for \"%s\" to \"%s\"", of, regex, value) | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			&Command{ | 			{ | ||||||
| 				Name:        "del", | 				Name:        "del", | ||||||
| 				Description: "del regex replace for channel:  [channel] regex replace", | 				Description: "del regex replace for channel:  [channel] regex replace", | ||||||
| 				Action: func(from string, params []string) string { | 				Action: func(from string, params []string) string { | ||||||
|  | @ -54,7 +54,7 @@ func NewReplace(db *database.DB) *Command { | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 
 | 
 | ||||||
| 			&Command{ | 			{ | ||||||
| 				Name:        "all", | 				Name:        "all", | ||||||
| 				Description: "list of all channels", | 				Description: "list of all channels", | ||||||
| 				Action: func(from string, params []string) string { | 				Action: func(from string, params []string) string { | ||||||
|  | @ -68,7 +68,7 @@ func NewReplace(db *database.DB) *Command { | ||||||
| 					return msg | 					return msg | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			&Command{ | 			{ | ||||||
| 				Name:        "channel", | 				Name:        "channel", | ||||||
| 				Description: "list of given channel: channel", | 				Description: "list of given channel: channel", | ||||||
| 				Action: func(from string, params []string) string { | 				Action: func(from string, params []string) string { | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ func NewSend(db *database.DB) *Command { | ||||||
| 		Name:        "send", | 		Name:        "send", | ||||||
| 		Description: "list and configurate destination for hostnames", | 		Description: "list and configurate destination for hostnames", | ||||||
| 		Commands: []*Command{ | 		Commands: []*Command{ | ||||||
| 			&Command{ | 			{ | ||||||
| 				Name:        "add", | 				Name:        "add", | ||||||
| 				Description: "add a destination for host with: IPAddress/Hostname [to]", | 				Description: "add a destination for host with: IPAddress/Hostname [to]", | ||||||
| 				Action: func(from string, params []string) string { | 				Action: func(from string, params []string) string { | ||||||
|  | @ -43,7 +43,7 @@ func NewSend(db *database.DB) *Command { | ||||||
| 					return fmt.Sprintf("added %s in list of %s", to, host) | 					return fmt.Sprintf("added %s in list of %s", to, host) | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			&Command{ | 			{ | ||||||
| 				Name:        "del", | 				Name:        "del", | ||||||
| 				Description: "del a destination for host with: IPAddress/Hostname [to]", | 				Description: "del a destination for host with: IPAddress/Hostname [to]", | ||||||
| 				Action: func(from string, params []string) string { | 				Action: func(from string, params []string) string { | ||||||
|  | @ -63,7 +63,7 @@ func NewSend(db *database.DB) *Command { | ||||||
| 					return "not found host" | 					return "not found host" | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			&Command{ | 			{ | ||||||
| 				Name:        "all", | 				Name:        "all", | ||||||
| 				Description: "list of all hosts with there channels", | 				Description: "list of all hosts with there channels", | ||||||
| 				Action: func(from string, params []string) string { | 				Action: func(from string, params []string) string { | ||||||
|  | @ -85,7 +85,7 @@ func NewSend(db *database.DB) *Command { | ||||||
| 					return msg | 					return msg | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			&Command{ | 			{ | ||||||
| 				Name:        "channel", | 				Name:        "channel", | ||||||
| 				Description: "list all host of given channel: channel", | 				Description: "list all host of given channel: channel", | ||||||
| 				Action: func(from string, params []string) string { | 				Action: func(from string, params []string) string { | ||||||
|  |  | ||||||
							
								
								
									
										41
									
								
								circle.yml
								
								
								
								
							
							
						
						
									
										41
									
								
								circle.yml
								
								
								
								
							|  | @ -1,41 +0,0 @@ | ||||||
| version: 2 |  | ||||||
| jobs: |  | ||||||
|   build: |  | ||||||
|     docker: |  | ||||||
|       - image: circleci/golang:latest |  | ||||||
|     working_directory: /go/src/dev.sum7.eu/genofire/logmania |  | ||||||
|     steps: |  | ||||||
|       - checkout |  | ||||||
|       - run: go get -t -d -v ./... |  | ||||||
|       - run: go install dev.sum7.eu/genofire/logmania |  | ||||||
|       - store_artifacts: |  | ||||||
|           path: /go/bin/ |  | ||||||
|           destination: logmania |  | ||||||
|   test: |  | ||||||
|     docker: |  | ||||||
|       - image: circleci/golang:latest |  | ||||||
|     working_directory: /go/src/dev.sum7.eu/genofire/logmania |  | ||||||
|     steps: |  | ||||||
|       - checkout |  | ||||||
|       - run: go get -t -d -v ./... |  | ||||||
|       - run: go get github.com/mattn/goveralls |  | ||||||
|       - run: go get golang.org/x/tools/cmd/cover |  | ||||||
|       - run: ./.test-coverage circle-ci |  | ||||||
|       - store_test_results: |  | ||||||
|           path: ./ |  | ||||||
|           destination: profile.cov |  | ||||||
|   test_race: |  | ||||||
|     docker: |  | ||||||
|       - image: circleci/golang:latest |  | ||||||
|     working_directory: /go/src/dev.sum7.eu/genofire/logmania |  | ||||||
|     steps: |  | ||||||
|       - checkout |  | ||||||
|       - run: go get -t -d -v ./... |  | ||||||
|       - run: go test -race ./... |  | ||||||
| workflows: |  | ||||||
|   version: 2 |  | ||||||
|   build_and_tests: |  | ||||||
|     jobs: |  | ||||||
|       - build |  | ||||||
|       - test |  | ||||||
|       - test_race |  | ||||||
		Loading…
	
		Reference in New Issue