migrate ci to woodpicker
continuous-integration/drone the build was successful Details

- fix lint - install python3
- fix database
- fix coverage (use own)
This commit is contained in:
Geno 2021-06-01 15:30:05 +02:00
parent 88ca3d142e
commit 917e7db85b
8 changed files with 46 additions and 128 deletions

View File

@ -6,3 +6,4 @@ if [ -n "$result" ]; then
echo "$result" echo "$result"
exit 1 exit 1
fi fi

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# checks if every desired package has test files # checks if every desired package has test files
import os import os
@ -11,11 +11,11 @@ missing = False
for root, dirs, files in os.walk("."): for root, dirs, files in os.walk("."):
# ignore some paths # ignore some paths
if root == "." or root == "./database/graphite" or root.startswith("./vendor") or root.startswith("./."): if root == "." or root.startswith("./vendor") or root.startswith("./.") or root.startswith("./docs"):
continue continue
# source files but not test files? # source files but not test files?
if len(filter(source_re.match, files)) > 0 and len(filter(test_re.match, files)) == 0: if len([f for f in files if source_re.match(f)]) > 0 and len([f for f in files if test_re.match(f)]) == 0:
print("no test files for {}".format(root)) print("no test files for {}".format(root))
missing = True missing = True
@ -23,3 +23,4 @@ if missing:
sys.exit(1) sys.exit(1)
else: else:
print("every package has test files") print("every package has test files")

View File

@ -1,26 +0,0 @@
pipeline:
# Library does not need to build
#build:
# image: golang:latest
# commands:
# - go get -d -t ./...
# - go install
test-coverage:
image: golang:latest
commands:
- go get -u github.com/mattn/goveralls
- go get -u golang.org/x/tools/cmd/cover
- go get -d -t ./...
- ./contrib/ci/check-coverage drone.io
codestyle:
image: golang:latest
commands:
- ./contrib/ci/check-testfiles
- ./contrib/ci/check-gofmt
- go get github.com/client9/misspell/cmd/misspell
- misspell -error .
test-race:
image: golang:latest
commands:
- go get -d -t ./...
- go test -race ./...

29
.woodpecker.yml Normal file
View File

@ -0,0 +1,29 @@
services:
database:
image: cockroachdb/cockroach:latest
commands:
- cockroach start-single-node --insecure
pipeline:
lint:
image: golang:latest
commands:
- apt update
- apt install python3 --yes
- ./.ci/check-testfiles
- ./.ci/check-gofmt
- go get github.com/client9/misspell/cmd/misspell
- misspell -error .
test-coverage:
image: golang:latest
commands:
- go get -d -t ./...
- go test -ldflags "-X dev.sum7.eu/genofire/golang-lib/web/webtest.DBConnection=postgres://root:root@database:26257/defaultdb?sslmode=disable" $(go list ./... | grep -v /vendor/) -v -failfast -p 1 -coverprofile .testCoverage.txt
- go tool cover -func=".testCoverage.txt"
test-race:
image: golang:latest
commands:
- go get -d -t ./...
- go test -ldflags "-X dev.sum7.eu/genofire/golang-lib/web/webtest.DBConnection=postgres://root:root@database:26257/defaultdb?sslmode=disable" $(go list ./... | grep -v /vendor/) -race

View File

