[TASK] use circle ci for build artifacts + enable data race detection (#95)
This commit is contained in:
parent
63eaa413d6
commit
037ff80193
@ -1,6 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Issue: https://github.com/mattn/goveralls/issues/20
|
# Issue: https://github.com/mattn/goveralls/issues/20
|
||||||
# Source: https://github.com/uber/go-torch/blob/63da5d33a225c195fea84610e2456d5f722f3963/.test-cover.sh
|
# 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
|
echo "mode: count" > profile.cov
|
||||||
FAIL=0
|
FAIL=0
|
||||||
@ -20,7 +26,7 @@ done
|
|||||||
|
|
||||||
# Failures have incomplete results, so don't send
|
# Failures have incomplete results, so don't send
|
||||||
if [ "$FAIL" -eq 0 ]; then
|
if [ "$FAIL" -eq 0 ]; then
|
||||||
goveralls -service=travis-ci -v -coverprofile=profile.cov
|
goveralls -service=$CI -v -coverprofile=profile.cov
|
||||||
bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN -f profile.cov
|
bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN -f profile.cov
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -7,5 +7,5 @@ install:
|
|||||||
- go get github.com/mattn/goveralls
|
- go get github.com/mattn/goveralls
|
||||||
- go get golang.org/x/tools/cmd/cover
|
- go get golang.org/x/tools/cmd/cover
|
||||||
script:
|
script:
|
||||||
- ./.test-coverage
|
- ./.test-coverage travis-ci
|
||||||
- go install github.com/FreifunkBremen/yanic
|
- go install github.com/FreifunkBremen/yanic
|
||||||
|
@ -9,6 +9,7 @@ Yet another node info collector
|
|||||||
```
|
```
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/FreifunkBremen/yanic.svg?branch=master)](https://travis-ci.org/FreifunkBremen/yanic)
|
[![Build Status](https://travis-ci.org/FreifunkBremen/yanic.svg?branch=master)](https://travis-ci.org/FreifunkBremen/yanic)
|
||||||
|
[![CircleCI](https://circleci.com/gh/FreifunkBremen/yanic/tree/master.svg?style=shield)](https://circleci.com/gh/FreifunkBremen/yanic/tree/master)
|
||||||
[![Coverage Status](https://coveralls.io/repos/github/FreifunkBremen/yanic/badge.svg?branch=master)](https://coveralls.io/github/FreifunkBremen/yanic?branch=master)
|
[![Coverage Status](https://coveralls.io/repos/github/FreifunkBremen/yanic/badge.svg?branch=master)](https://coveralls.io/github/FreifunkBremen/yanic?branch=master)
|
||||||
[![codecov](https://codecov.io/gh/FreifunkBremen/yanic/branch/master/graph/badge.svg)](https://codecov.io/gh/FreifunkBremen/yanic)
|
[![codecov](https://codecov.io/gh/FreifunkBremen/yanic/branch/master/graph/badge.svg)](https://codecov.io/gh/FreifunkBremen/yanic)
|
||||||
[![Go Report Card](https://goreportcard.com/badge/github.com/FreifunkBremen/yanic)](https://goreportcard.com/report/github.com/FreifunkBremen/yanic)
|
[![Go Report Card](https://goreportcard.com/badge/github.com/FreifunkBremen/yanic)](https://goreportcard.com/report/github.com/FreifunkBremen/yanic)
|
||||||
|
41
circle.yml
Normal file
41
circle.yml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
version: 2
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
docker:
|
||||||
|
- image: circleci/golang:latest
|
||||||
|
working_directory: /go/src/github.com/FreifunkBremen/yanic
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run: go get -t -d -v ./...
|
||||||
|
- run: go install github.com/FreifunkBremen/yanic
|
||||||
|
- store_artifacts:
|
||||||
|
path: /go/bin/
|
||||||
|
destination: yanic
|
||||||
|
test:
|
||||||
|
docker:
|
||||||
|
- image: circleci/golang:latest
|
||||||
|
working_directory: /go/src/github.com/FreifunkBremen/yanic
|
||||||
|
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/github.com/FreifunkBremen/yanic
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run: go get -t -d -v ./...
|
||||||
|
- run: go test -race ./...
|
||||||
|
workflows:
|
||||||
|
version: 2
|
||||||
|
build_and_tests:
|
||||||
|
jobs:
|
||||||
|
- build
|
||||||
|
- test
|
||||||
|
- test_race
|
@ -2,6 +2,7 @@ package all
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/FreifunkBremen/yanic/output"
|
"github.com/FreifunkBremen/yanic/output"
|
||||||
@ -11,11 +12,19 @@ import (
|
|||||||
|
|
||||||
type testOutput struct {
|
type testOutput struct {
|
||||||
output.Output
|
output.Output
|
||||||
CountSave int
|
countSave int
|
||||||
|
sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *testOutput) Save(nodes *runtime.Nodes) {
|
func (c *testOutput) Save(nodes *runtime.Nodes) {
|
||||||
c.CountSave++
|
c.Lock()
|
||||||
|
c.countSave++
|
||||||
|
c.Unlock()
|
||||||
|
}
|
||||||
|
func (c *testOutput) Get() int {
|
||||||
|
c.Lock()
|
||||||
|
defer c.Unlock()
|
||||||
|
return c.countSave
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStart(t *testing.T) {
|
func TestStart(t *testing.T) {
|
||||||
@ -69,9 +78,9 @@ func TestStart(t *testing.T) {
|
|||||||
})
|
})
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
assert.Equal(0, globalOutput.CountSave)
|
assert.Equal(0, globalOutput.Get())
|
||||||
allOutput.Save(nodes)
|
allOutput.Save(nodes)
|
||||||
assert.Equal(3, globalOutput.CountSave)
|
assert.Equal(3, globalOutput.Get())
|
||||||
|
|
||||||
_, err = Register(map[string]interface{}{
|
_, err = Register(map[string]interface{}{
|
||||||
"e": []map[string]interface{}{
|
"e": []map[string]interface{}{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package output
|
package output
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -10,11 +11,19 @@ import (
|
|||||||
|
|
||||||
type testConn struct {
|
type testConn struct {
|
||||||
Output
|
Output
|
||||||
CountSave int
|
countSave int
|
||||||
|
sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *testConn) Save(nodes *runtime.Nodes) {
|
func (c *testConn) Save(nodes *runtime.Nodes) {
|
||||||
c.CountSave++
|
c.Lock()
|
||||||
|
c.countSave++
|
||||||
|
c.Unlock()
|
||||||
|
}
|
||||||
|
func (c *testConn) Get() int {
|
||||||
|
c.Lock()
|
||||||
|
defer c.Unlock()
|
||||||
|
return c.countSave
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStart(t *testing.T) {
|
func TestStart(t *testing.T) {
|
||||||
@ -38,12 +47,12 @@ func TestStart(t *testing.T) {
|
|||||||
Start(conn, nil, config)
|
Start(conn, nil, config)
|
||||||
assert.NotNil(quit)
|
assert.NotNil(quit)
|
||||||
|
|
||||||
assert.Equal(0, conn.CountSave)
|
assert.Equal(0, conn.Get())
|
||||||
time.Sleep(time.Millisecond * 12)
|
time.Sleep(time.Millisecond * 12)
|
||||||
assert.Equal(1, conn.CountSave)
|
assert.Equal(1, conn.Get())
|
||||||
|
|
||||||
time.Sleep(time.Millisecond * 12)
|
time.Sleep(time.Millisecond * 12)
|
||||||
Close()
|
Close()
|
||||||
assert.Equal(2, conn.CountSave)
|
assert.Equal(2, conn.Get())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user