Skip to content

Commit

Permalink
Adding coveralls (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreybauduin authored Sep 2, 2017
1 parent 5e0f415 commit 8ef410b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.idea
coverage.out
coverage_tmp.out
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ install:
- go get github.com/mattn/go-sqlite3
- go get github.com/lib/pq
- go get github.com/go-sql-driver/mysql
- go get golang.org/x/tools/cmd/cover
- go get github.com/mattn/goveralls
- go install github.com/mattn/goveralls
env:
- DB=sqlite
- DB=mysql DSN="travis:@/test?parseTime=true"
- DB=postgres DSN=postgres://postgres:@/test
before_script:
- sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'DROP DATABASE test;' -U postgres; psql -c 'CREATE DATABASE test;' -U postgres; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'DROP DATABASE test;' ; mysql -e 'CREATE DATABASE test;'; mysql -e \"GRANT ALL PRIVILEGES ON test.* TO 'travis'@'%';\"; fi"
script: make test
script: make testwithcoverage
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ test:
go test -v -timeout=1200s `go list ./... | grep -v vendor` $(filter-out $@,$(MAKECMDGOALS))

vendor:
mv _vendor vendor ; govendor add $(filter-out $@,$(MAKECMDGOALS)) ; mv vendor _vendor
mv _vendor vendor ; govendor add $(filter-out $@,$(MAKECMDGOALS)) ; mv vendor _vendor

testwithcoverage:
ROOT_DIR=$(ROOT_DIR) ./test-coverage.sh $(filter-out $@,$(MAKECMDGOALS))
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Build Status](https://travis-ci.org/geoffreybauduin/yaorm.svg?branch=master)](https://travis-ci.org/geoffreybauduin/yaorm)
[![Go Report Card](https://goreportcard.com/badge/github.com/geoffreybauduin/yaorm)](https://goreportcard.com/report/github.com/geoffreybauduin/yaorm)
[![Coverage Status](https://coveralls.io/repos/github/geoffreybauduin/yaorm/badge.svg?branch=master)](https://coveralls.io/github/geoffreybauduin/yaorm?branch=master)

This is another ORM. Another one.

Expand Down
13 changes: 13 additions & 0 deletions test-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

rm -f $ROOT_DIR/coverage.out
for pkg in $(go list ./... | grep -v vendor)
do
go test -v -cover -race -coverprofile=$ROOT_DIR/coverage_tmp.out -timeout=1200s $pkg $@
if [[ -f "$ROOT_DIR/coverage.out" ]]; then
tail -n +2 $ROOT_DIR/coverage_tmp.out >> $ROOT_DIR/coverage.out
else
cat $ROOT_DIR/coverage_tmp.out > $ROOT_DIR/coverage.out
fi
done
$GOPATH/bin/goveralls -coverprofile=$ROOT_DIR/coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN

0 comments on commit 8ef410b

Please sign in to comment.