Skip to content

Commit

Permalink
Add Travis CI config and test coverage script
Browse files Browse the repository at this point in the history
  • Loading branch information
jtblin committed Jun 24, 2017
1 parent 6444d9a commit 12fa75c
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ _testmain.go
# Created by .ignore support plugin (hsz.mobi)

/build/
coverage.out
/vendor/
34 changes: 34 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
sudo: required

language: go

services:
- docker

go:
- 1.8.x

os:
- linux

before_install:
- go get -v github.com/mattn/goveralls

install:
- make setup

script:
- make build
- make test-race
- make check
- make bench-race
- make coveralls

after_success:
- if [ "$TRAVIS_OS_NAME" == "linux" -a ! -z "$TRAVIS_TAG" ]; then
echo "Executing release on tag build $TRAVIS_TAG";
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
make release;
else
echo "Not executing release on non-tag build";
fi
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ DOCKER_REPO ?= jtblin
IMAGE_NAME := $(DOCKER_REPO)/$(BINARY_NAME)
ARCH ?= darwin
METALINTER_CONCURRENCY ?= 4
METALINTER_DEADLINE ?= 180
# useful for passing --build-arg http_proxy :)
DOCKER_BUILD_FLAGS :=

Expand All @@ -21,6 +22,7 @@ setup:
go get -v -u github.com/githubnemo/CompileDaemon
go get -v -u github.com/alecthomas/gometalinter
go get -v -u github.com/jstemmer/go-junit-report
go get -v github.com/mattn/goveralls
gometalinter --install --update
glide install --strip-vendor

Expand Down Expand Up @@ -63,7 +65,7 @@ junit-test: build

check:
go install ./cmd
gometalinter --concurrency=$(METALINTER_CONCURRENCY) --deadline=180s ./... --vendor --linter='errcheck:errcheck:-ignore=net:Close' --cyclo-over=20 \
gometalinter --concurrency=$(METALINTER_CONCURRENCY) --deadline=$(METALINTER_DEADLINE)s ./... --vendor --linter='errcheck:errcheck:-ignore=net:Close' --cyclo-over=20 \
--linter='vet:go tool vet -composites=false {paths}:PATH:LINE:MESSAGE' --disable=interfacer --dupl-threshold=50

check-all:
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
[![Build Status](https://travis-ci.org/jtblin/kube2iam.svg?branch=master)](https://travis-ci.org/jtblin/kube2iam)
[![GitHub tag](https://img.shields.io/github/tag/jtblin/kube2iam.svg?maxAge=86400)](https://github.com/atlassian/gostatsd)
[![Docker Pulls](https://img.shields.io/docker/pulls/jtblin/kube2iam.svg)]()
[![Go Report Card](https://goreportcard.com/badge/github.com/jtblin/kube2iam)](https://goreportcard.com/report/github.com/jtblin/kube2iam)
[![license](https://img.shields.io/github/license/jtblin/kube2iam.svg)](https://github.com/jtblin/kube2iam/blob/master/LICENSE)

# kube2iam

Expand Down
35 changes: 35 additions & 0 deletions cover.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

function die() {
echo $*
exit 1
}

# Initialize coverage.out
echo "mode: count" > coverage.out

# Initialize error tracking
ERROR=""

declare -a packages=('' \
'cmd' \
'iam' \
'iptables' \
'k8s' \
'server' \
'store' \
'version');

# Test each package and append coverage profile info to coverage.out
for pkg in "${packages[@]}"
do
go test -v -covermode=count -coverprofile=coverage_tmp.out "github.com/jtblin/kube2iam/$pkg" || ERROR="Error testing $pkg"
tail -n +2 coverage_tmp.out >> coverage.out 2> /dev/null ||:
done

rm -f coverage_tmp.out

if [ ! -z "$ERROR" ]
then
die "Encountered error, last error was: $ERROR"
fi

0 comments on commit 12fa75c

Please sign in to comment.