build.yml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. name: build
  2. on:
  3. - push
  4. - pull_request
  5. jobs:
  6. tests:
  7. name: PHP ${{ matrix.php }} Test on ${{ matrix.os }}
  8. env:
  9. extensions: bz2, dom, iconv, fileinfo, openssl, xml, zlib
  10. key: cache-v1
  11. PHPUNIT_COVERAGE: 0
  12. PHP_INI: date.timezone='UTC', memory_limit=-1, opcache.enable=1, opcache.enable_cli=1
  13. strategy:
  14. matrix:
  15. os:
  16. - ubuntu-latest
  17. - windows-latest
  18. - macos-latest
  19. php:
  20. - '7.4'
  21. - '8.0'
  22. - '8.1'
  23. runs-on: ${{ matrix.os }}
  24. steps:
  25. -
  26. name: Checkout
  27. uses: actions/checkout@v1
  28. -
  29. name: Install linux dependencies
  30. if: matrix.os == 'ubuntu-latest'
  31. run: sudo apt-get install unzip p7zip-full
  32. -
  33. name: Install windows dependencies
  34. if: matrix.os == 'windows-latest'
  35. run: choco install zip unzip 7zip
  36. -
  37. name: Install macos dependencies
  38. if: matrix.os == 'macos-latest'
  39. run: brew install zip unzip p7zip
  40. -
  41. name: Disable JIT for PHP 8 on Linux and Mac
  42. if: (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest') && matrix.php != '7.4'
  43. run: echo "PHP_INI=\"${PHP_INI}, opcache.jit=0, opcache.jit_buffer_size=0\"" >> $GITHUB_ENV
  44. -
  45. name: Disable JIT for PHP 8 on Windows
  46. if: matrix.os == 'windows-latest' && matrix.php != '7.4'
  47. run: echo "PHP_INI=\"$PHP_INI, opcache.jit=0, opcache.jit_buffer_size=0\"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
  48. -
  49. name: Install PHP with extensions
  50. uses: shivammathur/setup-php@v2
  51. with:
  52. php-version: ${{ matrix.php }}
  53. extensions: ${{ env.extensions }}
  54. coverage: pcov
  55. ini-values: ${{ env.PHP_INI }}
  56. tools: composer:v2, cs2pr
  57. -
  58. name: Determine composer cache directory on Linux or MacOS
  59. if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
  60. run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
  61. -
  62. name: Determine composer cache directory on Windows
  63. if: matrix.os == 'windows-latest'
  64. run: echo "COMPOSER_CACHE_DIR=~\AppData\Local\Composer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
  65. -
  66. name: Set coverage args
  67. if: matrix.os == 'ubuntu-latest' && matrix.php == '7.4'
  68. run: echo "PHPUNIT_COVERAGE=1" >> $GITHUB_ENV
  69. -
  70. name: Cache composer dependencies
  71. uses: actions/cache@v2
  72. with:
  73. path: ${{ env.COMPOSER_CACHE_DIR }}
  74. key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
  75. restore-keys: php${{ matrix.php }}-composer-
  76. -
  77. name: Check PHP Version
  78. run: php -v
  79. -
  80. name: Check Composer Version
  81. run: composer -V
  82. -
  83. name: Check PHP Extensions
  84. run: php -m
  85. -
  86. name: Validate composer.json and composer.lock
  87. run: composer validate
  88. -
  89. name: Install dependencies with composer
  90. run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
  91. -
  92. name: Run tests with phpunit
  93. if: env.PHPUNIT_COVERAGE == 0
  94. run: vendor/bin/phpunit -v --testsuite "all_tests" --group small,medium,large
  95. -
  96. name: Run tests with phpunit and coverage
  97. if: env.PHPUNIT_COVERAGE == 1
  98. run: vendor/bin/phpunit -v --coverage-clover=coverage.clover --testsuite "all_tests" --group small,medium,large
  99. -
  100. name: Static analysis
  101. run: vendor/bin/psalm --shepherd --stats --output-format=checkstyle | cs2pr --graceful-warnings --colorize
  102. -
  103. name: Upload code coverage scrutinizer
  104. if: env.PHPUNIT_COVERAGE == 1
  105. run: |
  106. wget https://scrutinizer-ci.com/ocular.phar
  107. php ocular.phar code-coverage:upload --format=php-clover coverage.clover