.travis.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. language: php
  2. sudo: false
  3. git:
  4. depth: 1
  5. cache:
  6. directories:
  7. - $HOME/.composer
  8. env:
  9. global:
  10. - DEFAULT_COMPOSER_FLAGS="--no-interaction --no-progress"
  11. - COMPOSER_FLAGS=""
  12. before_install:
  13. # turn off XDebug
  14. - phpenv config-rm xdebug.ini || return 0
  15. # Composer: boost installation
  16. - composer global show -ND 2>&1 | grep "hirak/prestissimo" || travis_retry composer global require $DEFAULT_COMPOSER_FLAGS hirak/prestissimo
  17. jobs:
  18. include:
  19. -
  20. stage: Static Code Analysis
  21. php: 7.1
  22. env: COMPOSER_FLAGS="--no-dev --prefer-stable"
  23. install:
  24. - travis_retry composer update -d dev-tools $DEFAULT_COMPOSER_FLAGS
  25. - composer info -d dev-tools -D | sort
  26. - travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS
  27. - composer info -D | sort
  28. before_script:
  29. - if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then COMMIT_RANGE=$TRAVIS_COMMIT_RANGE; else COMMIT_RANGE="HEAD~..HEAD"; fi;
  30. - export COMMIT_SCA_FILES=`git diff --name-only --diff-filter=ACMRTUXB $COMMIT_RANGE`
  31. script:
  32. # @TODO remove at 3.0
  33. - if [ $TASK_SCA == 1 ]; then git archive -o /dev/null HEAD -v 2>&1 | grep tests | grep \.php | grep -v tests/Test/Assert/AssertTokensTrait.php | grep -v tests/Test/AbstractFixerTestCase.php | grep -v tests/Test/AbstractIntegrationTestCase.php | grep -v tests/Test/IntegrationCase.php | grep -v tests/Test/IntegrationCaseFactory.php && (echo "UNKNOWN FILES DETECTED" && travis_terminate 1) || echo "NO UNKNOWN FILES"; fi
  34. - ./check_trailing_spaces.sh || travis_terminate 1
  35. - if [ -n "$COMMIT_SCA_FILES" ]; then ./dev-tools/vendor/bin/phpmd `echo "$COMMIT_SCA_FILES" | grep -Ev "^(src/Resources|tests/Fixtures)" | xargs | sed 's/ /,/g'` text phpmd.xml || travis_terminate 1; fi
  36. - ./dev-tools/vendor/bin/composer-require-checker check composer.json --config-file=.composer-require-checker.json
  37. - &STANDARD_TEST_JOB
  38. stage: Test
  39. php: 7.0
  40. install:
  41. - travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS
  42. - composer info -D | sort
  43. script:
  44. - vendor/bin/phpunit --verbose || travis_terminate 1
  45. - php php-cs-fixer --diff --dry-run -v fix
  46. -
  47. <<: *STANDARD_TEST_JOB
  48. php: 5.6
  49. env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
  50. -
  51. <<: *STANDARD_TEST_JOB
  52. php: 7.1
  53. env: COLLECT_COVERAGE=1
  54. before_script:
  55. # check phpdbg
  56. - phpdbg --version 2> /dev/null || { echo 'No phpdbg'; export COLLECT_COVERAGE=0; }
  57. # for building a tag release we don't need to collect code coverage
  58. - if [ $TRAVIS_TAG ]; then export COLLECT_COVERAGE=0; fi
  59. script:
  60. - if [ $COLLECT_COVERAGE == 0 ]; then vendor/bin/phpunit --verbose || travis_terminate 1; fi
  61. - if [ $COLLECT_COVERAGE == 1 ]; then phpdbg -qrr vendor/bin/phpunit --verbose --coverage-clover build/logs/clover.xml || travis_terminate 1; fi
  62. - php php-cs-fixer --diff --dry-run -v fix || travis_terminate 1
  63. - if [ $COLLECT_COVERAGE == 1 ]; then php vendor/bin/coveralls -v; fi
  64. -
  65. <<: *STANDARD_TEST_JOB
  66. php: nightly
  67. env: COMPOSER_FLAGS="--ignore-platform-reqs" SYMFONY_DEPRECATIONS_HELPER=weak PHP_CS_FIXER_IGNORE_ENV=1 PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER=1
  68. script:
  69. - php php-cs-fixer fix --rules @PHP70Migration:risky,@PHP71Migration,native_function_invocation -q || travis_terminate 1
  70. - vendor/bin/phpunit --verbose || travis_terminate 1
  71. - git checkout . -q
  72. - php php-cs-fixer --diff --dry-run -v fix
  73. -
  74. stage: Deployment
  75. php: 7.1
  76. env: COMPOSER_FLAGS="--no-dev --prefer-stable"
  77. install: skip
  78. script: skip
  79. before_deploy:
  80. # ensure that deps will work on lowest supported PHP version
  81. - composer config platform.php 2> /dev/null || composer config platform.php 5.6.0
  82. # require suggested packages
  83. - composer require --no-update symfony/polyfill-mbstring
  84. - travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS
  85. - composer info -D | sort
  86. # install box2
  87. - curl -LSs http://box-project.github.io/box2/installer.php | php
  88. - php box.phar --version
  89. # build phar file
  90. - php -d phar.readonly=false box.phar build
  91. deploy:
  92. provider: releases
  93. api_key:
  94. secure: K9NKi7X1OPz898fxtVc1RfWrSI+4hTFFYOik932wTz1jC4dQJ64Khh1LV9frA1+JiDS3+R6TvmQtpzbkX3y4L75UrSnP1ADH5wfMYIVmydG3ZjTMo8SWQWHmRMh3ORAKTMMpjl4Q7EkRkLp6RncKe+FAFPP5mgv55mtIMaE4qUk=
  95. file: php-cs-fixer.phar
  96. skip_cleanup: true
  97. on:
  98. repo: FriendsOfPHP/PHP-CS-Fixer
  99. tags: true
  100. after_deploy:
  101. - ./dev-tools/trigger-website.sh ${TRAVIS_TOKEN} ${TRAVIS_TAG}