ci.yml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. name: CI
  2. on:
  3. - pull_request
  4. - push
  5. jobs:
  6. tests:
  7. strategy:
  8. matrix:
  9. include:
  10. - operating-system: 'ubuntu-20.04'
  11. php-version: '5.6'
  12. composer-flags: '--prefer-stable --prefer-lowest' # should be checked on lowest supported PHP version
  13. - operating-system: 'ubuntu-20.04'
  14. php-version: '7.0'
  15. job-description: 'with Sf ^3'
  16. execute-flex-with-symfony-version: '^3' # Explicit check for Sf 3.x compatibility
  17. - operating-system: 'ubuntu-20.04'
  18. php-version: '7.1'
  19. job-description: 'with Sf ^4'
  20. execute-flex-with-symfony-version: '^4' # Explicit check for Sf 4.x compatibility
  21. - operating-system: 'ubuntu-20.04'
  22. php-version: '7.2'
  23. job-description: 'with Sf ^5'
  24. execute-flex-with-symfony-version: '^5' # Explicit check for Sf 5.x compatibility
  25. - operating-system: 'ubuntu-20.04'
  26. php-version: '7.3'
  27. job-description: 'with legacy Tokenizer' # should be checked on any job, one is enough
  28. PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER: 1
  29. SYMFONY_DEPRECATIONS_HELPER: 'disabled'
  30. - operating-system: 'ubuntu-20.04'
  31. php-version: '7.4'
  32. job-description: 'with calculating code coverage'
  33. calculate-code-coverage: 'yes'
  34. phpunit-flags: '--testsuite coverage --exclude-group covers-nothing --coverage-clover build/logs/clover.xml'
  35. - operating-system: 'ubuntu-20.04'
  36. php-version: '7.4'
  37. job-description: 'with deployment'
  38. execute-deployment: 'yes'
  39. - operating-system: 'ubuntu-20.04'
  40. php-version: '7.4'
  41. job-description: 'with migration rules'
  42. execute-migration-rules: 'yes' # should be checked on highest supported PHP version
  43. - operating-system: 'ubuntu-20.04'
  44. php-version: '8.0'
  45. composer-flags: '--ignore-platform-req=php' # as this is a version not yet officially supported by PHP CS Fixer
  46. PHP_CS_FIXER_IGNORE_ENV: 1
  47. - operating-system: 'windows-latest'
  48. php-version: '7.4'
  49. job-description: 'on Windows'
  50. FAST_LINT_TEST_CASES: 1
  51. - operating-system: 'macos-latest'
  52. php-version: '7.4'
  53. job-description: 'on macOS'
  54. name: PHP ${{ matrix.php-version }} ${{ matrix.job-description }}
  55. runs-on: ${{ matrix.operating-system }}
  56. steps:
  57. - name: Checkout code
  58. uses: actions/checkout@v2
  59. - name: Get code coverage driver
  60. uses: actions/github-script@v3.1
  61. id: code-coverage-driver
  62. with:
  63. script: 'return "${{ matrix.calculate-code-coverage }}" == "yes" ? "pcov" : "none"'
  64. result-encoding: string
  65. - name: Setup PHP
  66. uses: shivammathur/setup-php@v2
  67. with:
  68. php-version: ${{ matrix.php-version }}
  69. coverage: ${{ steps.code-coverage-driver.outputs.result }}
  70. tools: flex
  71. env:
  72. fail-fast: false # disabled as old PHP version cannot run flex
  73. - name: Get Composer cache directory
  74. id: composer-cache
  75. run: echo "::set-output name=dir::$(composer config cache-dir)"
  76. - name: Cache dependencies
  77. uses: actions/cache@v2
  78. with:
  79. path: ${{ steps.composer-cache.outputs.dir }}
  80. key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-${{ matrix.composer-flags }}
  81. restore-keys: |
  82. composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-
  83. composer-${{ runner.os }}-${{ matrix.php-version }}-
  84. composer-${{ runner.os }}-
  85. composer-
  86. - name: Configure Symfony Flex
  87. if: matrix.execute-flex-with-symfony-version
  88. run: composer config extra.symfony.require ${{ matrix.execute-flex-with-symfony-version }}
  89. - name: Install dependencies
  90. uses: nick-invision/retry@v2
  91. with:
  92. timeout_minutes: 5
  93. max_attempts: 5
  94. retry_wait_seconds: 30
  95. command: |
  96. composer update --optimize-autoloader --no-interaction --no-progress ${{ matrix.composer-flags }}
  97. composer info -D
  98. - name: Execute migration rules
  99. if: matrix.execute-migration-rules == 'yes'
  100. run: php php-cs-fixer fix --rules @PHP73Migration,@PHP71Migration:risky,blank_line_after_opening_tag -q
  101. - name: Run tests
  102. continue-on-error: ${{ matrix.php-version == '8.0' }}
  103. env:
  104. PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.PHP_CS_FIXER_IGNORE_ENV }}
  105. FAST_LINT_TEST_CASES: ${{ matrix.FAST_LINT_TEST_CASES }}
  106. PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER: ${{ matrix.PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER }}
  107. SYMFONY_DEPRECATIONS_HELPER: ${{ matrix.SYMFONY_DEPRECATIONS_HELPER }}
  108. run: vendor/bin/phpunit ${{ matrix.phpunit-flags }}
  109. - name: Upload coverage results to Coveralls
  110. if: matrix.calculate-code-coverage == 'yes'
  111. env:
  112. COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  113. run: php vendor/bin/php-coveralls --verbose
  114. - name: Run PHP CS Fixer
  115. env:
  116. PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.PHP_CS_FIXER_IGNORE_ENV }}
  117. PHP_CS_FIXER_FUTURE_MODE: 1
  118. run: php php-cs-fixer --diff --dry-run -v fix
  119. - name: Execute deployment checks
  120. if: matrix.execute-deployment == 'yes'
  121. run: |
  122. ./dev-tools/build.sh
  123. PHP_CS_FIXER_TEST_ALLOW_SKIPPING_SMOKE_TESTS=0 vendor/bin/phpunit tests/Smoke/
  124. - name: Execute deployment post-hook
  125. if: matrix.execute-deployment == 'yes' && startsWith(github.ref, 'refs/tags/v')
  126. env:
  127. TRAVIS_TOKEN: ${{ secrets.TRAVIS_TOKEN }}
  128. run: |
  129. # ensure that deployment is happening only if tag matches version of PHP CS Fixer
  130. test $(php dev-tools/info-extractor.php | jq -r .version.vnumber) == "${GITHUB_REF#refs/tags/}"
  131. # trigger website update
  132. ./dev-tools/trigger-website.sh ${TRAVIS_TOKEN} ${GITHUB_REF#refs/tags/}