Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #35 | Upgrade WordPress Coding Standards to 3.1.0 #49

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ RUN chmod +x /action/entrypoint.sh

RUN apk update && \
apk upgrade && \
apk add git
apk add git composer php8-simplexml php8-tokenizer php8-xmlreader php8-xmlwriter

ENTRYPOINT ["/action/entrypoint.sh"]
21 changes: 16 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

cp /action/problem-matcher.json /github/workflow/problem-matcher.json

git clone --depth 1 -b 2.3.0 https://github.com/WordPress/WordPress-Coding-Standards.git ~/wpcs
# Install Composer if not found
if ! [ -x "$(command -v composer)" ]; then
echo 'Composer not found, installing...'
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
fi

composer global config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer global require --dev phpcsstandards/phpcsextra:"^1.2.0"
composer global require --dev wp-coding-standards/wpcs:"^3.0.0" --update-with-dependencies

git config --global --add safe.directory $(pwd)

Expand Down Expand Up @@ -105,7 +114,7 @@ if [ "${INPUT_STANDARD}" = "WordPress-VIP-Go" ] || [ "${INPUT_STANDARD}" = "Word
git clone --depth 1 -b 2.3.3 https://github.com/Automattic/VIP-Coding-Standards.git ${HOME}/vipcs
git clone https://github.com/sirbrillig/phpcs-variable-analysis ${HOME}/variable-analysis

decide_all_files_or_changed "${HOME}/wpcs,${HOME}/vipcs,${HOME}/variable-analysis"
decide_all_files_or_changed "$(composer config home)/vendor/wp-coding-standards/wpcs,${HOME}/vipcs,${HOME}/variable-analysis"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sksaju, when using the WordPress-VIP-Go standard, I'm getting ERROR: Referenced sniff "WordPress.PHP.StrictComparisons" does not exist. This occurs because the action is missing the PHPCSUtils path in its configuration.

I think we need to add PHPCSUtils to the decide_all_files_or_changed paths:

decide_all_files_or_changed "$(composer config home)/vendor/wp-coding-standards/wpcs,${HOME}/vipcs,${HOME}/variable-analysis,${HOME}/phpcsutils/PHPCSUtils"

cc @benlk @jeffpaul

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@s3rgiosan I've updated the PR, could you take another look, please? Thank you

elif [ "${INPUT_STANDARD}" = "10up-Default" ]; then
echo "Setting up 10up-Default"
git clone https://github.com/10up/phpcs-composer ${HOME}/10up
Expand All @@ -116,14 +125,16 @@ elif [ "${INPUT_STANDARD}" = "10up-Default" ]; then
git clone https://github.com/Automattic/VIP-Coding-Standards ${HOME}/vipcs
git clone https://github.com/sirbrillig/phpcs-variable-analysis ${HOME}/variable-analysis

decide_all_files_or_changed "${HOME}/wpcs,${HOME}/10up/10up-Default,${HOME}/phpcompatwp/PHPCompatibilityWP,${HOME}/phpcompat/PHPCompatibility,${HOME}/phpcompat-paragonie/PHPCompatibilityParagonieSodiumCompat,${HOME}/phpcompat-paragonie/PHPCompatibilityParagonieRandomCompat,${HOME}/phpcsutils/PHPCSUtils,${HOME}/vipcs,${HOME}/variable-analysis"
decide_all_files_or_changed "$(composer config home)/vendor/wp-coding-standards/wpcs,${HOME}/10up/10up-Default,${HOME}/phpcompatwp/PHPCompatibilityWP,${HOME}/phpcompat/PHPCompatibility,${HOME}/phpcompat-paragonie/PHPCompatibilityParagonieSodiumCompat,${HOME}/phpcompat-paragonie/PHPCompatibilityParagonieRandomCompat,${HOME}/phpcsutils/PHPCSUtils,$(composer config home)/vendor/phpcsstandards/phpcsextra,${HOME}/vipcs,${HOME}/variable-analysis"
elif [ -z "${INPUT_STANDARD_REPO}" ] || [ "${INPUT_STANDARD_REPO}" = "false" ]; then
decide_all_files_or_changed "${HOME}/wpcs"
echo "Setting up default WPCS"
git clone --depth 1 --branch 1.0.11 https://github.com/PHPCSStandards/PHPCSUtils ${HOME}/phpcsutils
decide_all_files_or_changed "$(composer config home)/vendor/wp-coding-standards/wpcs,${HOME}/phpcsutils/PHPCSUtils"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sksaju, when using the default standard, I'm getting ERROR: Referenced sniff "Universal.NamingConventions.NoReservedKeywordParameterNames" does not exist. This occurs because PHPCSExtra's path isn't included in PHPCS's installed_paths configuration, even though it's installed globally via composer.

I think we need to add PHPCSExtra's path to the decide_all_files_or_changed call:

decide_all_files_or_changed "$(composer config home)/vendor/wp-coding-standards/wpcs,${HOME}/phpcsutils/PHPCSUtils,$(composer config home)/vendor/phpcsstandards/phpcsextra"

cc @benlk @jeffpaul

else
echo "Standard repository: ${INPUT_STANDARD_REPO}"
git clone -b ${INPUT_REPO_BRANCH} ${INPUT_STANDARD_REPO} ${HOME}/cs

decide_all_files_or_changed "${HOME}/wpcs,${HOME}/cs"
decide_all_files_or_changed "$(composer config home)/vendor/wp-coding-standards/wpcs,${HOME}/cs"
fi

if [ -z "${INPUT_EXCLUDES}" ]; then
Expand Down