Skip to content

Commit 28a8b6d

Browse files
committed
Check code formatting compliance during the CI build
Use the Artistic Style formatting tool (also used for the Arduino IDE's auto format feature) to check all code files in the repository for compliance with the Arduino code formatting style.
1 parent e9278ba commit 28a8b6d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

.travis.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ matrix:
2828
install:
2929
- arduino-cli core install arduino:sam
3030

31+
# check all code files for compliance with the Arduino code formatting style
32+
- env:
33+
- NAME='Code Formatting Check'
34+
language: minimal
35+
before_install:
36+
# install Artistic Style code formatter tool: http://astyle.sourceforge.net
37+
- |
38+
mkdir "${HOME}/astyle";
39+
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";
40+
tar --extract --file="${HOME}/astyle/astyle.tar.gz" --directory="${HOME}/astyle";
41+
cd "${HOME}/astyle/astyle/build/gcc";
42+
make;
43+
export PATH="$PWD/bin:$PATH";
44+
cd "$TRAVIS_BUILD_DIR"
45+
# download Arduino's Artistic Style configuration file
46+
- wget --directory-prefix="${HOME}/astyle" https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples_formatter.conf
47+
script:
48+
# check code formatting
49+
- 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'
50+
3151
# default phases shared by the compilation tests
3252
before_install:
3353
- wget http://downloads.arduino.cc/arduino-cli/arduino-cli-$CLI_VERSION-linux64.tar.bz2

0 commit comments

Comments
 (0)