From bdbcfd10cccf30c9885fd2dbe417331cc0959966 Mon Sep 17 00:00:00 2001 From: zSALLAZAR <59490940+zSALLAZAR@users.noreply.github.com> Date: Mon, 19 Aug 2024 23:52:51 +0200 Subject: [PATCH] Add ShellCheck (#6407) Co-authored-by: IvanCraft623 <57236932+IvanCraft623@users.noreply.github.com> --- .github/workflows/main.yml | 12 ++++++++++++ start.sh | 2 +- tests/travis.sh | 7 +++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7c92c0b8b28..b5a9740b5c1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,3 +37,15 @@ jobs: - name: Run PHP-CS-Fixer run: php-cs-fixer fix --dry-run --diff --ansi + + shellcheck: + name: ShellCheck + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v4 + + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@2.0.0 diff --git a/start.sh b/start.sh index 0121f3887bb..4d47871143f 100755 --- a/start.sh +++ b/start.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash DIR="$(cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" -cd "$DIR" +cd "$DIR" || { echo "Couldn't change directory to $DIR"; exit 1; } while getopts "p:f:l" OPTION 2> /dev/null; do case ${OPTION} in diff --git a/tests/travis.sh b/tests/travis.sh index 094f6590533..a4674fb6f23 100755 --- a/tests/travis.sh +++ b/tests/travis.sh @@ -7,6 +7,9 @@ while getopts "t:" OPTION 2> /dev/null; do t) PM_WORKERS="$OPTARG" ;; + \?) + break + ;; esac done @@ -19,7 +22,7 @@ rm PocketMine-MP.phar 2> /dev/null mkdir "$DATA_DIR" mkdir "$PLUGINS_DIR" -cd tests/plugins/DevTools +cd tests/plugins/DevTools || { echo "Couldn't change directory to $DIR"; exit 1; } php -dphar.readonly=0 ./src/ConsoleScript.php --make ./ --relative ./ --out "$PLUGINS_DIR/DevTools.phar" cd ../../.. composer make-server @@ -45,7 +48,7 @@ if [ "$result" != "" ]; then echo "$result" echo Some tests did not complete successfully, changing build status to failed exit 1 -elif [ $(grep -c "ERROR\|CRITICAL\|EMERGENCY" "$DATA_DIR/server.log") -ne 0 ]; then +elif [ "$(grep -c "ERROR\|CRITICAL\|EMERGENCY" "$DATA_DIR/server.log")" -ne 0 ]; then echo Server log contains error messages, changing build status to failed exit 1 else