.travis.yml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. dist: xenial
  2. os: linux
  3. language: php
  4. git:
  5. depth: 10
  6. cache:
  7. directories:
  8. - $HOME/.composer
  9. - $HOME/bin
  10. env:
  11. global:
  12. - DEFAULT_COMPOSER_FLAGS="--optimize-autoloader --no-interaction --no-progress"
  13. - COMPOSER_FLAGS=""
  14. before_install:
  15. # turn off XDebug
  16. - phpenv config-rm xdebug.ini || return 0
  17. jobs:
  18. include:
  19. -
  20. stage: Static Code Analysis
  21. php: 7.4
  22. env: COMPOSER_FLAGS="--prefer-stable"
  23. install:
  24. - travis_retry ./dev-tools/install.sh
  25. - travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS
  26. - composer info -D | sort
  27. before_script:
  28. - if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then COMMIT_RANGE=$TRAVIS_COMMIT_RANGE; else COMMIT_RANGE="HEAD~..HEAD"; fi;
  29. - export CHANGED_PHP_FILES=`git diff --name-only --diff-filter=ACMRTUXB $COMMIT_RANGE | grep -E "\.php$"`
  30. script:
  31. # @TODO remove at 3.0
  32. - |
  33. git archive -o /dev/null HEAD -v 2>&1 | grep tests | grep \.php \
  34. | grep -v tests/Test/AbstractFixerTestCase.php \
  35. | grep -v tests/Test/AbstractIntegrationCaseFactory.php \
  36. | grep -v tests/Test/AbstractIntegrationTestCase.php \
  37. | grep -v tests/Test/Assert/AssertTokensTrait.php \
  38. | grep -v tests/Test/IntegrationCase.php \
  39. | grep -v tests/Test/IntegrationCaseFactory.php \
  40. | grep -v tests/Test/IntegrationCaseFactoryInterface.php \
  41. | grep -v tests/Test/InternalIntegrationCaseFactory.php \
  42. | grep -v tests/Test/IsIdenticalConstraint.php \
  43. | grep -v tests/TestCase.php \
  44. && (echo "UNKNOWN FILES DETECTED" && travis_terminate 1) || echo "NO UNKNOWN FILES"
  45. - ./dev-tools/check_file_permissions.sh || travis_terminate 1
  46. - ./dev-tools/check_trailing_spaces.sh || travis_terminate 1
  47. - dev-tools/vendor/bin/phpstan analyse
  48. - if [ -n "$CHANGED_PHP_FILES" ]; then ./dev-tools/vendor/bin/phpmd `echo "$CHANGED_PHP_FILES" | xargs | sed 's/ /,/g'` text phpmd.xml || travis_terminate 1; fi
  49. - ./dev-tools/vendor/bin/composer-require-checker check composer.json --config-file $(realpath .composer-require-checker.json) || travis_terminate 1
  50. - composer normalize --dry-run --working-dir=./dev-tools ../composer.json
  51. - ./dev-tools/check_shell_scripts.sh
  52. - &STANDARD_TEST_JOB
  53. stage: Fast Test
  54. php: 7.0
  55. install:
  56. # Composer: enforce given Symfony components version
  57. - if [ "$SYMFONY_VERSION" != "" ]; then composer global show symfony/flex -q || travis_retry composer global require $DEFAULT_COMPOSER_FLAGS symfony/flex; fi
  58. - if [ "$SYMFONY_VERSION" != "" ]; then composer config extra.symfony.require $SYMFONY_VERSION || true; fi
  59. - travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS
  60. - composer info -D | sort
  61. script:
  62. - vendor/bin/phpunit || travis_terminate 1
  63. - PHP_CS_FIXER_FUTURE_MODE=1 php php-cs-fixer --diff --dry-run -v fix
  64. -
  65. <<: *STANDARD_TEST_JOB
  66. stage: Test
  67. php: 5.6
  68. env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
  69. -
  70. <<: *STANDARD_TEST_JOB
  71. stage: Test
  72. php: 7.1
  73. name: 7.1 | Symfony ~4.1.0
  74. env: SYMFONY_DEPRECATIONS_HELPER=disabled PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER=1 SYMFONY_VERSION="~4.1.0"
  75. -
  76. <<: *STANDARD_TEST_JOB
  77. stage: Test
  78. php: 7.2
  79. name: 7.2 | Symfony ^5.0
  80. env: SYMFONY_DEPRECATIONS_HELPER=disabled PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER=1 SYMFONY_VERSION="^5.0"
  81. -
  82. <<: *STANDARD_TEST_JOB
  83. stage: Test
  84. php: 7.3
  85. name: 7.3 | With migration rules
  86. before_script:
  87. - php php-cs-fixer fix --rules @PHP73Migration,@PHP71Migration:risky,blank_line_after_opening_tag -q || travis_terminate 1
  88. -
  89. <<: *STANDARD_TEST_JOB
  90. stage: Test
  91. php: 7.4
  92. name: 7.4 | Collect coverage
  93. before_install:
  94. # for building a tag release we don't need to collect code coverage
  95. - if [ $TRAVIS_TAG ]; then travis_terminate 0; fi
  96. ## regular `before_install`
  97. # turn off XDebug
  98. - phpenv config-rm xdebug.ini || return 0
  99. # Require PHPUnit 8
  100. - composer require --dev --no-update phpunit/phpunit:^8
  101. # Install PCOV
  102. - pecl install pcov
  103. before_script:
  104. # Make code compatible with PHPUnit 8
  105. - PHP_CS_FIXER_FUTURE_MODE=1 php php-cs-fixer fix --rules=void_return -q tests || return 0
  106. script:
  107. - vendor/bin/phpunit --testsuite coverage --exclude-group covers-nothing --coverage-clover build/logs/clover.xml || travis_terminate 1
  108. - php vendor/bin/php-coveralls -v
  109. -
  110. <<: *STANDARD_TEST_JOB
  111. stage: Test
  112. php: nightly
  113. env: COMPOSER_FLAGS="--ignore-platform-reqs" PHP_CS_FIXER_IGNORE_ENV=1 SYMFONY_DEPRECATIONS_HELPER=weak
  114. -
  115. stage: Deployment
  116. php: 7.4
  117. install: ./dev-tools/build.sh
  118. script:
  119. - PHP_CS_FIXER_TEST_ALLOW_SKIPPING_SMOKE_TESTS=0 vendor/bin/phpunit tests/Smoke/
  120. before_deploy:
  121. # ensure that deployment is happening only if tag matches version of PHP CS Fixer
  122. - test $(php dev-tools/info-extractor.php | jq .version.vnumber) == "\"$TRAVIS_TAG\""
  123. deploy:
  124. provider: releases
  125. token:
  126. secure: K9NKi7X1OPz898fxtVc1RfWrSI+4hTFFYOik932wTz1jC4dQJ64Khh1LV9frA1+JiDS3+R6TvmQtpzbkX3y4L75UrSnP1ADH5wfMYIVmydG3ZjTMo8SWQWHmRMh3ORAKTMMpjl4Q7EkRkLp6RncKe+FAFPP5mgv55mtIMaE4qUk=
  127. file: php-cs-fixer.phar
  128. skip_cleanup: true
  129. on:
  130. repo: FriendsOfPHP/PHP-CS-Fixer
  131. tags: true
  132. after_deploy:
  133. - ./dev-tools/trigger-website.sh ${TRAVIS_TOKEN} ${TRAVIS_TAG}
  134. allow_failures:
  135. - php: nightly