Fixes travis config file

Fixes the mess due to #995 and #1005.

Fixes:
* Remove --standard - codesniffer.ruleset.xml was renamed to phpcs.xml which gets picked automatically by PHPCS.
* Install PHP Compatibility sniffs.
* Add PHP Compatibility to install path for PHPCS sniffs.
This commit is contained in:
IanDelMar 2019-12-17 00:07:10 +01:00 committed by GitHub
parent 594231d02d
commit f3f657df99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 7 deletions

View File

@ -29,6 +29,10 @@ env:
# e.g. copy database configurations, environment variables, etc. # e.g. copy database configurations, environment variables, etc.
# Failures in this section will result in build status 'errored'. # Failures in this section will result in build status 'errored'.
before_script: before_script:
# Set up temporary paths.
- export PHPCS_DIR=/tmp/phpcs
- export WPCS_DIR=/tmp/wpcs
- export PHPCOMPAT_DIR=/tmp/phpcompatibility
# Set up WordPress installation. # Set up WordPress installation.
- export WP_DEVELOP_DIR=/tmp/wordpress/ - export WP_DEVELOP_DIR=/tmp/wordpress/
- mkdir -p $WP_DEVELOP_DIR - mkdir -p $WP_DEVELOP_DIR
@ -49,14 +53,14 @@ before_script:
# Create WordPress database. # Create WordPress database.
#- mysql -u root -e "CREATE DATABASE wordpress_test;" #- mysql -u root -e "CREATE DATABASE wordpress_test;"
# Install CodeSniffer for WordPress Coding Standards checks. # Install CodeSniffer for WordPress Coding Standards checks.
- mkdir php-codesniffer && curl -L https://github.com/squizlabs/PHP_CodeSniffer/archive/3.5.0.tar.gz | tar xz --strip-components=1 -C php-codesniffer - git clone -b master --depth 1 https://github.com/squizlabs/PHP_CodeSniffer.git $PHPCS_DIR
# Install WordPress Coding Standards. # Install WordPress Coding Standards.
- mkdir wordpress-coding-standards && curl -L https://github.com/WordPress/WordPress-Coding-Standards/archive/2.1.1.tar.gz | tar xz --strip-components=1 -C wordpress-coding-standards - git clone -b master --depth 1 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $WPCS_DIR
# Hop into CodeSniffer directory. # Install PHP Compatibility sniffs.
- cd php-codesniffer - git clone -b master --depth 1 https://github.com/wimg/PHPCompatibility.git $PHPCOMPAT_DIR
# Set install path for WordPress Coding Standards # Set install path for PHPCS sniffs.
# @link https://github.com/squizlabs/PHP_CodeSniffer/blob/4237c2fc98cc838730b76ee9cee316f99286a2a7/CodeSniffer.php#L1941 # @link https://github.com/squizlabs/PHP_CodeSniffer/blob/4237c2fc98cc838730b76ee9cee316f99286a2a7/CodeSniffer.php#L1941
- bin/phpcs --config-set installed_paths ../wordpress-coding-standards - $PHPCS_DIR/bin/phpcs --config-set installed_paths $WPCS_DIR,$PHPCOMPAT_DIR
# Hop into themes directory. # Hop into themes directory.
- cd $theme_dir - cd $theme_dir
# After CodeSniffer install you should refresh your path. # After CodeSniffer install you should refresh your path.
@ -88,4 +92,4 @@ script:
# -n flag: Do not print warnings (shortcut for --warning-severity=0) # -n flag: Do not print warnings (shortcut for --warning-severity=0)
# --standard: Use WordPress as the standard. # --standard: Use WordPress as the standard.
# --extensions: Only sniff PHP files. # --extensions: Only sniff PHP files.
- $WP_DEVELOP_DIR/php-codesniffer/bin/phpcs -p -s -v -n . --standard=./codesniffer.ruleset.xml --extensions=php --ignore=*/woocommerce/*,*/src/* - $PHPCS_DIR/bin/phpcs -p -s -v -n . --extensions=php --ignore=*/woocommerce/*,*/src/*