build.yml 4.3 KB

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