From af73a4762039ada52b5bdbb44cb91cfb427b9191 Mon Sep 17 00:00:00 2001 From: Ulrich Pogson Date: Thu, 17 May 2018 11:21:00 +0200 Subject: [PATCH 1/2] Install WPCS & PHPCompatibility via composer PHPCS is loaded automatically as a dependency --- .travis.yml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4840c9fed2..2cf1e30045 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,19 +48,13 @@ matrix: before_script: # Speed up build time by disabling Xdebug. - phpenv config-rm xdebug.ini || echo 'No xdebug config.' - # Set up temporary paths. - - export PHPCS_DIR=/tmp/phpcs - - export WPCS_DIR=/tmp/wpcs - - export PHPCOMPAT_DIR=/tmp/phpcompatibility - # Install CodeSniffer for WordPress Coding Standards checks. - - if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/squizlabs/PHP_CodeSniffer.git $PHPCS_DIR; fi - # Install WordPress Coding Standards. - - if [[ "$SNIFF" == "1" ]]; then git clone -b 0.14.1 --depth 1 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $WPCS_DIR; fi - # Install PHP Compatibility sniffs. - - if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/wimg/PHPCompatibility.git $PHPCOMPAT_DIR; fi + # Install WordPress Coding Standards & PHP Compatibility sniffs. + - if [[ "$SNIFF" == "1" ]]; then composer global require wp-coding-standards/wpcs:~0.14.1 wimg/php-compatibility:dev-master --prefer-stable --no-interaction --no-suggest; fi + # Set composer PATH. + - if [[ "$SNIFF" == "1" ]]; then export PATH=$HOME/.composer/vendor/bin:$PATH; fi # Set install path for PHPCS sniffs. # @link https://github.com/squizlabs/PHP_CodeSniffer/blob/4237c2fc98cc838730b76ee9cee316f99286a2a7/CodeSniffer.php#L1941 - - if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/bin/phpcs --config-set installed_paths $WPCS_DIR,$PHPCOMPAT_DIR; fi + - if [[ "$SNIFF" == "1" ]]; then phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs,$HOME/.composer/vendor/wimg/php-compatibility; fi # After CodeSniffer install you should refresh your path. - if [[ "$SNIFF" == "1" ]]; then phpenv rehash; fi # Install JSCS: JavaScript Code Style checker. @@ -87,7 +81,7 @@ script: # @link https://pear.php.net/package/PHP_CodeSniffer/ # Uses a custom ruleset based on WordPress. This ruleset is automatically # picked up by PHPCS as it's named `phpcs.xml(.dist)`. - - if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/bin/phpcs --runtime-set ignore_warnings_on_exit 1; fi + - if [[ "$SNIFF" == "1" ]]; then phpcs --runtime-set ignore_warnings_on_exit 1; fi # Receive notifications for build results. # @link https://docs.travis-ci.com/user/notifications/#Email-notifications From a5268d906c9797733438812026acbfda947f3612 Mon Sep 17 00:00:00 2001 From: Ulrich Pogson Date: Sun, 20 May 2018 20:40:50 +0200 Subject: [PATCH 2/2] Use dealerdirect/phpcodesniffer-composer-installer Replaces the need to set the sniffs path manually --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2cf1e30045..ced2573eba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,12 +49,9 @@ before_script: # Speed up build time by disabling Xdebug. - phpenv config-rm xdebug.ini || echo 'No xdebug config.' # Install WordPress Coding Standards & PHP Compatibility sniffs. - - if [[ "$SNIFF" == "1" ]]; then composer global require wp-coding-standards/wpcs:~0.14.1 wimg/php-compatibility:dev-master --prefer-stable --no-interaction --no-suggest; fi + - if [[ "$SNIFF" == "1" ]]; then composer global require wp-coding-standards/wpcs:~0.14.1 wimg/php-compatibility:dev-master dealerdirect/phpcodesniffer-composer-installer:^0.4.3 --prefer-stable --no-interaction --no-suggest; fi # Set composer PATH. - if [[ "$SNIFF" == "1" ]]; then export PATH=$HOME/.composer/vendor/bin:$PATH; fi - # Set install path for PHPCS sniffs. - # @link https://github.com/squizlabs/PHP_CodeSniffer/blob/4237c2fc98cc838730b76ee9cee316f99286a2a7/CodeSniffer.php#L1941 - - if [[ "$SNIFF" == "1" ]]; then phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs,$HOME/.composer/vendor/wimg/php-compatibility; fi # After CodeSniffer install you should refresh your path. - if [[ "$SNIFF" == "1" ]]; then phpenv rehash; fi # Install JSCS: JavaScript Code Style checker.