|
| 1 | +# SPDX-FileCopyrightText: 2020-2024 LibreCode coop and contributors |
| 2 | +# SPDX-License-Identifier: AGPL-3.0-or-later |
| 3 | + |
| 4 | +name: Behat MySQL |
| 5 | + |
| 6 | +on: pull_request |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: behat-mysql-${{ github.head_ref || github.run_id }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + matrix: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + outputs: |
| 19 | + php-version: ${{ steps.versions.outputs.php-available-list }} |
| 20 | + server-max: ${{ steps.versions.outputs.branches-max-list }} |
| 21 | + steps: |
| 22 | + - name: Checkout app |
| 23 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 24 | + with: |
| 25 | + persist-credentials: false |
| 26 | + |
| 27 | + - name: Get version matrix |
| 28 | + id: versions |
| 29 | + uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1 |
| 30 | + with: |
| 31 | + matrix: '{"mysql-versions": ["8.1"]}' |
| 32 | + |
| 33 | + changes: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + |
| 36 | + outputs: |
| 37 | + src: ${{ steps.changes.outputs.src}} |
| 38 | + |
| 39 | + steps: |
| 40 | + - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 |
| 41 | + id: changes |
| 42 | + continue-on-error: true |
| 43 | + with: |
| 44 | + filters: | |
| 45 | + src: |
| 46 | + - '.github/workflows/behat*' |
| 47 | + - 'appinfo/**' |
| 48 | + - 'lib/**' |
| 49 | + - 'templates/**' |
| 50 | + - 'tests/**' |
| 51 | + - '3rdparty/**' |
| 52 | + - 'vendor-bin/**' |
| 53 | + - '.php-cs-fixer.dist.php' |
| 54 | + - 'composer.json' |
| 55 | + - 'composer.lock' |
| 56 | +
|
| 57 | + behat-mysql: |
| 58 | + runs-on: ubuntu-latest |
| 59 | + |
| 60 | + needs: [changes, matrix] |
| 61 | + if: needs.changes.outputs.src != 'false' |
| 62 | + |
| 63 | + strategy: |
| 64 | + matrix: |
| 65 | + php-versions: ${{ fromJson(needs.matrix.outputs.php-version) }} |
| 66 | + server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }} |
| 67 | + mysql-versions: ['8.1'] |
| 68 | + |
| 69 | + name: MySQL ${{ matrix.mysql-versions }} PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }} |
| 70 | + |
| 71 | + services: |
| 72 | + mysql: |
| 73 | + image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest |
| 74 | + ports: |
| 75 | + - 4444:3306/tcp |
| 76 | + env: |
| 77 | + MYSQL_ROOT_PASSWORD: rootpassword |
| 78 | + options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10 |
| 79 | + mailhog: |
| 80 | + image: mailhog/mailhog |
| 81 | + ports: |
| 82 | + - 8025:8025/tcp |
| 83 | + - 1025:1025/tcp |
| 84 | + |
| 85 | + steps: |
| 86 | + - name: Set app env |
| 87 | + run: | |
| 88 | + # Split and keep last |
| 89 | + echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV |
| 90 | +
|
| 91 | + - name: Install system dependencies |
| 92 | + run: sudo apt update && sudo apt install poppler-utils |
| 93 | + |
| 94 | + - name: Checkout server |
| 95 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 96 | + with: |
| 97 | + persist-credentials: false |
| 98 | + submodules: true |
| 99 | + repository: nextcloud/server |
| 100 | + ref: ${{ matrix.server-versions }} |
| 101 | + |
| 102 | + - name: Checkout app |
| 103 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 104 | + with: |
| 105 | + persist-credentials: false |
| 106 | + submodules: true |
| 107 | + path: apps/${{ env.APP_NAME }} |
| 108 | + |
| 109 | + - name: Set up php ${{ matrix.php-versions }} |
| 110 | + uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2 |
| 111 | + with: |
| 112 | + php-version: ${{ matrix.php-versions }} |
| 113 | + tools: phpunit |
| 114 | + # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation |
| 115 | + extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite |
| 116 | + coverage: none |
| 117 | + ini-file: development |
| 118 | + # Temporary workaround for missing pcntl_* in PHP 8.3 |
| 119 | + ini-values: disable_functions= |
| 120 | + env: |
| 121 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 122 | + |
| 123 | + - name: Enable ONLY_FULL_GROUP_BY MySQL option |
| 124 | + run: | |
| 125 | + echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword |
| 126 | + echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword |
| 127 | +
|
| 128 | + - name: Check composer file existence |
| 129 | + id: check_composer |
| 130 | + uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0 |
| 131 | + with: |
| 132 | + files: apps/${{ env.APP_NAME }}/composer.json |
| 133 | + |
| 134 | + - name: Set up dependencies |
| 135 | + # Only run if phpunit config file exists |
| 136 | + if: steps.check_composer.outputs.files_exists == 'true' |
| 137 | + working-directory: apps/${{ env.APP_NAME }} |
| 138 | + run: | |
| 139 | + composer remove nextcloud/ocp --dev --no-scripts |
| 140 | + composer install --no-dev |
| 141 | + composer --working-dir=tests/integration install |
| 142 | +
|
| 143 | + - name: Set up Nextcloud |
| 144 | + env: |
| 145 | + DB_PORT: 4444 |
| 146 | + run: | |
| 147 | + sudo echo "127.0.0.1 mailhog" | sudo tee -a /etc/hosts |
| 148 | + mkdir data |
| 149 | + ./occ maintenance:install \ |
| 150 | + --verbose \ |
| 151 | + --database=mysql \ |
| 152 | + --database-name=nextcloud \ |
| 153 | + --database-host=127.0.0.1 \ |
| 154 | + --database-port=$DB_PORT \ |
| 155 | + --database-user=root \ |
| 156 | + --database-pass=rootpassword \ |
| 157 | + --admin-user admin \ |
| 158 | + --admin-pass admin |
| 159 | + ./occ --version |
| 160 | + ./occ app:enable --force ${{ env.APP_NAME }} |
| 161 | + git clone --depth 1 -b ${{ matrix.server-versions }} https://github.com/nextcloud/notifications apps/notifications |
| 162 | + ./occ app:enable --force notifications |
| 163 | + git clone --depth 1 -b ${{ matrix.server-versions }} https://github.com/nextcloud/activity apps/activity |
| 164 | + ./occ app:enable --force activity |
| 165 | + git clone --depth 1 -b main https://github.com/nextcloud/guests apps/guests |
| 166 | + ./occ app:enable --force guests |
| 167 | + ./occ config:system:set mail_smtpport --value 1025 --type integer |
| 168 | + ./occ config:system:set mail_smtphost --value mailhog |
| 169 | + ./occ config:system:set allow_local_remote_servers --value true --type boolean |
| 170 | + ./occ config:system:set auth.bruteforce.protection.enabled --value false --type boolean |
| 171 | + ./occ config:app:set dav enableDefaultContact --value false --type boolean |
| 172 | +
|
| 173 | + - name: Run behat |
| 174 | + working-directory: apps/${{ env.APP_NAME }}/tests/integration |
| 175 | + env: |
| 176 | + BEHAT_ROOT_DIR: ../../../../ |
| 177 | + run: | |
| 178 | + export BEHAT_RUN_AS=runner |
| 179 | + export BEHAT_VERBOSE="$RUNNER_DEBUG" |
| 180 | + vendor/bin/behat -f junit -f pretty --colors |
| 181 | +
|
| 182 | + - name: Print logs |
| 183 | + if: always() |
| 184 | + run: | |
| 185 | + cat data/nextcloud.log |
| 186 | +
|
| 187 | + summary: |
| 188 | + permissions: |
| 189 | + contents: none |
| 190 | + runs-on: ubuntu-latest |
| 191 | + needs: [changes, behat-mysql] |
| 192 | + |
| 193 | + if: always() |
| 194 | + |
| 195 | + name: behat-mysql-summary |
| 196 | + |
| 197 | + steps: |
| 198 | + - name: Summary status |
| 199 | + run: if ${{ needs.changes.outputs.src != 'false' && needs.behat-mysql.result != 'success' }}; then exit 1; fi |
0 commit comments