Meta: Integrate Shellcheck into Travis

lint-shell-scripts searches over the repository looking for shell
scripts. On those found, shellcheck is run against them. If any linting
fails print those warnings and exit with a non-zero exit code.

Run this script automatically in Travis.
This commit is contained in:
Shannon Booth 2020-02-10 19:39:30 +13:00 committed by Andreas Kling
parent fe668db999
commit 084e67f267
Notes: sideshowbarker 2024-07-19 09:29:30 +09:00
2 changed files with 28 additions and 1 deletions

View file

@ -22,7 +22,7 @@ notifications:
before_install:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update -qq
- sudo apt-get install g++-8 libstdc++-8-dev
- sudo apt-get install g++-8 libstdc++-8-dev shellcheck
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 90
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 90
- sudo apt-get install -y libmpfr-dev libmpc-dev libgmp-dev
@ -33,3 +33,4 @@ script:
- ./BuildIt.sh
- cd ../Kernel
- ./makeall.sh
- ../Meta/lint-shell-scripts.sh

26
Meta/lint-shell-scripts.sh Executable file
View file

@ -0,0 +1,26 @@
#!/bin/bash
set -e pipefail
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
cd "$script_path/.."
ERRORS=()
for f in $(find . -path ./Root -prune -o \
-path ./Ports -prune -o \
-path ./.git -prune -o \
-path ./Toolchain -prune -o \
-type f | sort -u); do
if file "$f" | grep --quiet shell; then
{
shellcheck "$f" && echo -e "[\033[0;32mOK\033[0m]: sucessfully linted $f"
} || {
ERRORS+=("$f")
}
fi
done
if (( ${#ERRORS[@]} )); then
echo "Files failing shellcheck: ${ERRORS[*]}"
exit 1
fi