-
Notifications
You must be signed in to change notification settings - Fork 3
travis: add testing #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
sudo: false | ||
|
||
language: go | ||
|
||
# Do not move these lines; they are referred to by README.md. | ||
# Versions of go that are explicitly supported by gonum plus go tip. | ||
go: | ||
- 1.8.x | ||
- 1.9.x | ||
- 1.10.x | ||
- master | ||
|
||
matrix: | ||
fast_finish: true | ||
allow_failures: | ||
- go: master | ||
|
||
before_install: | ||
# Required for format check. | ||
- go get golang.org/x/tools/cmd/goimports | ||
# Required for coverage. | ||
- go get golang.org/x/tools/cmd/cover | ||
- go get github.com/mattn/goveralls | ||
|
||
go_import_path: gonum.org/v1/tools | ||
|
||
# Get deps, build, test, and ensure the code is gofmt'ed. | ||
# If we are building as gonum, then we have access to the coveralls api key, so we can run coverage as well. | ||
script: | ||
- ${TRAVIS_BUILD_DIR}/.travis/check-formatting.sh | ||
- go get -d -t -v ./... | ||
- go build -v ./... | ||
- if [[ $TRAVIS_SECURE_ENV_VARS = "true" ]]; then bash ./.travis/test-coverage.sh; fi | ||
- ${TRAVIS_BUILD_DIR}/.travis/check-imports.sh | ||
# This is run last since it alters the tree. | ||
- ${TRAVIS_BUILD_DIR}/.travis/check-generate.sh | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
test -z "$(goimports -d .)" | ||
if [[ -n "$(gofmt -s -l .)" ]]; then | ||
echo -e '\e[31mCode not gofmt simplified in:\n\n' | ||
gofmt -s -l . | ||
echo -e "\e[0" | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
# Add any go generate invocations below this line. | ||
|
||
|
||
if [ -n "$(git diff)" ]; then | ||
git diff | ||
exit 1 | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
check-imports -b "math/rand,github.com/gonum/.*" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is actually something that could be rewritten in Go and put as a standalone command in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. File an issue for that? It can live here and be used Gonum-wide. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done: #5 |
||
|
||
PROFILE_OUT=$PWD/profile.out | ||
ACC_OUT=$PWD/acc.out | ||
|
||
testCover() { | ||
# set the return value to 0 (succesful) | ||
retval=0 | ||
# get the directory to check from the parameter. Default to '.' | ||
d=${1:-.} | ||
# skip if there are no Go files here | ||
ls $d/*.go &> /dev/null || return $retval | ||
# switch to the directory to check | ||
pushd $d > /dev/null | ||
# create the coverage profile | ||
coverageresult=`go test -v $TAGS -coverprofile=$PROFILE_OUT` | ||
# output the result so we can check the shell output | ||
echo ${coverageresult} | ||
# append the results to acc.out if coverage didn't fail, else set the retval to 1 (failed) | ||
( [[ ${coverageresult} == *FAIL* ]] && retval=1 ) || ( [ -f $PROFILE_OUT ] && grep -v "mode: set" $PROFILE_OUT >> $ACC_OUT ) | ||
# return to our working dir | ||
popd > /dev/null | ||
# return our return value | ||
return $retval | ||
} | ||
|
||
# Init acc.out | ||
echo "mode: set" > $ACC_OUT | ||
|
||
# Run test coverage on all directories containing go files. | ||
find . -type d | while read d; do testCover $d || exit; done | ||
|
||
# Upload the coverage profile to coveralls.io | ||
[ -n "$COVERALLS_TOKEN" ] && goveralls -coverprofile=$ACC_OUT -service=travis-ci -repotoken $COVERALLS_TOKEN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably not needed ATM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave this one here though.