Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions .github/workflows/phpunit-redis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT

name: PHPUnit Redis

on:
pull_request:

permissions:
contents: read

concurrency:
group: phpunit-redis-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
REDIS_IMAGE: redis:8

jobs:
changes:
runs-on: ubuntu-latest-low

outputs:
src: ${{ steps.changes.outputs.src}}

steps:
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
id: changes
continue-on-error: true
with:
filters: |
src:
- '.github/workflows/phpunit-redis.yml'
- '3rdparty/**'
- '**/appinfo/**'
- '**.php'

phpunit-redis:
runs-on: ubuntu-latest

needs: changes
if: needs.changes.outputs.src != 'false'

strategy:
fail-fast: false
matrix:
php-versions: ["8.3", "8.5"]
# The two supported topologies for the Redis cache
topology: ["single", "cluster"]
include:
- topology: single
config-file: redis.config.php
- topology: cluster
config-file: redis-cluster.config.php

name: Redis ${{ matrix.topology }} (PHP ${{ matrix.php-versions }})

steps:
- name: Checkout server
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
submodules: true

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 #v2.37.2
timeout-minutes: 5
with:
php-version: ${{ matrix.php-versions }}
# https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
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
coverage: none
ini-file: development
ini-values: disable_functions=""
env:
fail-fast: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Start Redis (single server)
if: matrix.topology == 'single'
run: |
docker run -d --name redis-single -p 6379:6379 "${REDIS_IMAGE}"
timeout 60 sh -c 'until docker exec redis-single redis-cli ping | grep -q PONG; do sleep 1; done'

- name: Start Redis (cluster)
if: matrix.topology == 'cluster'
run: |
for port in 7000 7001 7002 7003 7004 7005; do
docker run -d --name "redis-cluster-$port" --network host "${REDIS_IMAGE}" \
redis-server --port "$port" --cluster-enabled yes \
--cluster-config-file "nodes-$port.conf" --cluster-node-timeout 5000 \
--appendonly no --save ""
done
# Wait for every node to answer before forming the cluster
for port in 7000 7001 7002 7003 7004 7005; do
timeout 60 sh -c "until docker exec redis-cluster-$port redis-cli -p $port ping | grep -q PONG; do sleep 1; done"
done
docker exec redis-cluster-7000 redis-cli --cluster create \
127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 \
127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 \
--cluster-replicas 1 --cluster-yes

- name: Set up dependencies
run: composer i

- name: Set up Nextcloud
run: |
mkdir data
cp tests/${{ matrix.config-file }} config/
cp tests/preseed-config.php config/config.php
./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin
php -f tests/enable_all.php

- name: PHPUnit Redis tests
run: composer run test -- --group Redis --log-junit junit.xml

- name: Print logs
if: always()
run: |
cat data/nextcloud.log

summary:
permissions:
contents: none
runs-on: ubuntu-latest-low
needs: [changes, phpunit-redis]

if: always()

name: phpunit-redis-summary

steps:
- name: Summary status
run: if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-redis.result != 'success' }}; then exit 1; fi
27 changes: 27 additions & 0 deletions LICENSES/PHP-3.01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
The PHP License, version 3.01

Copyright (c) 1999 - 2012 The PHP Group. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, is permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. The name "PHP" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact group@php.net.

4. Products derived from this software may not be called "PHP", nor may "PHP" appear in their name, without prior written permission from group@php.net. You may indicate that your software works in conjunction with PHP by saying "Foo for PHP" instead of calling it "PHP Foo" or "phpfoo"

5. The PHP Group may publish revised and/or new versions of the license from time to time. Each version will be given a distinguishing version number. Once covered code has been published under a particular version of the license, you may always continue to use it under the terms of that version. You may also choose to use such covered code under the terms of any subsequent version of the license published by the PHP Group. No one other than the PHP Group has the right to modify the terms applicable to covered code created under this License.

6. Redistributions of any form whatsoever must retain the following acknowledgment: "This product includes PHP software, freely available from <http://www.php.net/software/>".

THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This software consists of voluntary contributions made by many individuals on behalf of the PHP Group.

The PHP Group can be contacted via Email at group@php.net.

For more information on the PHP Group and the PHP project, please see <http://www.php.net>.

PHP includes the Zend Engine, freely available at <http://www.zend.com>.
10 changes: 0 additions & 10 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4049,11 +4049,6 @@
<code><![CDATA[mixed]]></code>
</LessSpecificImplementedReturnType>
</file>
<file src="lib/private/Memcache/Redis.php">
<FalsableReturnStatement>
<code><![CDATA[is_int($value) ? (string)$value : json_encode($value)]]></code>
</FalsableReturnStatement>
</file>
<file src="lib/private/Preview/Storage/LocalPreviewStorage.php">
<FalsableReturnStatement>
<code><![CDATA[file_put_contents($previewPath, $stream)]]></code>
Expand All @@ -4072,11 +4067,6 @@
<code><![CDATA[$instance === '']]></code>
</RedundantCondition>
</file>
<file src="lib/private/RedisFactory.php">
<InvalidArgument>
<code><![CDATA[\RedisCluster::OPT_SLAVE_FAILOVER]]></code>
</InvalidArgument>
</file>
<file src="lib/private/Repair/RemoveLinkShares.php">
<InvalidPropertyAssignmentValue>
<code><![CDATA[$this->userToNotify]]></code>
Expand Down
Loading
Loading