@@ -94,6 +94,45 @@ matrix:
94
94
# Report success since we have overridden default behaviour
95
95
- bash -c "$STATUS" success "Local $NAME testing has passed"
96
96
97
+ - env :
98
+ - NAME=astyle
99
+ install :
100
+ - wget https://downloads.sourceforge.net/project/astyle/astyle/astyle%203.1/astyle_3.1_linux.tar.gz;
101
+ mkdir -p BUILD && tar xf astyle_3.1_linux.tar.gz -C BUILD;
102
+ pushd BUILD/astyle/build/gcc;
103
+ make;
104
+ export PATH=$PWD/bin:$PATH;
105
+ popd;
106
+ - astyle --version
107
+ script :
108
+ # only changed files this time
109
+ - git diff --name-only $TRAVIS_BRANCH | grep '.*\.\(h\|c\|hpp\|cpp\)' | fgrep -v -f .astyleignore | xargs -n 100 -I {} bash -c "astyle -n --options=.astylerc \"{}\"" > astyle-files-changed.out;
110
+ if [ $(cat astyle-files-changed.out | grep Formatted | wc -l) -ne 0 ]; then
111
+ git --no-pager diff;
112
+ echo "Please fix style issues as shown above";
113
+ else
114
+ echo "Coding style check OK";
115
+ fi
116
+ after_success :
117
+ # run astyle for all files on the branch
118
+ - git checkout -- .
119
+ - find -regex '.*\.\(h\|c\|hpp\|cpp\)' -type f | fgrep -v -f .astyleignore | xargs -n 100 -I {} bash -c "astyle -n --options=.astylerc \"{}\"" > astyle-branch.out;
120
+ # update status if we succeeded, compare with master if possible
121
+ - |
122
+ CURR=$(cat astyle-branch.out | grep Formatted | wc -l)
123
+ PREV=$(curl https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
124
+ | jq -re "select(.sha != \"$TRAVIS_COMMIT\")
125
+ | .statuses[] | select(.context == \"travis-ci/$NAME\").description
126
+ | capture(\", (?<warnings>[0-9]+) warnings\").warnings" \
127
+ || echo 0)
128
+
129
+ STATUSM="Passed, ${CURR} warnings"
130
+ if [ "$PREV" -ne 0 ]
131
+ then
132
+ STATUSM="$STATUSM ($(python -c "print '%+d' % ($CURR-$PREV)") warnings)"
133
+ fi
134
+ - bash -c "$STATUS" success "$STATUSM"
135
+
97
136
- env :
98
137
- NAME=events
99
138
- EVENTS=events
0 commit comments