phpunit-mariadb.yml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. name: PHPUnit mariadb
  6. on:
  7. pull_request:
  8. schedule:
  9. - cron: "5 2 * * *"
  10. permissions:
  11. contents: read
  12. concurrency:
  13. group: phpunit-mariadb-${{ github.head_ref || github.run_id }}
  14. cancel-in-progress: true
  15. jobs:
  16. changes:
  17. runs-on: ubuntu-latest-low
  18. outputs:
  19. src: ${{ steps.changes.outputs.src}}
  20. steps:
  21. - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
  22. id: changes
  23. continue-on-error: true
  24. with:
  25. filters: |
  26. src:
  27. - '.github/workflows/**'
  28. - '3rdparty/**'
  29. - '**/appinfo/**'
  30. - '**/lib/**'
  31. - '**/templates/**'
  32. - '**/tests/**'
  33. - 'vendor/**'
  34. - 'vendor-bin/**'
  35. - '.php-cs-fixer.dist.php'
  36. - 'composer.json'
  37. - 'composer.lock'
  38. - '**.php'
  39. phpunit-mariadb:
  40. runs-on: ubuntu-latest
  41. needs: changes
  42. if: needs.changes.outputs.src != 'false'
  43. strategy:
  44. matrix:
  45. php-versions: ['8.1']
  46. mariadb-versions: ['10.3', '10.5', '10.6', '10.11']
  47. include:
  48. - php-versions: '8.3'
  49. mariadb-versions: '10.6'
  50. coverage: ${{ github.event_name != 'pull_request' }}
  51. name: MariaDB ${{ matrix.mariadb-versions }} (PHP ${{ matrix.php-versions }}) - database tests
  52. services:
  53. cache:
  54. image: ghcr.io/nextcloud/continuous-integration-redis:latest
  55. ports:
  56. - 6379:6379/tcp
  57. options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
  58. mariadb:
  59. image: mariadb:${{ matrix.mariadb-versions }}
  60. ports:
  61. - 4444:3306/tcp
  62. env:
  63. MYSQL_ROOT_PASSWORD: rootpassword
  64. MYSQL_USER: oc_autotest
  65. MYSQL_PASSWORD: nextcloud
  66. MYSQL_DATABASE: oc_autotest
  67. options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5
  68. steps:
  69. - name: Checkout server
  70. uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
  71. with:
  72. submodules: true
  73. - name: Set up php ${{ matrix.php-versions }}
  74. uses: shivammathur/setup-php@4bd44f22a98a19e0950cbad5f31095157cc9621b # v2
  75. with:
  76. php-version: ${{ matrix.php-versions }}
  77. # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
  78. 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
  79. coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
  80. ini-file: development
  81. env:
  82. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  83. - name: Set up dependencies
  84. run: composer i
  85. - name: Enable ONLY_FULL_GROUP_BY MySQL option
  86. run: |
  87. echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
  88. echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
  89. - name: Set up Nextcloud
  90. env:
  91. DB_PORT: 4444
  92. run: |
  93. mkdir data
  94. cp tests/redis.config.php config/
  95. cp tests/preseed-config.php config/config.php
  96. ./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
  97. php -f tests/enable_all.php | grep -i -C9999 error && echo "Error during app setup" && exit 1 || exit 0
  98. - name: PHPUnit
  99. run: composer run test:db ${{ matrix.coverage && ' -- --coverage-clover ./clover.db.xml' || '' }}
  100. - name: Upload db code coverage
  101. if: ${{ !cancelled() && matrix.coverage }}
  102. uses: codecov/codecov-action@v4.1.1
  103. with:
  104. files: ./clover.db.xml
  105. flags: phpunit-mariadb
  106. - name: Print logs
  107. if: always()
  108. run: |
  109. cat data/nextcloud.log
  110. summary:
  111. permissions:
  112. contents: none
  113. runs-on: ubuntu-latest-low
  114. needs: [changes, phpunit-mariadb]
  115. if: always()
  116. name: phpunit-mariadb-summary
  117. steps:
  118. - name: Summary status
  119. run: if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-mariadb.result != 'success' }}; then exit 1; fi