|
| 1 | +# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | + |
| 4 | +name: PHPUnit Redis |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: phpunit-redis-${{ github.head_ref || github.run_id }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +env: |
| 17 | + REDIS_IMAGE: redis:8 |
| 18 | + |
| 19 | +jobs: |
| 20 | + changes: |
| 21 | + runs-on: ubuntu-latest-low |
| 22 | + |
| 23 | + outputs: |
| 24 | + src: ${{ steps.changes.outputs.src}} |
| 25 | + |
| 26 | + steps: |
| 27 | + - uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1 |
| 28 | + id: changes |
| 29 | + continue-on-error: true |
| 30 | + with: |
| 31 | + filters: | |
| 32 | + src: |
| 33 | + - '.github/workflows/phpunit-redis.yml' |
| 34 | + - '3rdparty/**' |
| 35 | + - '**/appinfo/**' |
| 36 | + - '**.php' |
| 37 | +
|
| 38 | + phpunit-redis: |
| 39 | + runs-on: ubuntu-latest |
| 40 | + |
| 41 | + needs: changes |
| 42 | + if: needs.changes.outputs.src != 'false' |
| 43 | + |
| 44 | + strategy: |
| 45 | + fail-fast: false |
| 46 | + matrix: |
| 47 | + php-versions: ["8.3", "8.5"] |
| 48 | + # The two supported topologies for the Redis cache |
| 49 | + topology: ["single", "cluster"] |
| 50 | + include: |
| 51 | + - topology: single |
| 52 | + config-file: redis.config.php |
| 53 | + - topology: cluster |
| 54 | + config-file: redis-cluster.config.php |
| 55 | + |
| 56 | + name: Redis ${{ matrix.topology }} (PHP ${{ matrix.php-versions }}) |
| 57 | + |
| 58 | + steps: |
| 59 | + - name: Checkout server |
| 60 | + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 61 | + with: |
| 62 | + persist-credentials: false |
| 63 | + submodules: true |
| 64 | + |
| 65 | + - name: Set up php ${{ matrix.php-versions }} |
| 66 | + uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 #v2.37.2 |
| 67 | + timeout-minutes: 5 |
| 68 | + with: |
| 69 | + php-version: ${{ matrix.php-versions }} |
| 70 | + # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation |
| 71 | + extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, pdo_sqlite, posix, redis, session, simplexml, sqlite, xmlreader, xmlwriter, zip, zlib |
| 72 | + coverage: none |
| 73 | + ini-file: development |
| 74 | + ini-values: disable_functions="" |
| 75 | + env: |
| 76 | + fail-fast: true |
| 77 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + |
| 79 | + - name: Start Redis (single server) |
| 80 | + if: matrix.topology == 'single' |
| 81 | + run: | |
| 82 | + docker run -d --name redis-single -p 6379:6379 "${REDIS_IMAGE}" |
| 83 | + timeout 60 sh -c 'until docker exec redis-single redis-cli ping | grep -q PONG; do sleep 1; done' |
| 84 | +
|
| 85 | + - name: Start Redis (cluster) |
| 86 | + if: matrix.topology == 'cluster' |
| 87 | + run: | |
| 88 | + for port in 7000 7001 7002 7003 7004 7005; do |
| 89 | + docker run -d --name "redis-cluster-$port" --network host "${REDIS_IMAGE}" \ |
| 90 | + redis-server --port "$port" --cluster-enabled yes \ |
| 91 | + --cluster-config-file "nodes-$port.conf" --cluster-node-timeout 5000 \ |
| 92 | + --appendonly no --save "" |
| 93 | + done |
| 94 | + # Wait for every node to answer before forming the cluster |
| 95 | + for port in 7000 7001 7002 7003 7004 7005; do |
| 96 | + timeout 60 sh -c "until docker exec redis-cluster-$port redis-cli -p $port ping | grep -q PONG; do sleep 1; done" |
| 97 | + done |
| 98 | + docker exec redis-cluster-7000 redis-cli --cluster create \ |
| 99 | + 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 \ |
| 100 | + 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 \ |
| 101 | + --cluster-replicas 1 --cluster-yes |
| 102 | +
|
| 103 | + - name: Set up dependencies |
| 104 | + run: composer i |
| 105 | + |
| 106 | + - name: Set up Nextcloud |
| 107 | + run: | |
| 108 | + mkdir data |
| 109 | + cp tests/${{ matrix.config-file }} config/ |
| 110 | + cp tests/preseed-config.php config/config.php |
| 111 | + ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin |
| 112 | + php -f tests/enable_all.php |
| 113 | +
|
| 114 | + - name: PHPUnit Redis tests |
| 115 | + run: composer run test -- --group Redis --log-junit junit.xml |
| 116 | + |
| 117 | + - name: Print logs |
| 118 | + if: always() |
| 119 | + run: | |
| 120 | + cat data/nextcloud.log |
| 121 | +
|
| 122 | + summary: |
| 123 | + permissions: |
| 124 | + contents: none |
| 125 | + runs-on: ubuntu-latest-low |
| 126 | + needs: [changes, phpunit-redis] |
| 127 | + |
| 128 | + if: always() |
| 129 | + |
| 130 | + name: phpunit-redis-summary |
| 131 | + |
| 132 | + steps: |
| 133 | + - name: Summary status |
| 134 | + run: if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-redis.result != 'success' }}; then exit 1; fi |
0 commit comments