ci.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. name: CI
  2. on:
  3. - pull_request
  4. - push
  5. permissions:
  6. contents: read # to fetch code (actions/checkout)
  7. concurrency:
  8. group: ci-${{ github.head_ref || github.run_id }} # will be canceled on subsequent pushes in pull requests but not branches
  9. cancel-in-progress: true
  10. env:
  11. PHP_MAX: '8.3'
  12. PHP_MIN: '7.4'
  13. jobs:
  14. tests:
  15. strategy:
  16. fail-fast: false
  17. matrix:
  18. include:
  19. - operating-system: 'ubuntu-20.04'
  20. php-version: '7.4'
  21. job-description: 'Fixer with lowest deps'
  22. run-fixer: 'yes'
  23. composer-flags: '--prefer-lowest' # should be checked on the lowest supported PHP version
  24. execute-flex-with-symfony-version: '^5' # explicit check for Symfony 5.x compatibility
  25. - operating-system: 'ubuntu-20.04'
  26. php-version: '7.4'
  27. job-description: 'tests with lowest deps'
  28. run-tests: 'yes'
  29. composer-flags: '--prefer-lowest' # should be checked on the lowest supported PHP version
  30. execute-flex-with-symfony-version: '^5' # explicit check for Symfony 5.x compatibility
  31. - operating-system: 'ubuntu-20.04'
  32. php-version: '8.0'
  33. job-description: 'Fixer'
  34. run-fixer: 'yes'
  35. - operating-system: 'ubuntu-20.04'
  36. php-version: '8.0'
  37. job-description: 'tests'
  38. run-tests: 'yes'
  39. - operating-system: 'ubuntu-20.04'
  40. php-version: '8.1'
  41. job-description: 'Fixer with Symfony ^6'
  42. run-fixer: 'yes'
  43. execute-flex-with-symfony-version: '^6' # explicit check for Symfony 6.x compatibility
  44. - operating-system: 'ubuntu-20.04'
  45. php-version: '8.1'
  46. job-description: 'tests with Symfony ^6'
  47. run-tests: 'yes'
  48. execute-flex-with-symfony-version: '^6' # explicit check for Symfony 6.x compatibility
  49. - operating-system: 'ubuntu-20.04'
  50. php-version: '8.2'
  51. job-description: 'Fixer'
  52. run-fixer: 'yes'
  53. - operating-system: 'ubuntu-20.04'
  54. php-version: '8.2'
  55. job-description: 'tests'
  56. run-tests: 'yes'
  57. - operating-system: 'ubuntu-20.04'
  58. php-version: '8.3'
  59. job-description: 'Fixer'
  60. run-fixer: 'yes'
  61. - operating-system: 'ubuntu-20.04'
  62. php-version: '8.3'
  63. job-description: 'tests'
  64. run-tests: 'yes'
  65. - operating-system: 'ubuntu-20.04'
  66. php-version: '8.3'
  67. job-description: 'Fixer with migration rules'
  68. run-fixer: 'yes'
  69. run-migration-rules: 'yes' # should be checked on the highest supported PHP version
  70. - operating-system: 'ubuntu-20.04'
  71. php-version: '8.3'
  72. job-description: 'tests with migration rules'
  73. run-tests: 'yes'
  74. run-migration-rules: 'yes' # should be checked on the highest supported PHP version
  75. - operating-system: 'ubuntu-20.04'
  76. php-version: '8.3'
  77. job-description: 'Fixer with Symfony ^7'
  78. run-fixer: 'yes'
  79. execute-flex-with-symfony-version: '^7' # explicit check for Symfony 7.x compatibility
  80. - operating-system: 'ubuntu-20.04'
  81. php-version: '8.3'
  82. job-description: 'tests with Symfony ^7'
  83. run-tests: 'yes'
  84. execute-flex-with-symfony-version: '^7' # explicit check for Symfony 7.x compatibility
  85. - operating-system: 'ubuntu-20.04'
  86. php-version: '8.3'
  87. job-description: 'code coverage'
  88. run-tests: 'yes'
  89. collect-code-coverage: 'yes'
  90. - operating-system: 'ubuntu-20.04'
  91. php-version: '8.3'
  92. job-description: 'mutation tests'
  93. run-mutation-tests: 'yes'
  94. - operating-system: 'windows-latest'
  95. php-version: '8.3'
  96. job-description: 'Fixer on Windows'
  97. run-fixer: 'yes'
  98. FAST_LINT_TEST_CASES: 1 # we need full syntax check on one job at least, no need to do it on additional
  99. - operating-system: 'windows-latest'
  100. php-version: '8.3'
  101. job-description: 'tests on Windows'
  102. run-tests: 'yes'
  103. FAST_LINT_TEST_CASES: 1 # we need full syntax check on one job at least, no need to do it on additional systems
  104. - operating-system: 'macos-latest'
  105. php-version: '8.3'
  106. job-description: 'Fixer on macOS'
  107. run-fixer: 'yes'
  108. FAST_LINT_TEST_CASES: 1 # we need full syntax check on one job at least, no need to do it on additional systems
  109. - operating-system: 'macos-latest'
  110. php-version: '8.3'
  111. job-description: 'tests on macOS'
  112. run-tests: 'yes'
  113. FAST_LINT_TEST_CASES: 1 # we need full syntax check on one job at least, no need to do it on additional
  114. - operating-system: 'ubuntu-22.04'
  115. php-version: '8.4'
  116. job-description: 'Fixer'
  117. run-fixer: 'yes'
  118. PHP_CS_FIXER_IGNORE_ENV: 1
  119. - operating-system: 'ubuntu-22.04'
  120. php-version: '8.4'
  121. job-description: 'tests'
  122. run-tests: 'yes'
  123. PHP_CS_FIXER_IGNORE_ENV: 1
  124. name: PHP ${{ matrix.php-version }} ${{ matrix.job-description }}
  125. runs-on: ${{ matrix.operating-system }}
  126. steps:
  127. - name: Checkout code
  128. uses: actions/checkout@v4
  129. - name: Remove Infection requirement if not needed
  130. if: matrix.run-mutation-tests != 'yes'
  131. run: composer remove --dev infection/infection --no-update
  132. - name: Setup PHP with Composer deps
  133. uses: ./.github/composite-actions/setup-php-with-composer-deps
  134. with:
  135. os: ${{ runner.os }}
  136. php: ${{ matrix.php-version }}
  137. php-coverage: ${{ matrix.collect-code-coverage || matrix.run-mutation-tests }}
  138. composer-flags: ${{ matrix.composer-flags }}
  139. composer-flex-with-symfony-version: ${{ matrix.execute-flex-with-symfony-version }}
  140. # Execute migration rules before running tests and self-fixing,
  141. # so we know that our codebase is future-ready.
  142. # Should be checked on the highest supported PHP version.
  143. - name: Run PHP CS Fixer with migration rules
  144. if: env.PHP_MAX == matrix.php-version && matrix.run-migration-rules == 'yes'
  145. env:
  146. PHP_CS_FIXER_FUTURE_MODE: 1
  147. run: php php-cs-fixer fix --config .php-cs-fixer.php-highest.php -q
  148. - name: Custom PHPUnit config with v10 alignments
  149. if: matrix.collect-code-coverage == 'yes' || matrix.run-mutation-tests
  150. run: sed -e 's/enforceTimeLimit="true"/enforceTimeLimit="false"/g' -e 's/coverage/source/g' phpunit.xml.dist > phpunit.xml
  151. - name: Disable time limit for tests under Windows # due to https://github.com/sebastianbergmann/phpunit/issues/5589
  152. if: matrix.operating-system == 'windows-latest'
  153. run: (Get-Content phpunit.xml.dist) -replace 'enforceTimeLimit="true"', 'enforceTimeLimit="false"' | Out-File phpunit.xml
  154. - name: Fix PHP 8.4 deprecations for tests
  155. if: matrix.run-tests == 'yes' && matrix.php-version == '8.4'
  156. env:
  157. PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.PHP_CS_FIXER_IGNORE_ENV }}
  158. run: php php-cs-fixer fix --rules=no_unreachable_default_argument_value,nullable_type_declaration_for_default_null_value --diff vendor
  159. - name: Run tests
  160. if: matrix.run-tests == 'yes' && matrix.collect-code-coverage != 'yes'
  161. env:
  162. PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.PHP_CS_FIXER_IGNORE_ENV }}
  163. FAST_LINT_TEST_CASES: ${{ matrix.FAST_LINT_TEST_CASES }}
  164. run: vendor/bin/paraunit run --testsuite unit,integration
  165. - name: Run tests with "short_open_tag" enabled
  166. if: matrix.run-tests == 'yes' && matrix.collect-code-coverage != 'yes'
  167. env:
  168. PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.PHP_CS_FIXER_IGNORE_ENV }}
  169. FAST_LINT_TEST_CASES: ${{ matrix.FAST_LINT_TEST_CASES }}
  170. run: composer test:short-open-tag
  171. - name: Run tests and collect code coverage
  172. if: matrix.run-tests == 'yes' && matrix.collect-code-coverage == 'yes'
  173. env:
  174. FAST_LINT_TEST_CASES: 1
  175. run: vendor/bin/paraunit coverage --testsuite unit --pass-through=--exclude-group=covers-nothing --clover=build/logs/clover.xml
  176. - name: Run mutation tests (Infection)
  177. # Run only on pull requests because we run mutations tests only for diff between branches
  178. if: github.event_name == 'pull_request' && matrix.run-mutation-tests == 'yes'
  179. env:
  180. FAST_LINT_TEST_CASES: 1
  181. run: |
  182. git fetch origin $GITHUB_BASE_REF
  183. vendor/bin/infection --threads=max --map-source-class-to-test --git-diff-lines --git-diff-base=origin/$GITHUB_BASE_REF --ignore-msi-with-no-mutations --only-covered
  184. - name: Upload coverage results to Coveralls
  185. if: matrix.run-tests == 'yes' && matrix.collect-code-coverage == 'yes'
  186. env:
  187. COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  188. run: php vendor/bin/php-coveralls --verbose
  189. - name: Run PHP CS Fixer
  190. if: matrix.run-fixer == 'yes'
  191. env:
  192. PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.PHP_CS_FIXER_IGNORE_ENV }}
  193. PHP_CS_FIXER_FUTURE_MODE: 1
  194. run: php php-cs-fixer check --diff -v
  195. # Should be checked on the lowest supported PHP version.
  196. # If any type can be converted from PHPDoc to native type on lowest supported PHP, we should commit such change.
  197. - name: Run PHP CS Fixer with PHPDoc to type rules
  198. if: env.PHP_MIN == matrix.php-version && matrix.run-fixer == 'yes'
  199. env:
  200. PHP_CS_FIXER_FUTURE_MODE: 1
  201. run: php php-cs-fixer check --diff -vvv --config .php-cs-fixer.php-lowest.php
  202. deployment:
  203. needs: tests
  204. strategy:
  205. fail-fast: false
  206. matrix:
  207. include:
  208. - operating-system: 'ubuntu-20.04'
  209. php-version: '8.2'
  210. name: Deployment checks
  211. runs-on: ${{ matrix.operating-system }}
  212. steps:
  213. - name: Checkout code
  214. uses: actions/checkout@v4
  215. - name: Remove Infection
  216. run: composer remove --dev infection/infection --no-update
  217. - name: Setup PHP with Composer deps
  218. uses: ./.github/composite-actions/setup-php-with-composer-deps
  219. with:
  220. os: ${{ runner.os }}
  221. php: ${{ matrix.php-version }}
  222. - name: Cache dev-tools
  223. uses: actions/cache@v3
  224. with:
  225. path: dev-tools/bin/
  226. key: Build-${{ hashFiles('dev-tools/build.sh') }}
  227. - name: Build phar
  228. run: ./dev-tools/build.sh
  229. - name: Run smoke tests
  230. env:
  231. FAST_LINT_TEST_CASES: 1
  232. run: vendor/bin/phpunit --testsuite smoke