phpunit-mariadb.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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: 2023-2024 Nextcloud GmbH and Nextcloud contributors
  7. # SPDX-License-Identifier: MIT
  8. name: PHPUnit MariaDB
  9. on:
  10. pull_request:
  11. schedule:
  12. - cron: "5 2 * * *"
  13. permissions:
  14. contents: read
  15. concurrency:
  16. group: phpunit-mariadb-${{ 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-mariadb:
  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. mariadb-versions: ['10.3', '10.6', '10.11', '11.4']
  50. include:
  51. - php-versions: '8.3'
  52. mariadb-versions: '10.11'
  53. coverage: ${{ github.event_name != 'pull_request' }}
  54. name: MariaDB ${{ matrix.mariadb-versions }} (PHP ${{ matrix.php-versions }}) - database tests
  55. services:
  56. cache:
  57. image: ghcr.io/nextcloud/continuous-integration-redis:latest
  58. ports:
  59. - 6379:6379/tcp
  60. options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
  61. mariadb:
  62. image: mariadb:${{ matrix.mariadb-versions }}
  63. ports:
  64. - 4444:3306/tcp
  65. env:
  66. MYSQL_ROOT_PASSWORD: rootpassword
  67. MYSQL_USER: oc_autotest
  68. MYSQL_PASSWORD: nextcloud
  69. MYSQL_DATABASE: oc_autotest
  70. options: --health-cmd="${{ matrix.mariadb-versions <= 10.4 && 'mysqladmin' || 'mariadb-admin'}} ping" --health-interval 5s --health-timeout 2s --health-retries 5
  71. steps:
  72. - name: Checkout server
  73. uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  74. with:
  75. submodules: true
  76. - name: Set up php ${{ matrix.php-versions }}
  77. uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 #v2.31.1
  78. with:
  79. php-version: ${{ matrix.php-versions }}
  80. # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
  81. 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
  82. coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
  83. ini-file: development
  84. env:
  85. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  86. - name: Set up dependencies
  87. run: composer i
  88. - name: Enable ONLY_FULL_GROUP_BY MariaDB option
  89. run: |
  90. echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
  91. echo 'SELECT @@sql_mode;' | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
  92. - name: Set up Nextcloud
  93. env:
  94. DB_PORT: 4444
  95. run: |
  96. mkdir data
  97. cp tests/redis.config.php config/
  98. cp tests/preseed-config.php config/config.php
  99. ./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
  100. php -f tests/enable_all.php | grep -i -C9999 error && echo "Error during app setup" && exit 1 || exit 0
  101. - name: PHPUnit
  102. run: composer run test:db ${{ matrix.coverage && ' -- --coverage-clover ./clover.db.xml' || '' }}
  103. - name: Upload db code coverage
  104. if: ${{ !cancelled() && matrix.coverage }}
  105. uses: codecov/codecov-action@v4.5.0
  106. with:
  107. files: ./clover.db.xml
  108. flags: phpunit-mariadb
  109. summary:
  110. permissions:
  111. contents: none
  112. runs-on: ubuntu-latest-low
  113. needs: [changes, phpunit-mariadb]
  114. if: always()
  115. name: phpunit-mariadb-summary
  116. steps:
  117. - name: Summary status
  118. run: if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-mariadb.result != 'success' }}; then exit 1; fi