Skip to content

Add code formatting check to Travis CI build #54

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

Merged
merged 3 commits into from
Apr 8, 2019
Merged
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
38 changes: 34 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,34 @@ language: generic
env:
global:
- IDE_VERSION=1.8.9
matrix:
- BOARD="arduino:samd:mkr1000"
- BOARD="arduino:samd:mkrwifi1010"
- BOARD="arduino:samd:mkrgsm1400"
matrix:
include:
- env:
- BOARD="arduino:samd:mkr1000"
- env:
- BOARD="arduino:samd:mkrwifi1010"
- env:
- BOARD="arduino:samd:mkrgsm1400"
- env:
- NAME=Code Formatting Check
# must define an empty before_install phase, otherwise the default one is used
before_install: true
install:
# install Artistic Style code formatter tool: http://astyle.sourceforge.net
- |
mkdir "${HOME}/astyle";
wget --no-verbose --output-document="${HOME}/astyle/astyle.tar.gz" "https://iweb.dl.sourceforge.net/project/astyle/astyle/astyle%203.1/astyle_3.1_linux.tar.gz";
tar --extract --file="${HOME}/astyle/astyle.tar.gz" --directory="${HOME}/astyle";
cd "${HOME}/astyle/astyle/build/gcc";
make;
export PATH=$PWD/bin:$PATH;
cd "$TRAVIS_BUILD_DIR"
# download Arduino's Artistic Style configuration file
- wget --directory-prefix="${HOME}/astyle" https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples_formatter.conf
script:
# check code formatting
- find . -regextype posix-extended -path './.git' -prune -or \( -iregex '.*\.((ino)|(h)|(hpp)|(hh)|(hxx)|(h\+\+)|(cpp)|(cc)|(cxx)|(c\+\+)|(cp)|(c)|(ipp)|(ii)|(ixx)|(inl)|(tpp)|(txx)|(tpl))$' -and -type f \) -print0 | xargs -0 -L1 bash -c 'if ! diff $0 <(astyle --options=${HOME}/astyle/examples_formatter.conf --dry-run < $0); then echo "Non-compliant code formatting in $0"; false; fi'
# default phases
before_install:
- wget http://downloads.arduino.cc/arduino-$IDE_VERSION-linux64.tar.xz
- tar xf arduino-$IDE_VERSION-linux64.tar.xz
Expand All @@ -31,4 +55,10 @@ script:
- buildExampleSketch ArduinoIoTCloud_LED_switch
- buildExampleSketch ArduinoIoTCloud_Travis_CI
- buildExampleUtilitySketch Provisioning
notifications:
webhooks:
urls:
- https://www.travisbuddy.com/
on_success: never
on_failure: always

Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ void setup() {
// tell ArduinoIoTCloud to use our WiFi connection
ArduinoCloud.begin(ArduinoIoTPreferredConnection);

/*
The following function allows you to obtain more information
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you'll get.
The default is 0 (only errors).
Maximum is 3

setDebugMessageLevel(3);
*/
ArduinoCloud.printDebugInfo();
Expand Down
8 changes: 4 additions & 4 deletions examples/ArduinoIoTCloud_LED_switch/arduino_secrets.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
Fill in your login credentials:
Fill in your login credentials:

The following lines are used for WiFi enabled boards (MKR1000, MKR WiFi 1010)
The following lines are used for WiFi enabled boards (MKR1000, MKR WiFi 1010)
*/
#define SECRET_SSID "YOUR_WIFI_NETWORK_NAME"
#define SECRET_PASS "YOUR_WIFI_PASSWORD"
/*
If you prefer using a MKR GSM 1400 comment the lines above and uncommet the following.
PIN, APN, Login and Password are supplied by your Cellular Data provider.
If you prefer using a MKR GSM 1400 comment the lines above and uncommet the following.
PIN, APN, Login and Password are supplied by your Cellular Data provider.
*/
#define SECRET_PIN ""
#define SECRET_APN ""
Expand Down
6 changes: 3 additions & 3 deletions examples/ArduinoIoTCloud_LED_switch/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <WiFiConnectionManager.h>
#elif defined(BOARD_HAS_GSM)
#include <GSMConnectionManager.h>
#else
#else
#error "Arduino IoT Cloud currently only supports MKR1000, MKR WiFi 1010 and MKR GSM 1400"
#endif

Expand All @@ -25,9 +25,9 @@ void initProperties() {
}

#if defined(BOARD_HAS_WIFI)
ConnectionManager * ArduinoIoTPreferredConnection = new WiFiConnectionManager(SECRET_SSID, SECRET_PASS);
ConnectionManager * ArduinoIoTPreferredConnection = new WiFiConnectionManager(SECRET_SSID, SECRET_PASS);
#elif defined(BOARD_HAS_GSM)
ConnectionManager * ArduinoIoTPreferredConnection = new GSMConnectionManager (SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
ConnectionManager * ArduinoIoTPreferredConnection = new GSMConnectionManager(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
#endif


Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* This sketch is used in combination with Travis CI to check if
* unintentional breaking changes are made to the used facing
* Arduino IoT Cloud API.
*/
This sketch is used in combination with Travis CI to check if
unintentional breaking changes are made to the used facing
Arduino IoT Cloud API.
*/

#include "arduino_secrets.h"
#include "thingProperties.h"
Expand Down
52 changes: 26 additions & 26 deletions examples/ArduinoIoTCloud_Travis_CI/thingProperties.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
* INCLUDE
INCLUDE
******************************************************************************/

#include <ArduinoIoTCloud.h>
Expand All @@ -9,25 +9,25 @@
#include <WiFiConnectionManager.h>
#elif defined(BOARD_HAS_GSM)
#include <GSMConnectionManager.h>
#else
#else
#error "Arduino IoT Cloud currently only supports MKR1000, MKR WiFi 1010 and MKR GSM 1400"
#endif

/******************************************************************************
* DEFINES
DEFINES
******************************************************************************/

#define THING_ID "ARDUINO_IOT_CLOUD_THING_ID"

/******************************************************************************
* GLOBAL CONSTANTS
GLOBAL CONSTANTS
******************************************************************************/

int const MIN_DELTA_INT_PROPERTY = 5;
float const MIN_DELTA_FLOAT_PROPERTY = 10.0f;

/******************************************************************************
* GLOBAL VARIABLES
GLOBAL VARIABLES
******************************************************************************/

bool bool_property_1;
Expand Down Expand Up @@ -55,36 +55,36 @@ String str_property_7;
String str_property_8;

#if defined(BOARD_HAS_WIFI)
ConnectionManager * ArduinoIoTPreferredConnection = new WiFiConnectionManager(SECRET_SSID, SECRET_PASS);
ConnectionManager * ArduinoIoTPreferredConnection = new WiFiConnectionManager(SECRET_SSID, SECRET_PASS);
#elif defined(BOARD_HAS_GSM)
ConnectionManager * ArduinoIoTPreferredConnection = new GSMConnectionManager (SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
ConnectionManager * ArduinoIoTPreferredConnection = new GSMConnectionManager(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
#endif

/******************************************************************************
* PROTOTYPES
PROTOTYPES
******************************************************************************/

void onBoolPropertyChange ();
void onIntPropertyChange ();
void onFloatPropertyChange ();
void onBoolPropertyChange();
void onIntPropertyChange();
void onFloatPropertyChange();
void onStringPropertyChange();

/******************************************************************************
* FUNCTIONS
FUNCTIONS
******************************************************************************/

void initProperties() {
ArduinoCloud.setThingId(THING_ID);

ArduinoCloud.addProperty(bool_property_1, READWRITE, 1*SECONDS);
ArduinoCloud.addProperty(int_property_1, READ, 2*MINUTES);
ArduinoCloud.addProperty(float_property_1, WRITE, 3*HOURS );
ArduinoCloud.addProperty(str_property_1, READWRITE, 4*DAYS );
ArduinoCloud.addProperty(bool_property_1, READWRITE, 1 * SECONDS);
ArduinoCloud.addProperty(int_property_1, READ, 2 * MINUTES);
ArduinoCloud.addProperty(float_property_1, WRITE, 3 * HOURS);
ArduinoCloud.addProperty(str_property_1, READWRITE, 4 * DAYS);

ArduinoCloud.addProperty(bool_property_2, Permission::ReadWrite).publishEvery(1*SECONDS);
ArduinoCloud.addProperty(int_property_2, Permission::Read ).publishEvery(1*MINUTES);
ArduinoCloud.addProperty(float_property_2, Permission::Write ).publishEvery(3*HOURS );
ArduinoCloud.addProperty(str_property_2, Permission::ReadWrite).publishEvery(4*DAYS );
ArduinoCloud.addProperty(bool_property_2, Permission::ReadWrite).publishEvery(1 * SECONDS);
ArduinoCloud.addProperty(int_property_2, Permission::Read).publishEvery(1 * MINUTES);
ArduinoCloud.addProperty(float_property_2, Permission::Write).publishEvery(3 * HOURS);
ArduinoCloud.addProperty(str_property_2, Permission::ReadWrite).publishEvery(4 * DAYS);

ArduinoCloud.addProperty(int_property_3, READWRITE, ON_CHANGE); /* Default 'minDelta' = 0 */
ArduinoCloud.addProperty(int_property_4, READWRITE, ON_CHANGE, onIntPropertyChange); /* Default 'minDelta' = 0 */
Expand All @@ -94,11 +94,11 @@ void initProperties() {
ArduinoCloud.addProperty(float_property_3, Permission::ReadWrite).publishOnChange(MIN_DELTA_FLOAT_PROPERTY);
ArduinoCloud.addProperty(float_property_4, Permission::ReadWrite).publishOnChange(MIN_DELTA_FLOAT_PROPERTY).onUpdate(onFloatPropertyChange);

ArduinoCloud.addProperty(str_property_3, READWRITE, 1*SECONDS, 0 /* onStringPropertyChange */, "" /* 'minDelta' */, MOST_RECENT_WINS);
ArduinoCloud.addProperty(str_property_4, READWRITE, 1*SECONDS, 0 /* onStringPropertyChange */, "" /* 'minDelta' */, CLOUD_WINS);
ArduinoCloud.addProperty(str_property_5, READWRITE, 1*SECONDS, 0 /* onStringPropertyChange */, "" /* 'minDelta' */, DEVICE_WINS);
ArduinoCloud.addProperty(str_property_3, READWRITE, 1 * SECONDS, 0 /* onStringPropertyChange */, "" /* 'minDelta' */, MOST_RECENT_WINS);
ArduinoCloud.addProperty(str_property_4, READWRITE, 1 * SECONDS, 0 /* onStringPropertyChange */, "" /* 'minDelta' */, CLOUD_WINS);
ArduinoCloud.addProperty(str_property_5, READWRITE, 1 * SECONDS, 0 /* onStringPropertyChange */, "" /* 'minDelta' */, DEVICE_WINS);

ArduinoCloud.addProperty(str_property_6, Permission::ReadWrite).publishEvery(1*SECONDS).onSync(MOST_RECENT_WINS);
ArduinoCloud.addProperty(str_property_7, Permission::ReadWrite).publishEvery(1*SECONDS).onSync(CLOUD_WINS);
ArduinoCloud.addProperty(str_property_8, Permission::ReadWrite).publishEvery(1*SECONDS).onSync(DEVICE_WINS);
ArduinoCloud.addProperty(str_property_6, Permission::ReadWrite).publishEvery(1 * SECONDS).onSync(MOST_RECENT_WINS);
ArduinoCloud.addProperty(str_property_7, Permission::ReadWrite).publishEvery(1 * SECONDS).onSync(CLOUD_WINS);
ArduinoCloud.addProperty(str_property_8, Permission::ReadWrite).publishEvery(1 * SECONDS).onSync(DEVICE_WINS);
}
2 changes: 1 addition & 1 deletion examples/utility/Provisioning/Provisioning.ino
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void setup() {
hexStringToBytes(serialNumber, serialNumberBytes, sizeof(serialNumberBytes));
hexStringToBytes(authorityKeyIdentifier, authorityKeyIdentifierBytes, sizeof(authorityKeyIdentifierBytes));
hexStringToBytes(signature, signatureBytes, sizeof(signatureBytes));

if (!ECCX08.writeSlot(deviceIdSlot, deviceIdBytes, sizeof(deviceIdBytes))) {
Serial.println("Error storing device id!");
while (1);
Expand Down
Loading