Merge pull request #4 from safing/feature/travis/setup

Setup Travis CI
This commit is contained in:
Daniel 2019-08-21 08:29:51 +02:00 committed by GitHub
commit 675397f692
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 6 deletions

18
.travis.yml Normal file
View file

@ -0,0 +1,18 @@
language: go
os:
- linux
- windows
branches:
only:
- master
- /^feature\/travis\/.+$/ # feature/travis/*
- /^fix\/travis\/.+$/ # fix/travis/*
install:
- go get -d -u github.com/golang/dep
- go install github.com/golang/dep/cmd/dep
- dep ensure
script: ./test --scripted

26
test
View file

@ -2,9 +2,13 @@
warnings=0 warnings=0
errors=0 errors=0
scripted=0
goUp="\\e[1A"
function run { function run {
echo "[......] $*" if [[ $scripted -eq 0 ]]; then
echo "[......] $*"
fi
# create tmpfile # create tmpfile
tmpfile=$(mktemp) tmpfile=$(mktemp)
@ -16,10 +20,10 @@ function run {
# check return code # check return code
if [[ $rc -eq 0 ]]; then if [[ $rc -eq 0 ]]; then
if [[ $output == *"[no test files]"* ]]; then if [[ $output == *"[no test files]"* ]]; then
echo -e "\e[1A[\e[01;33mNOTEST\e[00m] $*" echo -e "${goUp}[\e[01;33mNOTEST\e[00m] $*"
warnings=$((warnings+1)) warnings=$((warnings+1))
else else
echo -ne "\e[1A[\e[01;32m OK \e[00m] " echo -ne "${goUp}[\e[01;32m OK \e[00m] "
if [[ $2 == "test" ]]; then if [[ $2 == "test" ]]; then
echo -n $* echo -n $*
echo -n ": " echo -n ": "
@ -30,10 +34,9 @@ function run {
fi fi
else else
if [[ $output == *"build constraints exclude all Go files"* ]]; then if [[ $output == *"build constraints exclude all Go files"* ]]; then
echo -e "\e[1A[\e[01;33mNOTEST\e[00m] $*" echo -e "${goUp}[ !=OS ] $*"
warnings=$((warnings+1))
else else
echo -e "\e[1A[\e[01;31m FAIL \e[00m] $*" >/dev/stderr echo -e "${goUp}[\e[01;31m FAIL \e[00m] $*" >/dev/stderr
cat $tmpfile >/dev/stderr cat $tmpfile >/dev/stderr
errors=$((errors+1)) errors=$((errors+1))
fi fi
@ -46,9 +49,20 @@ function run {
baseDir="$( cd "$(dirname "$0")" && pwd )" baseDir="$( cd "$(dirname "$0")" && pwd )"
cd "$baseDir" cd "$baseDir"
# change output format if being run in script
if [[ $1 == "--scripted" ]]; then
scripted=1
goUp=""
fi
# platform info
platformInfo=$(go env GOOS GOARCH)
echo "running tests for ${platformInfo//$'\n'/ }:"
# get all packages # get all packages
packages=$(go list ./...) packages=$(go list ./...)
# run vet/test on packages
for package in $packages; do for package in $packages; do
run go vet $package run go vet $package
run go test -cover $package run go test -cover $package