|
| 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 | + |
| 9 | +name: PHPUnit mysql partitioning |
| 10 | + |
| 11 | +on: |
| 12 | + pull_request: |
| 13 | + schedule: |
| 14 | + - cron: "5 2 * * *" |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: phpunit-mysql-partitioning-${{ github.head_ref || github.run_id }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +jobs: |
| 24 | + changes: |
| 25 | + runs-on: ubuntu-latest-low |
| 26 | + permissions: |
| 27 | + contents: read |
| 28 | + pull-requests: read |
| 29 | + |
| 30 | + outputs: |
| 31 | + src: ${{ steps.changes.outputs.src }} |
| 32 | + |
| 33 | + steps: |
| 34 | + - uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2 |
| 35 | + id: changes |
| 36 | + continue-on-error: true |
| 37 | + with: |
| 38 | + filters: | |
| 39 | + src: |
| 40 | + - '.github/workflows/**' |
| 41 | + - '3rdparty/**' |
| 42 | + - '**/appinfo/**' |
| 43 | + - '**/lib/**' |
| 44 | + - '**/templates/**' |
| 45 | + - '**/tests/**' |
| 46 | + - 'vendor/**' |
| 47 | + - 'vendor-bin/**' |
| 48 | + - '.php-cs-fixer.dist.php' |
| 49 | + - 'composer.json' |
| 50 | + - 'composer.lock' |
| 51 | + - '**.php' |
| 52 | +
|
| 53 | + phpunit-mysql-partitioning: |
| 54 | + runs-on: ubuntu-latest |
| 55 | + |
| 56 | + needs: changes |
| 57 | + if: needs.changes.outputs.src != 'false' |
| 58 | + |
| 59 | + strategy: |
| 60 | + fail-fast: false |
| 61 | + matrix: |
| 62 | + include: |
| 63 | + - mysql-versions: '9.7' |
| 64 | + php-versions: '8.5' |
| 65 | + |
| 66 | + name: MySQL ${{ matrix.mysql-versions }} (PHP ${{ matrix.php-versions }}) - database tests |
| 67 | + |
| 68 | + services: |
| 69 | + cache: |
| 70 | + image: ghcr.io/nextcloud/continuous-integration-redis:latest # zizmor: ignore[unpinned-images] |
| 71 | + ports: |
| 72 | + - 6379:6379/tcp |
| 73 | + options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 74 | + |
| 75 | + mysql: |
| 76 | + image: mysql:${{ matrix.mysql-versions }} # zizmor: ignore[unpinned-images] |
| 77 | + ports: |
| 78 | + - 4444:3306/tcp |
| 79 | + env: |
| 80 | + MYSQL_ROOT_PASSWORD: rootpassword |
| 81 | + MYSQL_USER: oc_autotest |
| 82 | + MYSQL_PASSWORD: nextcloud |
| 83 | + MYSQL_DATABASE: oc_autotest |
| 84 | + options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10 |
| 85 | + |
| 86 | + steps: |
| 87 | + - name: Checkout server |
| 88 | + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 89 | + with: |
| 90 | + persist-credentials: false |
| 91 | + submodules: true |
| 92 | + |
| 93 | + - name: Set up php ${{ matrix.php-versions }} |
| 94 | + uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2 |
| 95 | + timeout-minutes: 5 |
| 96 | + with: |
| 97 | + php-version: ${{ matrix.php-versions }} |
| 98 | + # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation |
| 99 | + 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 |
| 100 | + coverage: none |
| 101 | + ini-file: development |
| 102 | + ini-values: disable_functions="" |
| 103 | + env: |
| 104 | + fail-fast: true |
| 105 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 106 | + |
| 107 | + - name: Set up dependencies |
| 108 | + run: composer i |
| 109 | + |
| 110 | + - name: Enable ONLY_FULL_GROUP_BY MySQL option |
| 111 | + run: | |
| 112 | + echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword |
| 113 | + echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword |
| 114 | +
|
| 115 | + - name: Set up Nextcloud |
| 116 | + env: |
| 117 | + DB_PORT: 4444 |
| 118 | + run: | |
| 119 | + mkdir data |
| 120 | + cp tests/redis.config.php config/ |
| 121 | + cp tests/preseed-config.php config/config.php |
| 122 | + ./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 |
| 123 | + php -f tests/enable_all.php |
| 124 | +
|
| 125 | + - name: Enable sharding for oc_filecache |
| 126 | + run: | |
| 127 | + echo "alter table oc_filecache drop primary key, add primary key (fileid, storage);" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword nextcloud |
| 128 | + echo "alter table oc_filecache partition by hash(storage) partitions 5;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword nextcloud |
| 129 | +
|
| 130 | + - name: PHPUnit |
| 131 | + run: composer run test:db -- --log-junit junit.xml |
| 132 | + env: |
| 133 | + DB_ROOT_USER: root |
| 134 | + DB_ROOT_PASS: rootpassword |
| 135 | + |
| 136 | + - name: Print logs |
| 137 | + if: always() |
| 138 | + run: | |
| 139 | + cat data/nextcloud.log |
| 140 | +
|
| 141 | + summary: |
| 142 | + permissions: |
| 143 | + contents: none |
| 144 | + runs-on: ubuntu-latest-low |
| 145 | + needs: [changes, phpunit-mysql-partitioning] |
| 146 | + |
| 147 | + if: always() |
| 148 | + |
| 149 | + name: phpunit-mysql-partitioning-summary |
| 150 | + |
| 151 | + steps: |
| 152 | + - name: Summary status |
| 153 | + run: if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-mysql.result != 'success' }}; then exit 1; fi |
0 commit comments