Skip to content

Commit 1a8d494

Browse files
per1234aentinger
authored andcommitted
Add code formatting check to Travis CI build
Check compliance with the code style standard established by Arduino's examples_formatter.conf Artistic Style configuration file: https://github.com/arduino/Arduino/blob/master/build/shared/examples_formatter.conf If the code doesn not comply with the standard, a diff between the submitted code and the auto-formatted code is shown in the log. I did some reorganization of .travis.yml so that the formatting check was done in a single dedicated Travis CI job, rather than redundantly in every one of the jobs.
1 parent 1673ae4 commit 1a8d494

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

.travis.yml

+28-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,34 @@ language: generic
22
env:
33
global:
44
- IDE_VERSION=1.8.9
5-
matrix:
6-
- BOARD="arduino:samd:mkr1000"
7-
- BOARD="arduino:samd:mkrwifi1010"
8-
- BOARD="arduino:samd:mkrgsm1400"
5+
matrix:
6+
include:
7+
- env:
8+
- BOARD="arduino:samd:mkr1000"
9+
- env:
10+
- BOARD="arduino:samd:mkrwifi1010"
11+
- env:
12+
- BOARD="arduino:samd:mkrgsm1400"
13+
- env:
14+
- NAME=Code Formatting Check
15+
# must define an empty before_install phase, otherwise the default one is used
16+
before_install: true
17+
install:
18+
# install Artistic Style code formatter tool: http://astyle.sourceforge.net
19+
- |
20+
mkdir "${HOME}/astyle";
21+
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";
22+
tar --extract --file="${HOME}/astyle/astyle.tar.gz" --directory="${HOME}/astyle";
23+
cd "${HOME}/astyle/astyle/build/gcc";
24+
make;
25+
export PATH=$PWD/bin:$PATH;
26+
cd "$TRAVIS_BUILD_DIR"
27+
# download Arduino's Artistic Style configuration file
28+
- wget --directory-prefix="${HOME}/astyle" https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples_formatter.conf
29+
script:
30+
# check code formatting
31+
- 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'
32+
# default phases
933
before_install:
1034
- wget http://downloads.arduino.cc/arduino-$IDE_VERSION-linux64.tar.xz
1135
- tar xf arduino-$IDE_VERSION-linux64.tar.xz

0 commit comments

Comments
 (0)