diff --git a/scripts/prepare-drupal-lint.sh b/scripts/prepare-drupal-lint.sh index 424690d..1e95f3c 100755 --- a/scripts/prepare-drupal-lint.sh +++ b/scripts/prepare-drupal-lint.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e if [ -z "$TARGET_DRUPAL_CORE_VERSION" ]; then # default to target Drupal 8, you can override this by setting the secrets value on your github repo @@ -13,21 +14,20 @@ composer --version echo "\$COMPOSER_HOME: $COMPOSER_HOME" echo "TARGET_DRUPAL_CORE_VERSION: $TARGET_DRUPAL_CORE_VERSION" -composer global require drupal/coder -composer global require phpcompatibility/php-compatibility +# Add this line to avoid the plugin prompt +composer config --global allow-plugins.dealerdirect/phpcodesniffer-composer-installer true + +composer global require drupal/coder --dev +composer global require phpcompatibility/php-compatibility --dev export PATH="$PATH:$COMPOSER_HOME/vendor/bin" -composer global require dealerdirect/phpcodesniffer-composer-installer +composer global require dealerdirect/phpcodesniffer-composer-installer --dev composer global show -P phpcs -i - phpcs --config-set colors 1 -# see: https://github.com/squizlabs/PHP_CodeSniffer/issues/262 -# phpcs --config-set ignore_warnings_on_exit 1 -# phpcs --config-set ignore_errors_on_exit 1 phpcs --config-set drupal_core_version $TARGET_DRUPAL_CORE_VERSION phpcs --config-show diff --git a/scripts/run-drupal-lint.sh b/scripts/run-drupal-lint.sh index ae0cfe0..3c20379 100755 --- a/scripts/run-drupal-lint.sh +++ b/scripts/run-drupal-lint.sh @@ -2,31 +2,41 @@ source scripts/prepare-drupal-lint.sh EXIT_CODE=0 -PHP_VERSION="8.3-" -STANDARDS=("PHPCompatibility" "Drupal" "DrupalPractice") -FILE_EXTENSIONS="php,module,inc,install,test,profile,theme,info,txt,md,yml" -IGNORE_PATHS="node_modules,analyze/vendor,.github,vendor" -for STANDARD in "${STANDARDS[@]}"; do - echo "---- Checking with $STANDARD standard... ----" - - COMMAND="phpcs --standard=$STANDARD" - - if [ "$STANDARD" == "PHPCompatibility" ]; then - COMMAND="$COMMAND --runtime-set testVersion $PHP_VERSION" - fi - - $COMMAND \ - --extensions=$FILE_EXTENSIONS \ - --ignore=$IGNORE \ - -v \ - . - - status=$? - if [ $status -ne 0 ]; then - EXIT_CODE=$status - fi -done +echo "---- Checking with PHPCompatibility PHP 8.3 and up ----" +phpcs --standard=PHPCompatibility \ + --runtime-set testVersion 8.3- \ + --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml \ + --ignore=node_modules,analyze/vendor,.github,vendor \ + -v \ + . +status=$? +if [ $status -ne 0 ]; then + EXIT_CODE=$status +fi + +echo "---- Checking with Drupal standard... ----" +phpcs --standard=Drupal \ + --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml \ + --ignore=node_modules,analyze/vendor,.github,vendor \ + -v \ + . +status=$? +if [ $status -ne 0 ]; then + EXIT_CODE=$status +fi + +echo "---- Checking with DrupalPractice standard... ----" +phpcs --standard=DrupalPractice \ + --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml \ + --ignore=node_modules,analyze/vendor,.github,vendor \ + -v \ + . + +status=$? +if [ $status -ne 0 ]; then + EXIT_CODE=$status +fi # Exit with failure if any of the checks failed exit $EXIT_CODE