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

Travis: use a mix of PHPCS versions in the matrix #91

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
76 changes: 66 additions & 10 deletions .travis.yml
Expand Up @@ -5,6 +5,7 @@ cache:
directories:
- "${HOME}/.composer/cache"
- "${HOME}/.npm/"

env:
global:
- PATH="${HOME}/bin:${PATH}"
Expand All @@ -25,38 +26,93 @@ jobs:

- stage: test
php: 7.4
env: PHPCS_VERSION="dev-master" LINT=1
- php: 7.4
# Lowest PHPCS version on which PHP 7.4 is supported.
env: PHPCS_VERSION="3.5.0"
- php: 7.3
env: SECURITY=1 PHPCS_VERSION="3.5.3" LINT=1 PHPCS=1
- php: 7.3
env: SECURITY=1
# Lowest PHPCS version on which PHP 7.3 is supported.
env: PHPCS_VERSION="3.3.1"
- php: 7.2
env: PHPCS_VERSION="3.2.3" LINT=1
- php: 7.2
# Lowest PHPCS version on which PHP 7.2 is supported.
env: PHPCS_VERSION="2.9.2"
- php: 7.1
env: PHPCS_VERSION="3.1.1" LINT=1
- php: 7.1
env: PHPCS_VERSION="2.0.0"
- php: 7.0
env: PHPCS_VERSION="3.4.2" LINT=1
- php: 7.0
env: PHPCS_VERSION="2.2.0"
- php: 5.6
env: PHPCS_VERSION="3.0.2" LINT=1
- php: 5.6
env: PHPCS_VERSION="2.4.0"
- php: 5.5
# As the latest Debian does not support PHP 5.5 anymore, we need to force using 'trusty'.
dist: trusty
env: PHPCS_VERSION="dev-master" LINT=1
- php: 5.5
# As the latest Debian does not support PHP 5.5 anymore, we need to force using 'trusty'.
dist: trusty
env: PHPCS_VERSION="2.6.1"
- php: 5.4
# As the latest Debian does not support PHP 5.4 anymore, we need to force using 'trusty'.
dist: trusty
env: PHPCS_VERSION="3.5.3" LINT=1
- php: 5.4
# As the latest Debian does not support PHP 5.4 anymore, we need to force using 'trusty'.
dist: trusty
env: PHPCS_VERSION="2.8.1"
- php: 5.3
# As the latest Debian does not support PHP 5.3 anymore, we need to force using 'precise'.
dist: precise
script:
- find . -type f -name "*.php" -print0 | xargs -0 -n1 php -l
- travis_wait composer install --no-interaction --no-progress --no-scripts --no-suggest --optimize-autoloader --prefer-dist --verbose
- composer install-codestandards
- ./vendor/bin/phpcs -i
- ./vendor/bin/phpcs -s --standard=PHPCompatibility --runtime-set testVersion "${TRAVIS_PHP_VERSION:0:3}" --exclude=PHPCompatibility.Upgrade.LowPHP ./src/
env: PHPCS_VERSION="2.9.2"
- php: 5.3
# As the latest Debian does not support PHP 5.3 anymore, we need to force using 'precise'.
dist: precise
env: PHPCS_VERSION="2.0.0"

fast_finish: true

before_install:
# Speed up build time by disabling Xdebug.
phpenv config-rm xdebug.ini || echo 'No xdebug config.'

script:
- find . -type f -name "*.php" -print0 | xargs -0 -n1 php -l
install:
- composer require --no-update --no-suggest --no-scripts squizlabs/php_codesniffer:${PHPCS_VERSION}
- |
if [[ ${PHPCS_VERSION:0:3} < "2.2" ]]; then
# Install PHPCompatibility 7.x for PHPCS < 2.2.
composer require --no-update --no-suggest --no-scripts phpcompatibility/php-compatibility:"^7.0"
elif [[ ${PHPCS_VERSION:0:3} < "2.3" ]]; then
# Install PHPCompatibility 8.x for PHPCS 2.2 < 2.3.
composer require --no-update --no-suggest --no-scripts phpcompatibility/php-compatibility:"^8.0"
fi
- travis_wait composer install --no-interaction --no-progress --no-scripts --no-suggest --optimize-autoloader --prefer-dist --verbose
- |
if [[ ${PHPCS_VERSION:0:3} < "2.2" ]]; then
# Rename the PHPCompatibility directory as PHPCompatibility 7.x wasn't fully compatible with Composer yet.
mv ./vendor/phpcompatibility/php-compatibility ./vendor/phpcompatibility/PHPCompatibility
fi

script:
- if [[ "$LINT" == "1" ]]; then if find . -path ./vendor -prune -o -name "*.php" -exec php -l {} \; | grep "^[Parse error|Fatal error]"; then exit 1; fi; fi
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if, instead of using

find . -path ./vendor -prune -o -name "*.php" -exec php -l {} \; 

it might be easier to just use

find ./src/ -name "*.php" -exec php -l {} \;

🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

@Potherca I understand the question. I didn't in the PR as it's really easy to overlook something like that and forget to change it again when - for instance - a tests/ directory would be added at a later time.

As it is now, the logic is consistent with the in/exclusion rules also used in the phpcs.xml.dist file

- composer install-codestandards
- ./vendor/bin/phpcs -i
- ./vendor/bin/phpcs -s --runtime-set testVersion "${TRAVIS_PHP_VERSION:0:3}" --exclude=PHPCompatibility.Upgrade.LowPHP ./src/
- |
if [[ "$PHPCS" == "1" ]]; then
# Do the actual code style check for this repo.
./vendor/bin/phpcs
elif [[ ${PHPCS_VERSION:0:3} < "2.3" ]]; then
# Test that an external standard has been registered correctly by running it against the codebase on PHPCS < 2.3.
./vendor/bin/phpcs -ps ./src/ --standard=PHPCompatibility --runtime-set testVersion "${TRAVIS_PHP_VERSION:0:3}" --sniffs=PHPCompatibility.PHP.DeprecatedFunctions
else
# Test that an external standard has been registered correctly by running it against the codebase.
./vendor/bin/phpcs -ps ./src/ --standard=PHPCompatibility --runtime-set testVersion "${TRAVIS_PHP_VERSION:0:3}" --sniffs=PHPCompatibility.FunctionUse.RemovedFunctions
fi
- if [[ "$SECURITY" == "1" ]];then ./vendor/bin/security-checker -n security:check --end-point=http://security.symfony.com/check_lock; fi