2
0

build.yml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. PHP_INI: date.timezone=UTC, memory_limit=-1, opcache.enable=1, opcache.enable_cli=1
  12. strategy:
  13. fail-fast: false
  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. - '8.2'
  24. - '8.3'
  25. - '8.4'
  26. - '8.5'
  27. runs-on: ${{ matrix.os }}
  28. steps:
  29. -
  30. name: Checkout
  31. uses: actions/checkout@v4
  32. -
  33. name: Install linux dependencies
  34. if: matrix.os == 'ubuntu-latest'
  35. run: sudo apt-get install unzip p7zip-full
  36. -
  37. name: Install windows dependencies
  38. if: matrix.os == 'windows-latest'
  39. run: choco install zip unzip 7zip
  40. -
  41. name: Install macos dependencies
  42. if: matrix.os == 'macos-latest'
  43. run: brew install zip unzip p7zip
  44. -
  45. name: Disable JIT for PHP 8 on Linux and Mac
  46. if: (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest') && matrix.php != '7.4'
  47. run: echo "PHP_INI=${PHP_INI}, opcache.jit=0, opcache.jit_buffer_size=0" >> "$GITHUB_ENV"
  48. -
  49. name: Disable JIT for PHP 8 on Windows
  50. if: matrix.os == 'windows-latest' && matrix.php != '7.4'
  51. run: echo "PHP_INI=$env:PHP_INI, opcache.jit=0, opcache.jit_buffer_size=0" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
  52. -
  53. name: Install PHP with extensions
  54. uses: shivammathur/setup-php@v2
  55. with:
  56. php-version: ${{ matrix.php }}
  57. extensions: ${{ env.extensions }}
  58. ini-values: ${{ env.PHP_INI }}
  59. tools: composer:v2
  60. -
  61. name: Determine composer cache directory on Linux or MacOS
  62. if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
  63. run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
  64. -
  65. name: Determine composer cache directory on Windows
  66. if: matrix.os == 'windows-latest'
  67. run: echo "COMPOSER_CACHE_DIR=~\AppData\Local\Composer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
  68. -
  69. name: Cache composer dependencies
  70. uses: actions/cache@v4
  71. with:
  72. path: ${{ env.COMPOSER_CACHE_DIR }}
  73. key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
  74. restore-keys: php${{ matrix.php }}-composer-
  75. -
  76. name: Check PHP Version
  77. run: php -v
  78. -
  79. name: Check Composer Version
  80. run: composer -V
  81. -
  82. name: Check PHP Extensions
  83. run: php -m
  84. -
  85. name: Validate composer.json and composer.lock
  86. run: composer validate
  87. -
  88. name: Install dependencies with composer
  89. run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
  90. -
  91. name: Run tests with phpunit
  92. run: vendor/bin/phpunit -v --testsuite "all_tests" --group small,medium,large
  93. static-analysis:
  94. name: Static analysis (Psalm)
  95. runs-on: ubuntu-latest
  96. env:
  97. extensions: bz2, dom, iconv, fileinfo, openssl, xml, zlib
  98. PHP_INI: date.timezone=UTC, memory_limit=-1
  99. steps:
  100. -
  101. name: Checkout
  102. uses: actions/checkout@v4
  103. -
  104. name: Install PHP with extensions
  105. uses: shivammathur/setup-php@v2
  106. with:
  107. php-version: '8.4'
  108. extensions: ${{ env.extensions }}
  109. ini-values: ${{ env.PHP_INI }}
  110. tools: composer:v2
  111. -
  112. name: Install dependencies with composer
  113. run: composer update --prefer-dist --no-interaction --no-progress --ansi
  114. -
  115. name: Run Psalm
  116. run: vendor/bin/psalm --output-format=github