Issue #3224583 by daffie, dhirendra.mishra, longwave: The testbot does not run PHPCS on all files when core/phpcs.xml.dist is changed

(cherry picked from commit 92a87eacc8)
merge-requests/444/merge
Alex Pott 2021-07-24 23:06:37 +01:00
parent 2f09626f10
commit d64dc5c13c
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
1 changed files with 22 additions and 1 deletions

View File

@ -107,10 +107,17 @@ fi
TOP_LEVEL=$(git rev-parse --show-toplevel)
# This variable will be set to one when the file core/phpcs.xml.dist is changed.
PHPCS_XML_DIST_FILE_CHANGED=0
# Build up a list of absolute file names.
ABS_FILES=
for FILE in $FILES; do
ABS_FILES="$ABS_FILES $TOP_LEVEL/$FILE"
if [[ $FILE == "core/phpcs.xml.dist" ]]; then
PHPCS_XML_DIST_FILE_CHANGED=1;
fi;
done
# Exit early if there are no files.
@ -163,6 +170,20 @@ printf "\n"
printf -- '-%.0s' {1..100}
printf "\n"
# When the file core/phpcs.xml.dist has been changed, then PHPCS must check all files.
if [[ $PHPCS_XML_DIST_FILE_CHANGED == "1" ]]; then
# Test all files with phpcs rules.
vendor/bin/phpcs -ps --runtime-set installed_paths "$TOP_LEVEL/vendor/drupal/coder/coder_sniffer" --standard="$TOP_LEVEL/core/phpcs.xml.dist"
PHPCS=$?
if [ "$PHPCS" -ne "0" ]; then
# If there are failures set the status to a number other than 0.
FINAL_STATUS=1
printf "\nPHPCS: ${red}failed${reset}\n"
else
printf "\nPHPCS: ${green}passed${reset}\n"
fi
fi
for FILE in $FILES; do
STATUS=0;
# Print a line to separate spellcheck output from per file output.
@ -199,7 +220,7 @@ for FILE in $FILES; do
############################################################################
### PHP AND YAML FILES
############################################################################
if [[ -f "$TOP_LEVEL/$FILE" ]] && [[ $FILE =~ \.(inc|install|module|php|profile|test|theme|yml)$ ]]; then
if [[ -f "$TOP_LEVEL/$FILE" ]] && [[ $FILE =~ \.(inc|install|module|php|profile|test|theme|yml)$ ]] && [[ $PHPCS_XML_DIST_FILE_CHANGED == "0" ]]; then
# Test files with phpcs rules.
vendor/bin/phpcs "$TOP_LEVEL/$FILE" --runtime-set installed_paths "$TOP_LEVEL/vendor/drupal/coder/coder_sniffer" --standard="$TOP_LEVEL/core/phpcs.xml.dist"
PHPCS=$?