diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..375db15fd --- /dev/null +++ b/.travis.yml @@ -0,0 +1,24 @@ +language: go +dist: trusty + +go: + - 1.6.x + - 1.7.x + - 1.8.x + - master + +before_install: + - sudo apt-get -qq update + - sudo apt-get install -y libbz2-dev + +install: + - ./build.sh + - go clean + +before_script: + - go vet ./... + +script: + #- go test -v ./... + - echo + diff --git a/README.md b/README.md index 2be13ea19..e693993fc 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ for the book, "The Go Programming Language"; see http://www.gopl.io. These example programs are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Creative Commons License +### *Examples* [![Build Status](https://travis-ci.org/claudioandre/gopl.io.svg)](https://travis-ci.org/claudioandre/gopl.io) + You can download, build, and run the programs with the following commands: $ export GOPATH=$HOME/gobook # choose workspace directory diff --git a/build.sh b/build.sh new file mode 100755 index 000000000..103b8387b --- /dev/null +++ b/build.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +function do_Test(){ + + #echo "gopl.io/$1/$2" + cd ../.. + go get ./$1/$2 + ret_code=$? + cd - + + if [[ $ret_code -ne 0 ]]; then + echo "ERROR ($ret_code): $1/$2" + echo + Total_Erros=$((Total_Erros + 1)) + fi + Total_Tests=$((Total_Tests + 1)) +} + +#----------- Init ----------- +Total_Tests=0 +Total_Erros=0 + +#cd src/gopl.io +#export GOPATH=$(pwd) + +for chapter in *; do + if [[ -d $chapter ]]; then + echo "-- Compiling examples of $chapter..." + cd $chapter + + for topic in *; do + if [[ -d $topic ]]; then + echo " ==> building $topic..." + cd $topic + do_Test $chapter $topic + fi + cd .. + done + cd .. + fi +done + +#----------- The End ----------- +echo +if [ $Total_Erros -eq 0 ]; then + echo '--------------------------------------------------------------------------------' + echo "All tests passed without error! Performed $Total_Tests tests in $SECONDS seconds." + echo '--------------------------------------------------------------------------------' + exit 0 +else + echo '--------------------------------------------------------------------------------' + echo "$Total_Erros tests FAILED! Performed $Total_Tests tests in $SECONDS seconds." + echo '--------------------------------------------------------------------------------' + exit 1 +fi +