tests.yml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. name: Tests
  2. on: [ pull_request, push ]
  3. jobs:
  4. ubuntu:
  5. runs-on: ubuntu-latest
  6. services:
  7. memcached:
  8. image: memcached:1.6-alpine
  9. ports:
  10. - 11211:11211
  11. mysql:
  12. image: mysql:5.7
  13. env:
  14. MYSQL_ALLOW_EMPTY_PASSWORD: yes
  15. MYSQL_DATABASE: forge
  16. ports:
  17. - 33306:3306
  18. options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
  19. redis:
  20. image: redis:5.0
  21. ports:
  22. - 6379:6379
  23. options: --entrypoint redis-server
  24. dynamodb:
  25. image: amazon/dynamodb-local:latest
  26. ports:
  27. - 8888:8000
  28. strategy:
  29. fail-fast: false
  30. matrix:
  31. include:
  32. - php: 7.1.8
  33. - php: 7.1.28
  34. - php: 7.1
  35. - php: 7.1
  36. setup: lowest
  37. - php: 7.2.0
  38. - php: 7.2.15
  39. - php: 7.2
  40. - php: 7.2
  41. setup: lowest
  42. - php: 7.3.0
  43. - php: 7.3.5
  44. - php: 7.3
  45. - php: 7.3
  46. setup: lowest
  47. - php: 7.4
  48. - php: 7.4
  49. setup: lowest
  50. - php: 8.0
  51. classmap-authoritative: true
  52. - php: 8.0
  53. - php: 8.0
  54. setup: lowest
  55. - php: 8.1
  56. - php: 8.1
  57. setup: lowest
  58. - php: 8.2
  59. - php: 8.2
  60. setup: lowest
  61. - php: 8.3
  62. - php: 8.3
  63. setup: lowest
  64. - php: 8.1
  65. laravel: true
  66. reference: 10.x
  67. - php: 8.1
  68. laravel: true
  69. reference: 10.x
  70. classmap-authoritative: true
  71. - php: 8.2
  72. laravel: true
  73. reference: master
  74. - php: 8.2
  75. laravel: true
  76. reference: master
  77. classmap-authoritative: true
  78. - php: 8.2
  79. coverage: true
  80. name: ${{ matrix.laravel && 'Laravel compatibility - ' || '' }}${{ matrix.classmap-authoritative && 'classmap-authoritative - ' || '' }}${{ matrix.coverage && 'Coverage - ' || '' }}PHP ${{ matrix.php }} - ${{ matrix.setup || 'stable' }} - ubuntu
  81. steps:
  82. - name: Checkout the code
  83. uses: actions/checkout@v4
  84. - name: Setup PHP
  85. uses: shivammathur/setup-php@v2
  86. with:
  87. php-version: ${{ matrix.php }}
  88. extensions: json, msgpack${{ matrix.laravel && ', dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, redis-phpredis/phpredis@5.3.5, igbinary, msgpack, lzf, zstd, lz4, memcached, gmp' || '' }}
  89. ini-values: error_reporting=${{ (matrix.setup != 'lowest') && '32767' || '8191' }}
  90. tools: composer:v2
  91. coverage: ${{ matrix.coverage && 'pcov' || 'none' }}
  92. env:
  93. REDIS_CONFIGURE_OPTS: --enable-redis --enable-redis-igbinary --enable-redis-msgpack --enable-redis-lzf --with-liblzf --enable-redis-zstd --with-libzstd --enable-redis-lz4 --with-liblz4
  94. REDIS_LIBS: liblz4-dev, liblzf-dev, libzstd-dev
  95. - name: Install locales
  96. run: |
  97. sudo apt-get update || apt --fix-broken install || echo 'Apt failure ignored'
  98. sudo apt-get install tzdata locales -y && sudo locale-gen fr_FR.UTF-8 sr_ME.UTF-8 ar_AE.UTF-8 zh_TW.UTF-8 zh_CN.UTF-8 yo_NG.UTF-8 en_US.UTF-8 || echo 'Apt failure ignored'
  99. - name: Set Minimum PHP 8.1 Versions
  100. uses: nick-invision/retry@v2
  101. with:
  102. timeout_minutes: 5
  103. max_attempts: 5
  104. command: composer require ramsey/collection:^1.2 brick/math:^0.9.3 --no-interaction --no-update
  105. if: matrix.laravel
  106. - name: Get composer cache directory
  107. id: composer-cache-ubuntu
  108. run: echo "dir=$(composer config cache-files-dir)" > $GITHUB_OUTPUT
  109. - name: Cache composer dependencies
  110. uses: actions/cache@v3
  111. with:
  112. path: ${{ steps.composer-cache-ubuntu.outputs.dir }}
  113. key: "php-${{ matrix.php }}-${{ matrix.setup }}-ubuntu-${{ hashFiles('**/composer.json') }}"
  114. restore-keys: "php-${{ matrix.php }}-${{ matrix.setup }}-ubuntu-${{ hashFiles('**/composer.json') }}"
  115. - name: Install dependencies
  116. uses: nick-fields/retry@v2
  117. if: steps.composer-cache.outputs.cache-hit != 'true'
  118. with:
  119. timeout_minutes: 10
  120. max_attempts: 3
  121. command: |
  122. composer remove --no-update phpmd/phpmd friendsofphp/php-cs-fixer --no-interaction --dev;
  123. if [[ "${{ matrix.laravel }}" != 'true' ]]; then
  124. composer remove --no-update kylekatarnls/multi-tester --no-interaction --dev;
  125. fi;
  126. ${{ matrix.php >= 8.1 && 'composer require --no-update phpunit/phpunit:^9.5.20 --no-interaction --dev;' || '' }}
  127. composer update --prefer-dist --no-progress --prefer-${{ matrix.setup || 'stable' }} ${{ matrix.classmap-authoritative && '--classmap-authoritative' || '' }}${{ matrix.php >= 8.2 && ' --ignore-platform-reqs' || '' }};
  128. - name: Run test suite
  129. run: |
  130. if [[ "${{ matrix.laravel }}" != 'true' && "${{ matrix.coverage }}" = 'true' ]]; then
  131. php -d memory_limit=-1 -d zend.enable_gc=0 -d error_reporting=-1 vendor/phpunit/phpunit/phpunit --coverage-clover=clover.xml --coverage-text;
  132. fi;
  133. if [[ "${{ matrix.laravel }}" != 'true' && "${{ matrix.coverage }}" != 'true' ]]; then
  134. php -d memory_limit=-1 -d zend.enable_gc=0 -d error_reporting=-1 vendor/phpunit/phpunit/phpunit;
  135. fi;
  136. if [[ "${{ matrix.laravel }}" = 'true' ]]; then
  137. vendor/bin/multi-tester tests/Laravel/laravel-${{ matrix.reference }}.multi-tester.yml;
  138. fi;
  139. env:
  140. PHP_VERSION: ${{ matrix.php }}
  141. REDIS_HOST: 127.0.0.1
  142. REDIS_PORT: 6379
  143. DB_PORT: ${{ job.services.mysql.ports[3306] }}
  144. DB_USERNAME: root
  145. - name: Code Climate Test Reporter
  146. if: matrix.coverage
  147. uses: aktions/codeclimate-test-reporter@v1
  148. with:
  149. codeclimate-test-reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }}
  150. command: after-build -t clover
  151. env:
  152. ACTIONS_ALLOW_UNSECURE_COMMANDS: true
  153. continue-on-error: true
  154. - name: Coverage
  155. uses: codecov/codecov-action@v3
  156. if: matrix.coverage
  157. windows:
  158. runs-on: windows-latest
  159. strategy:
  160. fail-fast: false
  161. matrix:
  162. include:
  163. - php: 7.1.8
  164. - php: 7.1.28
  165. - php: 7.1
  166. - php: 7.1
  167. setup: lowest
  168. - php: 7.2.0
  169. - php: 7.2.15
  170. - php: 7.2
  171. - php: 7.2
  172. setup: lowest
  173. - php: 7.3.0
  174. - php: 7.3.5
  175. - php: 7.3
  176. - php: 7.3
  177. setup: lowest
  178. - php: 7.4
  179. coverage: true
  180. - php: 7.4
  181. setup: lowest
  182. - php: 8.0
  183. - php: 8.0
  184. setup: lowest
  185. - php: 8.1
  186. - php: 8.1
  187. setup: lowest
  188. - php: 8.2
  189. - php: 8.2
  190. setup: lowest
  191. - php: 8.3
  192. - php: 8.3
  193. setup: lowest
  194. name: PHP ${{ matrix.php }} - ${{ matrix.setup || 'stable' }} - windows
  195. steps:
  196. - name: Checkout the code
  197. uses: actions/checkout@v4
  198. - name: Setup PHP
  199. uses: shivammathur/setup-php@v2
  200. with:
  201. php-version: ${{ matrix.php }}
  202. extensions: json
  203. tools: composer:v2
  204. coverage: none
  205. - name: Get composer cache directory
  206. id: composer-cache-windows
  207. shell: bash
  208. run: echo "dir=$(composer config cache-files-dir)" > $GITHUB_OUTPUT
  209. - name: Cache composer dependencies
  210. uses: actions/cache@v3
  211. with:
  212. path: ${{ steps.composer-cache-windows.outputs.dir }}
  213. key: "php-${{ matrix.php }}-${{ matrix.setup }}-windows-${{ hashFiles('**/composer.json') }}"
  214. restore-keys: "php-${{ matrix.php }}-${{ matrix.setup }}-windows-${{ hashFiles('**/composer.json') }}"
  215. - name: Install dependencies
  216. uses: nick-fields/retry@v2
  217. with:
  218. timeout_minutes: 10
  219. max_attempts: 3
  220. command: |
  221. composer remove --no-update kylekatarnls/multi-tester phpmd/phpmd friendsofphp/php-cs-fixer --no-interaction --dev;
  222. ${{ matrix.php >= 8.1 && 'composer require --no-update phpunit/phpunit:^9.5.20 --no-interaction --dev;' || '' }}
  223. composer update --prefer-dist --no-progress --prefer-${{ matrix.setup || 'stable' }}${{ matrix.php >= 8.2 && ' --ignore-platform-reqs' || '' }};
  224. - name: Run test suite
  225. run: |
  226. php -d memory_limit=-1 -d zend.enable_gc=0 -d error_reporting=-1 vendor/phpunit/phpunit/phpunit;
  227. env:
  228. PHP_VERSION: ${{ matrix.php }}
  229. REDIS_HOST: 127.0.0.1
  230. REDIS_PORT: 6379