Skip to content

Commit

Permalink
fix drupal lint in GitHub actions runner
Browse files Browse the repository at this point in the history
  • Loading branch information
Jurriaan Roelofs committed Sep 25, 2024
1 parent f36a368 commit e632202
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 31 deletions.
14 changes: 7 additions & 7 deletions scripts/prepare-drupal-lint.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
58 changes: 34 additions & 24 deletions scripts/run-drupal-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e632202

Please sign in to comment.