diff --git a/.travis.yml b/.travis.yml index c0233368..f57343e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,14 +5,16 @@ go: sudo: false before_install: - gotools=golang.org/x/tools - - if [ "$TRAVIS_GO_VERSION" = "release" ] || [ "$TRAVIS_GO_VERSION" = "go1.3.3" ]; then gotools=code.google.com/p/go.tools; fi + - if [ "$TRAVIS_GO_VERSION" = "release" ]; then gotools=code.google.com/p/go.tools; fi install: - go get -d -t -v ./... - - go get $gotools/cmd/vet - - go get -v github.com/GeertJohan/fgt + - go get -v $gotools/cmd/cover + - go get -v $gotools/cmd/vet + - go get -v github.com/bradfitz/goimports - go get -v github.com/golang/lint/golint + - go get -v github.com/mattn/goveralls script: - export PATH=$PATH:$HOME/gopath/bin - - go vet - - fgt golint -min_confidence=0.9 . - - go test -v + - ./goclean.sh +after_success: + - goveralls -coverprofile=profile.cov -service=travis-ci diff --git a/README.md b/README.md index 18bd230c..0b0b8085 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,10 @@ btcjson ======= [![Build Status](https://travis-ci.org/btcsuite/btcjson.png?branch=master)] -(https://travis-ci.org/btcsuite/btcjson) +(https://travis-ci.org/btcsuite/btcjson) [![Coverage Status] +(https://img.shields.io/coveralls/btcsuite/btcjson.svg)] +(https://coveralls.io/r/btcsuite/btcjson?branch=master) [![ISC License] +(http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) Package btcjson implements concrete types for marshalling to and from the bitcoin JSON-RPC API. A comprehensive suite of tests is provided to ensure @@ -62,6 +65,9 @@ server, and to handle the replies (putting them in useful Go data structures). ## Documentation +[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)] +(http://godoc.org/github.com/btcsuite/btcjson) + Full `go doc` style documentation for the project can be viewed online without installing this package by using the GoDoc site [here](http://godoc.org/github.com/btcsuite/btcjson). diff --git a/goclean.sh b/goclean.sh new file mode 100755 index 00000000..f0512e77 --- /dev/null +++ b/goclean.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# The script does automatic checking on a Go package and its sub-packages, including: +# 1. gofmt (http://golang.org/cmd/gofmt/) +# 2. goimports (https://github.com/bradfitz/goimports) +# 3. golint (https://github.com/golang/lint) +# 4. go vet (http://golang.org/cmd/vet) +# 5. race detector (http://blog.golang.org/race-detector) +# 6. test coverage (http://blog.golang.org/cover) + +set -e + +# Automatic checks +cd v2/btcjson +test -z "$(gofmt -l -w . | tee /dev/stderr)" +test -z "$(goimports -l -w . | tee /dev/stderr)" +test -z "$(golint . | tee /dev/stderr)" +go vet ./... +go test -race ./... + +# Run test coverage on each subdirectories and merge the coverage profile. + +echo "mode: count" > profile.cov + +# Standard go tooling behavior is to ignore dirs with leading underscors +for dir in $(find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -type d); +do +if ls $dir/*.go &> /dev/null; then + go test -covermode=count -coverprofile=$dir/profile.tmp $dir + if [ -f $dir/profile.tmp ]; then + cat $dir/profile.tmp | tail -n +2 >> profile.cov + rm $dir/profile.tmp + fi +fi +done + +go tool cover -func profile.cov + +# To submit the test coverage result to coveralls.io, +# use goveralls (https://github.com/mattn/goveralls) +# goveralls -coverprofile=profile.cov -service=travis-ci