.travis.yml 7.1 KB

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