ci.yml 6.0 KB

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