Skip to content

Add Travis Continuous Integration to the repo #12

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

Closed
wants to merge 17 commits into from
Closed
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
87 changes: 87 additions & 0 deletions .travis-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash

# This script is triggered from the script section of .travis.yml
# It runs the appropriate commands depending on the task requested.

set -e

CPP_LINT_URL="https://raw.githubusercontent.com/google/styleguide/gh-pages/cpplint/cpplint.py";

# Libmodbus spelling tested and should be fixed upstream
SPELLINGBLACKLIST=$(cat <<-BLACKLIST
-wholename "./.codespellignore" -or \
-wholename "./.git/*" -or \
-wholename "./src/libmodbus/*"
BLACKLIST
)

if [[ $TASK = 'lint' ]]; then
# run the lint tool only if it is the requested task
# first check we've not got any generic NOLINTs
# count the number of generic NOLINTs
nolints=$(grep -IR NOLINT * | grep -v "NOLINT(" | wc -l)
if [[ $nolints -ne 0 ]]; then
# print the output for info
echo $(grep -IR NOLINT * | grep -v "NOLINT(")
echo "Found $nolints generic NOLINTs"
exit 1;
else
echo "Found $nolints generic NOLINTs"
fi;
# then fetch and run the main cpplint tool
wget -O cpplint.py $CPP_LINT_URL;
chmod u+x cpplint.py;
./cpplint.py \
--filter=-legal/copyright,-readability/streams,-runtime/arrays \
$(find ./ \( -name "*.h" -or -name "*.cpp" \) | xargs)
if [[ $? -ne 0 ]]; then
exit 1;
fi;
elif [[ $TASK = 'spellintian' ]]; then
# run spellintian only if it is the requested task, ignoring duplicate words
spellingfiles=$(eval "find ./ -type f -and ! \( \
$SPELLINGBLACKLIST \
\) | xargs")
# count the number of spellintian errors, ignoring duplicate words
spellingerrors=$(zrun spellintian $spellingfiles 2>&1 | grep -v "\(duplicate word\)" | wc -l)
if [[ $spellingerrors -ne 0 ]]; then
# print the output for info
zrun spellintian $spellingfiles | grep -v "\(duplicate word\)"
echo "Found $spellingerrors spelling errors via spellintian, ignoring duplicates"
exit 1;
else
echo "Found $spellingerrors spelling errors via spellintian, ignoring duplicates"
fi;
elif [[ $TASK = 'spellintian-duplicates' ]]; then
# run spellintian only if it is the requested task
spellingfiles=$(eval "find ./ -type f -and ! \( \
$SPELLINGBLACKLIST \
\) | xargs")
# count the number of spellintian errors
spellingerrors=$(zrun spellintian $spellingfiles 2>&1 | wc -l)
if [[ $spellingerrors -ne 0 ]]; then
# print the output for info
zrun spellintian $spellingfiles
echo "Found $spellingerrors spelling errors via spellintian"
exit 1;
else
echo "Found $spellingerrors spelling errors via spellintian"
fi;
elif [[ $TASK = 'codespell' ]]; then
# run codespell only if it is the requested task
spellingfiles=$(eval "find ./ -type f -and ! \( \
$SPELLINGBLACKLIST \
\) | xargs")
# count the number of codespell errors
spellingerrors=$(zrun codespell --check-filenames --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" -L ser $spellingfiles 2>&1 | wc -l)
if [[ $spellingerrors -ne 0 ]]; then
# print the output for info
zrun codespell --check-filenames --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" -L ser $spellingfiles
echo "Found $spellingerrors spelling errors via codespell"
exit 1;
else
echo "Found $spellingerrors spelling errors via codespell"
fi;
else
platformio ci --lib="." --board=$BOARD
fi
101 changes: 101 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
language: python
python:
- "2.7"

os: linux
dist: trusty
# Short duration job, use the container/without sudo image as it boots faster
sudo: false
# Use the latest Travis images since they are more up to date than the stable release.
group: edge

before_cache:
- rm -f $HOME/.cache/pip/log/debug.log # erase log

cache:
directories:
- "~/.platformio"
- $HOME/.cache/pip # pip cache

env:
global:
# Warnings are errors
- PLATFORMIO_BUILD_FLAGS="-Werror -Wno-error=deprecated-declarations"

matrix:
fast_finish: true
include:
- env: BOARD=uno PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUClientKitchenSink
- env: BOARD=uno PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUClientToggle
- env: BOARD=uno PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUServerKitchenSink
- env: BOARD=uno PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUServerLED
- env: BOARD=uno PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUTemperatureSensor

- env: BOARD=diecimilaatmega328 PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUClientKitchenSink
- env: BOARD=diecimilaatmega328 PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUClientToggle
- env: BOARD=diecimilaatmega328 PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUServerKitchenSink
- env: BOARD=diecimilaatmega328 PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUServerLED
- env: BOARD=diecimilaatmega328 PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUTemperatureSensor

- env: BOARD=pro16MHzatmega328 PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUClientKitchenSink
- env: BOARD=pro16MHzatmega328 PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUClientToggle
- env: BOARD=pro16MHzatmega328 PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUServerKitchenSink
- env: BOARD=pro16MHzatmega328 PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUServerLED
- env: BOARD=pro16MHzatmega328 PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUTemperatureSensor

- env: BOARD=due PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUClientKitchenSink
- env: BOARD=due PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUClientToggle
- env: BOARD=due PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUServerKitchenSink
- env: BOARD=due PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUServerLED
- env: BOARD=due PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUTemperatureSensor

- env: BOARD=mkrwifi1010 PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUClientKitchenSink
- env: BOARD=mkrwifi1010 PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUClientToggle
- env: BOARD=mkrwifi1010 PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUServerKitchenSink
- env: BOARD=mkrwifi1010 PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUServerLED
- env: BOARD=mkrwifi1010 PLATFORMIO_CI_SRC=examples/RTU/ModbusRTUTemperatureSensor
- env: BOARD=mkrwifi1010 PLATFORMIO_CI_SRC=examples/TCP/WiFiModbusClientToggle
- env: BOARD=mkrwifi1010 PLATFORMIO_CI_SRC=examples/TCP/WiFiModbusServerLED

- os: linux
dist: trusty
# Short duration job, would use the container/without sudo image as it boots faster, but we need a backported lintian, so don't
sudo: required
env: TASK='spellintian'
addons:
apt:
packages:
- moreutils
- os: linux
dist: trusty
# Short duration job, would use the container/without sudo image as it boots faster, but we need a backported lintian, so don't
sudo: required
env: TASK='spellintian-duplicates'
addons:
apt:
packages:
- moreutils
- os: linux
dist: trusty
env: TASK='codespell'
addons:
apt:
packages:
- moreutils

allow_failures:
- os: linux
dist: trusty
env: TASK='spellintian-duplicates'

before_install:
- if [ "$TASK" == "spellintian" -o "$TASK" == "spellintian-duplicates" ]; then sudo add-apt-repository ppa:waja/trusty-backports -y; sudo apt-get update -qq; sudo apt-get install lintian -y; fi # Install a late enough lintian

install:
- if [ -z "$TASK" ]; then pip install --upgrade platformio; fi
- if [ -z "$TASK" ]; then platformio lib install "ArduinoRS485"; fi
- if [ -z "$TASK" -a "$BOARD" == "mkrwifi1010" ]; then platformio lib install "WiFiNINA"; fi
- if [ "$TASK" = "codespell" ]; then pip install --upgrade git+https://github.com/codespell-project/codespell.git; fi

script:
- bash -ex .travis-ci.sh
3 changes: 3 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[caption="Build Status",link=https://travis-ci.com/arduino-libraries/ArduinoModbus]
image::https://travis-ci.com/arduino-libraries/ArduinoModbus.svg?branch=master[Build Status]

= Modbus Library for Arduino =

Use http://www.modbus.org/[Modbus] with your Arduino.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Modbus RTU Client Kitchen Sink

This sketch creates a Modbus RTU Client and demostrates
This sketch creates a Modbus RTU Client and demonstrates
how to use various Modbus Client APIs.

Circuit:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Modbus RTU Server Kitchen Sink

This sketch creates a Modbus RTU Server and demostrates
This sketch creates a Modbus RTU Server and demonstrates
how to use various Modbus Server APIs.

Circuit:
Expand Down