@ -1,9 +1,11 @@
# golang-lib # golang-lib
[![DroneCI](https://ci.sum7.eu/api/badges/genofire/golang-lib/status.svg?branch=master)](https://ci.sum7.eu/genofire/golang-lib) [![DroneCI](https://ci.sum7.eu/api/badges/genofire/golang-lib/status.svg?branch=main)](https://ci.sum7.eu/genofire/golang-lib)
[![Travis](https://travis-ci.org/genofire/golang-lib.svg?branch=master)](https://travis-ci.org/genofire/golang-lib) [![CircleCI](https://circleci.com/gh/genofire/golang-lib/tree/master.svg?style=shield)](https://circleci.com/gh/genofire/golang-lib/tree/master)
[![Coverage](https://coveralls.io/repos/github/genofire/golang-lib/badge.svg?branch=master)](https://coveralls.io/github/genofire/golang-lib?branch=master)
[![codecov](https://codecov.io/gh/genofire/golang-lib/branch/master/graph/badge.svg)](https://codecov.io/gh/genofire/golang-lib)
[![Go Report Card](https://goreportcard.com/badge/dev.sum7.eu/genofire/golang-lib)](https://goreportcard.com/report/dev.sum7.eu/genofire/golang-lib) [![Go Report Card](https://goreportcard.com/badge/dev.sum7.eu/genofire/golang-lib)](https://goreportcard.com/report/dev.sum7.eu/genofire/golang-lib)
[![GoDoc](https://godoc.org/dev.sum7.eu/genofire/golang-lib?status.svg)](https://godoc.org/dev.sum7.eu/genofire/golang-lib) [![GoDoc](https://pkg.go.dev/dev.sum7.eu/genofire/golang-lib?status.svg)](https://godoc.org/dev.sum7.eu/genofire/golang-lib)
some packages collected for easy and often used functions some packages collected for easy and often used functions
- `file`: Read and Save - JSON, TOML
- `database`: Start by Config, Migrate
- `worker`: cronjob
- `web`: helpers for golang-gin framework e.g. websocket, metrics, status, auth

View File

@ -1,50 +0,0 @@
version: 2
jobs:
build:
docker:
- image: circleci/golang:latest
working_directory: /go/src/github.com/genofire/golang-lib
steps:
- checkout
- run: go get -d -t ./...
- run: go install
test-coverage:
docker:
- image: circleci/golang:latest
working_directory: /go/src/github.com/genofire/golang-lib
steps:
- checkout
- run: go get -d -t ./...
- run: go get github.com/mattn/goveralls
- run: go get golang.org/x/tools/cmd/cover
- run: ./contrib/ci/check-coverage circle-ci
- store_test_results:
path: ./
destination: profile.cov
codestyle:
docker:
- image: circleci/golang:latest
working_directory: /go/src/github.com/genofire/golang-lib
steps:
- checkout
- run: go get -d -t ./...
- run: ./contrib/ci/check-testfiles
- run: ./contrib/ci/check-gofmt
- run: go get github.com/client9/misspell/cmd/misspell
- run: misspell -error .
test_race:
docker:
- image: circleci/golang:latest
working_directory: /go/src/github.com/genofire/golang-lib
steps:
- checkout
- run: go get -d -t ./...
- run: go test -race ./...
workflows:
version: 2
build_and_tests:
jobs:
#- build # Library does not need to build
- test-coverage
- codestyle
- test_race

View File

@ -1,43 +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"
# circle-ci
# travis-ci
# travis-pro
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
[ "$FAIL" -ne 0 ] && exit 1
# ci not publishing
[ "$CI" == "" ] && exit 0
if [ "$CODECOV_TOKEN" != "" ]; then
bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN -f profile.cov
fi
if [ "$COVERALLS_REPO_TOKEN" != "" ] ; then
goveralls -v -coverprofile=profile.cov -service=$CI -repotoken=$COVERALLS_REPO_TOKEN
fi

View File

@ -16,6 +16,10 @@ import (
"dev.sum7.eu/genofire/golang-lib/web" "dev.sum7.eu/genofire/golang-lib/web"
) )
var (
DBConnection = "user=root password=root dbname=defaultdb host=localhost port=26257 sslmode=disable"
)
type testServer struct { type testServer struct {
db *database.Database db *database.Database
gin *gin.Engine gin *gin.Engine
@ -32,7 +36,7 @@ type Login struct {
func New(assert *assert.Assertions) *testServer { func New(assert *assert.Assertions) *testServer {
// db setup // db setup
dbConfig := database.Database{ dbConfig := database.Database{
Connection: "user=root password=root dbname=defaultdb host=localhost port=26257 sslmode=disable", Connection: DBConnection,
Testdata: true, Testdata: true,
Debug: false, Debug: false,
LogLevel: 0, LogLevel: 0,