Skip to content

Commit

Permalink
Merge pull request #63 from 4-20ma/55-add-ci-testing-with-travis
Browse files Browse the repository at this point in the history
55 add ci testing with travis
  • Loading branch information
4-20ma authored Sep 11, 2016
2 parents 7fbc328 + 9a07a91 commit 1094071
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 8 deletions.
17 changes: 9 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
language: c
before_install:
- export ARDUINO_VERSION=1.6.5
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16"
- sleep 3
- export DISPLAY=:1.0
- wget http://downloads.arduino.cc/arduino-1.6.5-linux64.tar.xz
- tar xf arduino-1.6.5-linux64.tar.xz
- sudo mv arduino-1.6.5 /usr/local/share/arduino
- wget http://downloads.arduino.cc/arduino-${ARDUINO_VERSION}-linux64.tar.xz
- tar xf arduino-${ARDUINO_VERSION}-linux64.tar.xz
- sudo mv arduino-${ARDUINO_VERSION} /usr/local/share/arduino
- sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino
install:
- ln -s $PWD /usr/local/share/arduino/libraries/ModbusMaster
- ln -s ${PWD} /usr/local/share/arduino/libraries/ModbusMaster
- arduino --pref "compiler.warning_level=all" --save-prefs
script:
- "echo $PWD"
- "echo $HOME"
- "ls $PWD"
- source $TRAVIS_BUILD_DIR/travis/common.sh
- echo $PWD
- echo $HOME
- ls -al $PWD
- source ${TRAVIS_BUILD_DIR}/travis/common.sh
- build_examples
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
ModbusMaster
============
[![Tag](https://img.shields.io/github/tag/4-20ma/ModbusMaster.svg)][Tag]
[![Travis](https://img.shields.io/travis/4-20ma/ModbusMaster.svg)][Travis]
[![License](https://img.shields.io/github/license/4-20ma/ModbusMaster.svg)][License]
[![Code of conduct](https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-blue.svg)][Code of conduct]

[Tag]: https:/4-20ma/ModbusMaster
[Travis]: https://travis-ci.org/4-20ma/ModbusMaster
[License]: COPYING
[Code of conduct]: https:/4-20ma/ModbusMaster/blob/master/CODE_OF_CONDUCT.md

Expand Down
51 changes: 51 additions & 0 deletions travis/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

function build_examples()
{
# track the exit code for this platform
local exit_code=0
# loop through results and add them to the array
examples=($(find $PWD/examples/ -name "*.pde" -o -name "*.ino"))

# get the last example in the array
local last="${examples[@]:(-1)}"

# loop through example sketches
for example in "${examples[@]}"; do

# store the full path to the example's sketch directory
local example_dir=$(dirname $example)

# store the filename for the example without the path
local example_file=$(basename $example)

echo "$example_file: "
local sketch="$example_dir/$example_file"
echo "$sketch"
#arduino -v --verbose-build --verify $sketch

# verify the example, and save stdout & stderr to a variable
# we have to avoid reading the exit code of local:
# "when declaring a local variable in a function, the local acts as a command in its own right"
local build_stdout
build_stdout=$(arduino --verify $sketch 2>&1)

# echo output if the build failed
if [ $? -ne 0 ]; then
# heavy X
echo -e "\xe2\x9c\x96"
echo -e "----------------------------- DEBUG OUTPUT -----------------------------\n"
echo "$build_stdout"
echo -e "\n------------------------------------------------------------------------\n"

# mark as fail
exit_code=1

else
# heavy checkmark
echo -e "\xe2\x9c\x93"
fi
done

return $exit_code
}

0 comments on commit 1094071

Please sign in to comment.