|
| 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 sharding |
| 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-sharding-${{ github.head_ref || github.run_id }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +jobs: |
| 24 | + changes: |
| 25 | + runs-on: ubuntu-latest-low |
| 26 | + |
| 27 | + outputs: |
| 28 | + src: ${{ steps.changes.outputs.src }} |
| 29 | + |
| 30 | + steps: |
| 31 | + - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 |
| 32 | + id: changes |
| 33 | + continue-on-error: true |
| 34 | + with: |
| 35 | + filters: | |
| 36 | + src: |
| 37 | + - '.github/workflows/**' |
| 38 | + - '3rdparty/**' |
| 39 | + - '**/appinfo/**' |
| 40 | + - '**/lib/**' |
| 41 | + - '**/templates/**' |
| 42 | + - '**/tests/**' |
| 43 | + - 'vendor/**' |
| 44 | + - 'vendor-bin/**' |
| 45 | + - '.php-cs-fixer.dist.php' |
| 46 | + - 'composer.json' |
| 47 | + - 'composer.lock' |
| 48 | + - '**.php' |
| 49 | +
|
| 50 | + phpunit-mysql: |
| 51 | + runs-on: ubuntu-latest |
| 52 | + |
| 53 | + needs: changes |
| 54 | + if: needs.changes.outputs.src != 'false' |
| 55 | + |
| 56 | + strategy: |
| 57 | + matrix: |
| 58 | + php-versions: ['8.1'] |
| 59 | + mysql-versions: ['8.4'] |
| 60 | + |
| 61 | + name: Sharding - MySQL ${{ matrix.mysql-versions }} (PHP ${{ matrix.php-versions }}) - database tests |
| 62 | + |
| 63 | + services: |
| 64 | + cache: |
| 65 | + image: ghcr.io/nextcloud/continuous-integration-redis:latest |
| 66 | + ports: |
| 67 | + - 6379:6379/tcp |
| 68 | + options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 69 | + |
| 70 | + mysql: |
| 71 | + image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest |
| 72 | + ports: |
| 73 | + - 4444:3306/tcp |
| 74 | + env: |
| 75 | + MYSQL_ROOT_PASSWORD: rootpassword |
| 76 | + MYSQL_USER: oc_autotest |
| 77 | + MYSQL_PASSWORD: nextcloud |
| 78 | + MYSQL_DATABASE: oc_autotest |
| 79 | + options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10 |
| 80 | + shard1: |
| 81 | + image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest |
| 82 | + ports: |
| 83 | + - 5001:3306/tcp |
| 84 | + env: |
| 85 | + MYSQL_ROOT_PASSWORD: rootpassword |
| 86 | + MYSQL_USER: oc_autotest |
| 87 | + MYSQL_PASSWORD: nextcloud |
| 88 | + MYSQL_DATABASE: nextcloud |
| 89 | + options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10 |
| 90 | + shard2: |
| 91 | + image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest |
| 92 | + ports: |
| 93 | + - 5002:3306/tcp |
| 94 | + env: |
| 95 | + MYSQL_ROOT_PASSWORD: rootpassword |
| 96 | + MYSQL_USER: oc_autotest |
| 97 | + MYSQL_PASSWORD: nextcloud |
| 98 | + MYSQL_DATABASE: nextcloud |
| 99 | + options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10 |
| 100 | + shard3: |
| 101 | + image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest |
| 102 | + ports: |
| 103 | + - 5003:3306/tcp |
| 104 | + env: |
| 105 | + MYSQL_ROOT_PASSWORD: rootpassword |
| 106 | + MYSQL_USER: oc_autotest |
| 107 | + MYSQL_PASSWORD: nextcloud |
| 108 | + MYSQL_DATABASE: nextcloud |
| 109 | + options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10 |
| 110 | + shard4: |
| 111 | + image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest |
| 112 | + ports: |
| 113 | + - 5004:3306/tcp |
| 114 | + env: |
| 115 | + MYSQL_ROOT_PASSWORD: rootpassword |
| 116 | + MYSQL_USER: oc_autotest |
| 117 | + MYSQL_PASSWORD: nextcloud |
| 118 | + MYSQL_DATABASE: nextcloud |
| 119 | + options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10 |
| 120 | + |
| 121 | + steps: |
| 122 | + - name: Checkout server |
| 123 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 |
| 124 | + with: |
| 125 | + submodules: true |
| 126 | + |
| 127 | + - name: Set up php ${{ matrix.php-versions }} |
| 128 | + uses: shivammathur/setup-php@2e947f1f6932d141d076ca441d0e1e881775e95b #v2.31.0 |
| 129 | + with: |
| 130 | + php-version: ${{ matrix.php-versions }} |
| 131 | + # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation |
| 132 | + 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 |
| 133 | + coverage: ${{ matrix.coverage && 'xdebug' || 'none' }} |
| 134 | + ini-file: development |
| 135 | + env: |
| 136 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 137 | + |
| 138 | + - name: Set up dependencies |
| 139 | + run: composer i |
| 140 | + |
| 141 | + - name: Enable ONLY_FULL_GROUP_BY MySQL option |
| 142 | + run: | |
| 143 | + echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword |
| 144 | + echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword |
| 145 | +
|
| 146 | + - name: Set up Nextcloud |
| 147 | + env: |
| 148 | + DB_PORT: 4444 |
| 149 | + SHARDING: 1 |
| 150 | + run: | |
| 151 | + mkdir data |
| 152 | + cp tests/redis.config.php config/ |
| 153 | + cp tests/preseed-config.php config/config.php |
| 154 | + ./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 |
| 155 | + php -f tests/enable_all.php | grep -i -C9999 error && echo "Error during app setup" && exit 1 || exit 0 |
| 156 | +
|
| 157 | + - name: PHPUnit |
| 158 | + run: composer run test:db ${{ matrix.coverage && ' -- --coverage-clover ./clover.db.xml' || '' }} |
| 159 | + |
| 160 | + - name: Upload db code coverage |
| 161 | + if: ${{ !cancelled() && matrix.coverage }} |
| 162 | + uses: codecov/codecov-action@v4.1.1 |
| 163 | + with: |
| 164 | + files: ./clover.db.xml |
| 165 | + flags: phpunit-mysql |
| 166 | + |
| 167 | + - name: Print logs |
| 168 | + if: always() |
| 169 | + run: | |
| 170 | + cat data/nextcloud.log |
| 171 | +
|
| 172 | + summary: |
| 173 | + permissions: |
| 174 | + contents: none |
| 175 | + runs-on: ubuntu-latest-low |
| 176 | + needs: [changes, phpunit-mysql] |
| 177 | + |
| 178 | + if: always() |
| 179 | + |
| 180 | + name: phpunit-mysql-summary |
| 181 | + |
| 182 | + steps: |
| 183 | + - name: Summary status |
| 184 | + run: if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-mysql.result != 'success' }}; then exit 1; fi |
0 commit comments