Skip to content
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

Build and check the examples using Travis CI #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ for the book, "The Go Programming Language"; see http://www.gopl.io.
These example programs are licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br/>
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png"/></a>

### *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
Expand Down
56 changes: 56 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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