ci.yml 6.3 KB

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