mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Check code style as part of the CI tests
If checkpatch.pl detects any ERROR in the new patches, the Travis CI build will fail. Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
48
.travis-checkpatch.sh
Executable file
48
.travis-checkpatch.sh
Executable file
@@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Checking code style..."
|
||||||
|
|
||||||
|
# Return failure as soon as a command fails to execute
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Download checkpatch.pl and related files
|
||||||
|
|
||||||
|
echo "Getting checkpatch.pl..."
|
||||||
|
|
||||||
|
mkdir checkpatchdir
|
||||||
|
|
||||||
|
wget https://raw.githubusercontent.com/torvalds/linux/master/scripts/checkpatch.pl
|
||||||
|
mv checkpatch.pl checkpatchdir/checkpatch.pl
|
||||||
|
chmod +x checkpatchdir/checkpatch.pl
|
||||||
|
|
||||||
|
touch checkpatchdir/const_structs.checkpatch
|
||||||
|
touch checkpatchdir/spelling.txt
|
||||||
|
|
||||||
|
# Run checkpatch.pl on the new commits
|
||||||
|
|
||||||
|
echo "Running checkpatch.pl..."
|
||||||
|
|
||||||
|
fname=$(mktemp)
|
||||||
|
rc=0
|
||||||
|
|
||||||
|
git remote set-branches --add origin develop
|
||||||
|
git fetch
|
||||||
|
|
||||||
|
make CHECKPATCH=checkpatchdir/checkpatch.pl checkpatch > $fname
|
||||||
|
|
||||||
|
cat $fname
|
||||||
|
|
||||||
|
if grep "ERROR" $fname; then
|
||||||
|
# At least one error found
|
||||||
|
echo "Code style errors have been found!"
|
||||||
|
rc=1
|
||||||
|
else
|
||||||
|
echo "No code style errors found, your patches are ready!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
|
||||||
|
rm -rf checkpatchdir
|
||||||
|
|
||||||
|
exit $rc
|
||||||
@@ -10,5 +10,6 @@ compiler:
|
|||||||
- clang
|
- clang
|
||||||
- gcc
|
- gcc
|
||||||
script:
|
script:
|
||||||
|
- ./.travis-checkpatch.sh
|
||||||
- cd test
|
- cd test
|
||||||
- ./run-tests.sh
|
- ./run-tests.sh
|
||||||
|
|||||||
Reference in New Issue
Block a user