Skip to content
Snippets Groups Projects

#3508450 Improvments to run-local-checks

2 files
+ 24
18
Compare changes
  • Side-by-side
  • Inline
Files
2
#!/bin/bash
# Launch from the root of this project: "./scripts/run-local-checks.sh [fix] [clean]".
# Launch from the root of this project: "./scripts/run-local-checks.sh [fix] [debug] [clean]".
#
# Optional arguments:
# fix - to run the fixer options of eslint and phpcs.
# debug - to show verbose output.
# clean - to remove the installed software and files copied from assets.
#
# Helper script to run all the checks that will be run via GitLab CI.
@@ -25,13 +26,16 @@ php scripts/prepare-cspell.php
npm install
composer install
EXIT_CODE=0
npx cspell --show-suggestions --show-context --no-progress --dot {**,.**} || EXIT_CODE=$((EXIT_CODE+1))
NO_PROGRESS=$([[ "$1" == "debug" ]] && echo "" || echo "--no-progress");
npx cspell --show-suggestions --show-context --dot $NO_PROGRESS {**,.**} || EXIT_CODE=$((EXIT_CODE+1))
ESLINT_FIX=$([[ "$1" == "fix" ]] && echo "--fix" || echo "");
npx eslint --no-error-on-unmatched-pattern --ext=.yml $ESLINT_FIX . && echo "ESLint passed." || EXIT_CODE=$((EXIT_CODE+1))
DEBUG=$([[ "$1" == "debug" ]] && echo "--debug" || echo "");
npx eslint --no-error-on-unmatched-pattern --ignore-pattern=vendor --ignore-pattern=node_modules --ext=.yml $DEBUG $ESLINT_FIX . && echo "ESLint passed." || EXIT_CODE=$((EXIT_CODE+1))
[[ "$1" == "fix" ]] && vendor/bin/phpcbf --colors scripts/*.php -s
vendor/bin/phpcs --colors scripts/*.php -s && echo "PHPCS passed." || EXIT_CODE=$((EXIT_CODE+1))
VERBOSE=$([[ "$1" == "debug" ]] && echo "-v" || echo "");
vendor/bin/phpcs --colors scripts/*.php -s $VERBOSE && echo "PHPCS passed." || EXIT_CODE=$((EXIT_CODE+1))
shellcheck scripts/*.sh && echo "Shellcheck passed." || EXIT_CODE=$((EXIT_CODE+1))
php scripts/unformatted-links.php || EXIT_CODE=$((EXIT_CODE+1))
php scripts/unformatted-links.php $VERBOSE || EXIT_CODE=$((EXIT_CODE+1))
[[ "$EXIT_CODE" != 0 ]] && echo -e "\n===========================\nNumber of failed checks: $EXIT_CODE\n===========================\n" || echo "= All OK ="
# Clean up all files that were copied.
Loading