phpunit-mysql-sharding.yml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. # This workflow is provided via the organization template repository
  2. #
  3. # https://github.com/nextcloud/.github
  4. # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
  5. #
  6. # SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
  7. # SPDX-License-Identifier: MIT
  8. name: PHPUnit sharding
  9. on:
  10. pull_request:
  11. schedule:
  12. - cron: "5 2 * * *"
  13. permissions:
  14. contents: read
  15. concurrency:
  16. group: phpunit-mysql-sharding-${{ github.head_ref || github.run_id }}
  17. cancel-in-progress: true
  18. jobs:
  19. changes:
  20. runs-on: ubuntu-latest-low
  21. outputs:
  22. src: ${{ steps.changes.outputs.src }}
  23. steps:
  24. - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
  25. id: changes
  26. continue-on-error: true
  27. with:
  28. filters: |
  29. src:
  30. - '.github/workflows/**'
  31. - '3rdparty/**'
  32. - '**/appinfo/**'
  33. - '**/lib/**'
  34. - '**/templates/**'
  35. - '**/tests/**'
  36. - 'vendor/**'
  37. - 'vendor-bin/**'
  38. - '.php-cs-fixer.dist.php'
  39. - 'composer.json'
  40. - 'composer.lock'
  41. - '**.php'
  42. phpunit-mysql:
  43. runs-on: ubuntu-latest
  44. needs: changes
  45. if: needs.changes.outputs.src != 'false'
  46. strategy:
  47. matrix:
  48. php-versions: ['8.1']
  49. mysql-versions: ['8.4']
  50. name: Sharding - MySQL ${{ matrix.mysql-versions }} (PHP ${{ matrix.php-versions }}) - database tests
  51. services:
  52. cache:
  53. image: ghcr.io/nextcloud/continuous-integration-redis:latest
  54. ports:
  55. - 6379:6379/tcp
  56. options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
  57. mysql:
  58. image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest
  59. ports:
  60. - 4444:3306/tcp
  61. env:
  62. MYSQL_ROOT_PASSWORD: rootpassword
  63. MYSQL_USER: oc_autotest
  64. MYSQL_PASSWORD: nextcloud
  65. MYSQL_DATABASE: oc_autotest
  66. options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10
  67. shard1:
  68. image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest
  69. ports:
  70. - 5001:3306/tcp
  71. env:
  72. MYSQL_ROOT_PASSWORD: rootpassword
  73. MYSQL_USER: oc_autotest
  74. MYSQL_PASSWORD: nextcloud
  75. MYSQL_DATABASE: nextcloud
  76. options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10
  77. shard2:
  78. image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest
  79. ports:
  80. - 5002:3306/tcp
  81. env:
  82. MYSQL_ROOT_PASSWORD: rootpassword
  83. MYSQL_USER: oc_autotest
  84. MYSQL_PASSWORD: nextcloud
  85. MYSQL_DATABASE: nextcloud
  86. options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10
  87. shard3:
  88. image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest
  89. ports:
  90. - 5003:3306/tcp
  91. env:
  92. MYSQL_ROOT_PASSWORD: rootpassword
  93. MYSQL_USER: oc_autotest
  94. MYSQL_PASSWORD: nextcloud
  95. MYSQL_DATABASE: nextcloud
  96. options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10
  97. shard4:
  98. image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest
  99. ports:
  100. - 5004:3306/tcp
  101. env:
  102. MYSQL_ROOT_PASSWORD: rootpassword
  103. MYSQL_USER: oc_autotest
  104. MYSQL_PASSWORD: nextcloud
  105. MYSQL_DATABASE: nextcloud
  106. options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10
  107. steps:
  108. - name: Checkout server
  109. uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
  110. with:
  111. submodules: true
  112. - name: Set up php ${{ matrix.php-versions }}
  113. uses: shivammathur/setup-php@2e947f1f6932d141d076ca441d0e1e881775e95b #v2.31.0
  114. with:
  115. php-version: ${{ matrix.php-versions }}
  116. # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
  117. extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, redis, session, simplexml, xmlreader, xmlwriter, zip, zlib, mysql, pdo_mysql
  118. coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
  119. ini-file: development
  120. env:
  121. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  122. - name: Set up dependencies
  123. run: composer i
  124. - name: Enable ONLY_FULL_GROUP_BY MySQL option
  125. run: |
  126. echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
  127. echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
  128. - name: Set up Nextcloud
  129. env:
  130. DB_PORT: 4444
  131. SHARDING: 1
  132. run: |
  133. mkdir data
  134. cp tests/redis.config.php config/
  135. cp tests/preseed-config.php config/config.php
  136. ./occ maintenance:install --verbose --database=mysql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin
  137. php -f tests/enable_all.php | grep -i -C9999 error && echo "Error during app setup" && exit 1 || exit 0
  138. - name: PHPUnit
  139. run: composer run test:db ${{ matrix.coverage && ' -- --coverage-clover ./clover.db.xml' || '' }}
  140. - name: Upload db code coverage
  141. if: ${{ !cancelled() && matrix.coverage }}
  142. uses: codecov/codecov-action@v4.1.1
  143. with:
  144. files: ./clover.db.xml
  145. flags: phpunit-mysql
  146. - name: Print logs
  147. if: always()
  148. run: |
  149. cat data/nextcloud.log
  150. summary:
  151. permissions:
  152. contents: none
  153. runs-on: ubuntu-latest-low
  154. needs: [changes, phpunit-mysql]
  155. if: always()
  156. name: phpunit-mysql-summary
  157. steps:
  158. - name: Summary status
  159. run: if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-mysql.result != 'success' }}; then exit 1; fi