2
0

build.yml 4.2 KB

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