ci.yml 7.0 KB

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