ci.yml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. name: CakePHP CI
  2. on:
  3. push:
  4. branches:
  5. - 3.x
  6. - 3.next
  7. pull_request:
  8. branches:
  9. - '*'
  10. jobs:
  11. testsuite:
  12. runs-on: ubuntu-18.04
  13. strategy:
  14. fail-fast: false
  15. matrix:
  16. php-version: ['5.6', '7.4']
  17. db-type: [sqlite, mysql, pgsql]
  18. prefer-lowest: ['']
  19. include:
  20. - php-version: '5.6'
  21. db-type: 'mysql'
  22. prefer-lowest: 'prefer-lowest'
  23. services:
  24. redis:
  25. image: redis
  26. ports:
  27. - 6379/tcp
  28. memcached:
  29. image: memcached
  30. ports:
  31. - 11211/tcp
  32. steps:
  33. - name: Setup MySQL 5.7
  34. if: matrix.db-type == 'mysql' && matrix.php-version != '5.6'
  35. run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql:5.7
  36. - name: Setup MySQL 5.6
  37. if: matrix.db-type == 'mysql' && matrix.php-version == '5.6'
  38. run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql:5.6 --character-set-server=utf8
  39. - name: Setup PostgreSQL latest
  40. if: matrix.db-type == 'pgsql' && matrix.php-version != '5.6'
  41. run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=cakephp -p 5432:5432 -d postgres
  42. - name: Setup PostgreSQL 9.4
  43. if: matrix.db-type == 'pgsql' && matrix.php-version == '5.6'
  44. run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=cakephp -p 5432:5432 -d postgres:9.4
  45. - uses: actions/checkout@v2
  46. - name: Setup PHP
  47. uses: shivammathur/setup-php@v2
  48. with:
  49. php-version: ${{ matrix.php-version }}
  50. extensions: mbstring, intl, apcu, memcached, redis, pdo_${{ matrix.db-type }}
  51. ini-values: apc.enable_cli = 1
  52. coverage: pcov
  53. - name: Get composer cache directory
  54. id: composer-cache
  55. run: echo "::set-output name=dir::$(composer config cache-files-dir)"
  56. - name: Get date part for cache key
  57. id: key-date
  58. run: echo "::set-output name=date::$(date +'%Y-%m')"
  59. - name: Cache composer dependencies
  60. uses: actions/cache@v1
  61. with:
  62. path: ${{ steps.composer-cache.outputs.dir }}
  63. key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
  64. - name: Install packages
  65. run: |
  66. sudo locale-gen da_DK.UTF-8
  67. sudo locale-gen de_DE.UTF-8
  68. - name: Composer install
  69. run: |
  70. if [[ ${{ matrix.php-version }} == '8.0' ]]; then
  71. composer install --ignore-platform-reqs
  72. elif ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
  73. composer update --prefer-lowest --prefer-stable
  74. else
  75. composer update
  76. fi
  77. if [[ ${{ matrix.php-version }} == '7.4' ]]; then
  78. composer require --dev pcov/clobber
  79. fi
  80. - name: Configure PHPUnit matcher
  81. if: matrix.php-version == '7.4' && matrix.db-type == 'mysql'
  82. run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
  83. - name: Run PHPUnit
  84. env:
  85. REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
  86. MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
  87. run: |
  88. if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export db_dsn='sqlite:///:memory:'; fi
  89. if [[ ${{ matrix.db-type }} == 'mysql' && ${{ matrix.php-version }} != '5.6' ]]; then export db_dsn='mysql://root:root@127.0.0.1/cakephp?init[]=SET sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"'; fi
  90. if [[ ${{ matrix.db-type }} == 'mysql' && ${{ matrix.php-version }} == '5.6' ]]; then export db_dsn='mysql://root:root@127.0.0.1/cakephp?encoding=utf8'; fi
  91. if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export db_dsn='postgres://postgres:postgres@127.0.0.1/postgres'; fi
  92. if [[ ${{ matrix.php-version }} == '7.4' ]]; then
  93. export CODECOVERAGE=1 && vendor/bin/pcov clobber; vendor/bin/phpunit --coverage-clover=coverage.xml
  94. else
  95. vendor/bin/phpunit
  96. fi
  97. - name: Submit code coverage
  98. if: matrix.php-version == '7.4'
  99. uses: codecov/codecov-action@v1
  100. testsuite-windows:
  101. runs-on: windows-2019
  102. name: Windows - PHP 7.4 & SQL Server
  103. env:
  104. EXTENSIONS: mbstring, intl, apcu, pdo_sqlsrv
  105. PHP_VERSION: '7.4'
  106. steps:
  107. - uses: actions/checkout@v2
  108. - name: Get date part for cache key
  109. id: key-date
  110. run: echo "::set-output name=date::$(date +'%Y-%m')"
  111. - name: Setup PHP extensions cache
  112. id: php-ext-cache
  113. uses: shivammathur/cache-extensions@v1
  114. with:
  115. php-version: ${{ env.PHP_VERSION }}
  116. extensions: ${{ env.EXTENSIONS }}
  117. key: ${{ steps.key-date.outputs.date }}
  118. - name: Cache PHP extensions
  119. uses: actions/cache@v1
  120. with:
  121. path: ${{ steps.php-ext-cache.outputs.dir }}
  122. key: ${{ runner.os }}-php-ext-${{ steps.php-ext-cache.outputs.key }}
  123. restore-keys: ${{ runner.os }}-php-ext-${{ steps.php-ext-cache.outputs.key }}
  124. - name: Setup PHP
  125. uses: shivammathur/setup-php@v2
  126. with:
  127. php-version: ${{ env.PHP_VERSION }}
  128. extensions: ${{ env.EXTENSIONS }}
  129. ini-values: apc.enable_cli = 1, extension = php_fileinfo.dll
  130. tools: composer:v1
  131. coverage: none
  132. - name: Setup SQLServer
  133. run: |
  134. # MSSQLLocalDB is the default SQL LocalDB instance
  135. SqlLocalDB start MSSQLLocalDB
  136. SqlLocalDB info MSSQLLocalDB
  137. sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "create database cakephp;"
  138. - name: Get composer cache directory
  139. id: composer-cache
  140. run: echo "::set-output name=dir::$(composer config cache-files-dir)"
  141. - name: Cache composer dependencies
  142. uses: actions/cache@v1
  143. with:
  144. path: ${{ steps.composer-cache.outputs.dir }}
  145. key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
  146. - name: Composer install
  147. run: composer update
  148. - name: Run PHPUnit
  149. env:
  150. db_dsn: 'sqlserver://@(localdb)\MSSQLLocalDB/cakephp'
  151. run: |
  152. vendor/bin/phpunit --verbose
  153. cs-stan:
  154. name: Coding Standard & Static Analysis
  155. runs-on: ubuntu-18.04
  156. steps:
  157. - uses: actions/checkout@v2
  158. - name: Setup PHP
  159. uses: shivammathur/setup-php@v2
  160. with:
  161. php-version: '7.2'
  162. extensions: mbstring, intl, apcu, memcached, redis
  163. coverage: none
  164. - name: Get composer cache directory
  165. id: composer-cache
  166. run: echo "::set-output name=dir::$(composer config cache-files-dir)"
  167. - name: Get date part for cache key
  168. id: key-date
  169. run: echo "::set-output name=date::$(date +'%Y-%m')"
  170. - name: Cache composer dependencies
  171. uses: actions/cache@v1
  172. with:
  173. path: ${{ steps.composer-cache.outputs.dir }}
  174. key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}
  175. - name: Composer install
  176. run: |
  177. composer update
  178. composer phpstan-setup
  179. - name: Run PHP CodeSniffer
  180. run: composer cs-check
  181. - name: Run phpstan
  182. run: composer phpstan