build.yml 4.6 KB

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