.travis.yml 7.1 KB

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