|
| 1 | +# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | + |
| 4 | +name: PHPUnit key-value store |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: phpunit-kvstore-${{ github.head_ref || github.run_id }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +env: |
| 17 | + VALKEY_IMAGE: valkey/valkey: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-kvstore.yml' |
| 34 | + - '3rdparty/**' |
| 35 | + - '**/appinfo/**' |
| 36 | + - '**.php' |
| 37 | +
|
| 38 | + phpunit-kvstore: |
| 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 three supported topologies for the key-value store cache |
| 49 | + topology: ["single", "cluster", "sentinel"] |
| 50 | + |
| 51 | + name: KV store ${{ matrix.topology }} (PHP ${{ matrix.php-versions }}) |
| 52 | + |
| 53 | + steps: |
| 54 | + - name: Checkout server |
| 55 | + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 56 | + with: |
| 57 | + persist-credentials: false |
| 58 | + submodules: true |
| 59 | + |
| 60 | + - name: Set up php ${{ matrix.php-versions }} |
| 61 | + uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 #v2.37.2 |
| 62 | + timeout-minutes: 5 |
| 63 | + with: |
| 64 | + php-version: ${{ matrix.php-versions }} |
| 65 | + # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation |
| 66 | + extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, pdo_sqlite, posix, session, simplexml, sqlite, xmlreader, xmlwriter, zip, zlib |
| 67 | + coverage: none |
| 68 | + ini-file: development |
| 69 | + ini-values: disable_functions="" |
| 70 | + env: |
| 71 | + fail-fast: true |
| 72 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + |
| 74 | + - name: Start Valkey (single server) |
| 75 | + if: matrix.topology == 'single' |
| 76 | + run: | |
| 77 | + docker run -d --name kv-single -p 6379:6379 "${VALKEY_IMAGE}" |
| 78 | + timeout 60 sh -c 'until docker exec kv-single valkey-cli ping | grep -q PONG; do sleep 1; done' |
| 79 | +
|
| 80 | + - name: Start Valkey (cluster) |
| 81 | + if: matrix.topology == 'cluster' |
| 82 | + run: | |
| 83 | + for port in 7000 7001 7002 7003 7004 7005; do |
| 84 | + docker run -d --name "kv-cluster-$port" --network host "${VALKEY_IMAGE}" \ |
| 85 | + valkey-server --port "$port" --cluster-enabled yes \ |
| 86 | + --cluster-config-file "nodes-$port.conf" --cluster-node-timeout 5000 \ |
| 87 | + --appendonly no --save "" |
| 88 | + done |
| 89 | + # Wait for every node to answer before forming the cluster |
| 90 | + for port in 7000 7001 7002 7003 7004 7005; do |
| 91 | + timeout 60 sh -c "until docker exec kv-cluster-$port valkey-cli -p $port ping | grep -q PONG; do sleep 1; done" |
| 92 | + done |
| 93 | + docker exec kv-cluster-7000 valkey-cli --cluster create \ |
| 94 | + 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 \ |
| 95 | + 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 \ |
| 96 | + --cluster-replicas 1 --cluster-yes |
| 97 | +
|
| 98 | + - name: Start Valkey (sentinel) |
| 99 | + if: matrix.topology == 'sentinel' |
| 100 | + run: | |
| 101 | + docker run -d --name kv-master --network host "${VALKEY_IMAGE}" \ |
| 102 | + valkey-server --port 6379 |
| 103 | + docker run -d --name kv-replica --network host "${VALKEY_IMAGE}" \ |
| 104 | + valkey-server --port 6380 --replicaof 127.0.0.1 6379 |
| 105 | + printf 'port 26379\nsentinel monitor mymaster 127.0.0.1 6379 1\nsentinel down-after-milliseconds mymaster 5000\nsentinel failover-timeout mymaster 10000\n' > sentinel.conf |
| 106 | + docker run -d --name kv-sentinel --network host -v "$PWD/sentinel.conf:/etc/valkey/sentinel.conf" \ |
| 107 | + "${VALKEY_IMAGE}" valkey-sentinel /etc/valkey/sentinel.conf |
| 108 | + timeout 60 sh -c 'until docker exec kv-sentinel valkey-cli -p 26379 ping | grep -q PONG; do sleep 1; done' |
| 109 | +
|
| 110 | + - name: Set up dependencies |
| 111 | + run: composer i |
| 112 | + |
| 113 | + - name: Set up Nextcloud |
| 114 | + run: | |
| 115 | + mkdir data |
| 116 | + cp tests/kvstore-${{ matrix.topology }}.config.php config/ |
| 117 | + cp tests/preseed-config.php config/config.php |
| 118 | + ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin |
| 119 | + php -f tests/enable_all.php |
| 120 | +
|
| 121 | + - name: PHPUnit key-value store tests |
| 122 | + run: composer run test -- --group KeyValueCache --log-junit junit.xml |
| 123 | + |
| 124 | + - name: Print logs |
| 125 | + if: always() |
| 126 | + run: | |
| 127 | + cat data/nextcloud.log |
| 128 | +
|
| 129 | + summary: |
| 130 | + permissions: |
| 131 | + contents: none |
| 132 | + runs-on: ubuntu-latest-low |
| 133 | + needs: [changes, phpunit-kvstore] |
| 134 | + |
| 135 | + if: always() |
| 136 | + |
| 137 | + name: phpunit-kvstore-summary |
| 138 | + |
| 139 | + steps: |
| 140 | + - name: Summary status |
| 141 | + run: if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-kvstore.result != 'success' }}; then exit 1; fi |
0 commit comments