From d79e91c97e90f9dbf2de907a9a2708fbdba9544b Mon Sep 17 00:00:00 2001
From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com>
Date: Sun, 6 Dec 2026 00:09:21 +0100
Subject: [PATCH] ci: run the SQLite and PostgreSQL PHP tests in 3 shards each
(#12834)
---
.github/workflows/actions.lock | 1 +
.github/workflows/test-suite.yaml | 71 ++++++++++++++++++++++++++----
.github/workflows/tests-pgsql.yaml | 10 ++---
phpunit.pgsql.xml | 17 ++++---
phpunit.xml | 40 +++++++++++++++++
scripts/test-ratchet | 5 ++-
tests/known-failures-pgsql.txt | 2 +-
7 files changed, 123 insertions(+), 23 deletions(-)
diff --git a/.github/workflows/actions.lock b/.github/workflows/actions.lock
index 47f354d660..2d520cc4ca 100644
--- a/.github/workflows/actions.lock
+++ b/.github/workflows/actions.lock
@@ -43,6 +43,7 @@ workflows:
'.github/workflows/test-suite.yaml':
- 'actions/cache@v6.1.0'
- 'actions/checkout@v7.0.1'
+ - 'actions/download-artifact@v8.0.2'
- 'actions/upload-artifact@v7.0.2'
- 'shivammathur/setup-php@2.40.0'
'.github/workflows/tests-pgsql.yaml':
diff --git a/.github/workflows/test-suite.yaml b/.github/workflows/test-suite.yaml
index 2f84b604c3..4d746255b6 100644
--- a/.github/workflows/test-suite.yaml
+++ b/.github/workflows/test-suite.yaml
@@ -1,5 +1,9 @@
name: Tests
+# The PHP tests run in 3 shards on 3 runners (the Shard1, Shard2 and Shard3 suites of phpunit.xml), so that a
+# pull request waits less. The ratchet job checks the JUnit files of all shards together against
+# tests/known-failures.txt and keeps the check name "PHP tests".
+
on:
pull_request:
branches: [main, next]
@@ -21,7 +25,11 @@ defaults:
jobs:
php:
- name: PHP tests
+ name: PHP tests shard ${{ matrix.shard }} of 3
+ strategy:
+ fail-fast: false
+ matrix:
+ shard: [1, 2, 3]
permissions:
contents: read
runs-on: ubuntu-26.04 # https://github.com/actions/runner-images
@@ -59,24 +67,71 @@ jobs:
npm ci --no-audit --no-fund
npm run build
- - name: Run the Feature, Unit, and Golden tests and check them against the known failures
+ - name: Run one shard of the Feature, Unit, and Golden tests
env:
- JUNIT: ${{ runner.temp }}/junit.xml
+ JUNIT: ${{ runner.temp }}/shard/junit.xml
+ SHARD: ${{ matrix.shard }}
run: |
+ mkdir -p "$(dirname "$JUNIT")"
status=0
# The Reverb open-file limit tests need a hard limit above 65536, which only root can raise.
sudo prlimit --pid $$ --nofile=:1048576
- php artisan test --compact --parallel --testsuite=Feature,Unit,Golden --log-junit "$JUNIT" || status=$?
- scripts/test-ratchet --junit "$JUNIT" --exit-code "$status"
+ php artisan test --compact --parallel --testsuite="Shard$SHARD" --log-junit "$JUNIT" || status=$?
+ echo "$status" > "$(dirname "$JUNIT")/exit-code"
- - name: Upload the JUnit report
+ - name: Upload the JUnit report of the shard
if: ${{ always() }}
uses: actions/upload-artifact@v7.0.2
with:
- name: junit-php
- path: ${{ runner.temp }}/junit.xml
+ name: junit-php-shard-${{ matrix.shard }}
+ path: ${{ runner.temp }}/shard
if-no-files-found: ignore
+ ratchet:
+ name: PHP tests
+ needs: php
+ if: ${{ !cancelled() }}
+ permissions:
+ contents: read
+ runs-on: ubuntu-26.04 # https://github.com/actions/runner-images
+ timeout-minutes: 10
+ steps:
+ - name: Check out the repository
+ uses: actions/checkout@v7.0.1
+ with:
+ persist-credentials: false
+
+ - name: Set up PHP 8.4, the version of the production image
+ uses: shivammathur/setup-php@2.40.0
+ with:
+ php-version: "8.4"
+ coverage: none
+
+ - name: Download the JUnit reports of the shards
+ uses: actions/download-artifact@v8.0.2
+ with:
+ pattern: junit-php-shard-*
+ path: ${{ runner.temp }}/shards
+
+ - name: Check the tests of all shards against the known failures
+ env:
+ SHARDS: ${{ runner.temp }}/shards
+ SHARD_JOBS: ${{ needs.php.result }}
+ run: |
+ if [ "$SHARD_JOBS" != success ]; then
+ echo "A shard job failed before its tests finished."
+ exit 1
+ fi
+ status=0
+ junits=()
+ for shard in 1 2 3; do
+ dir="$SHARDS/junit-php-shard-$shard"
+ junits+=(--junit "$dir/junit.xml")
+ code=$(cat "$dir/exit-code")
+ if [ "$code" -gt "$status" ]; then status=$code; fi
+ done
+ scripts/test-ratchet "${junits[@]}" --exit-code "$status"
+
js:
name: JavaScript tests
permissions:
diff --git a/.github/workflows/tests-pgsql.yaml b/.github/workflows/tests-pgsql.yaml
index 47cf64a904..4a2b4be04e 100644
--- a/.github/workflows/tests-pgsql.yaml
+++ b/.github/workflows/tests-pgsql.yaml
@@ -4,8 +4,8 @@ name: Tests on PostgreSQL
# runs on SQLite, which hides boolean, CHECK constraint and foreign key behavior.
# The ratchet checks the run against tests/known-failures-pgsql.txt: it fails on a new failure
# and on a listed test that passes.
-# The tests run in 2 shards on 2 runners (the Shard1 and Shard2 suites of phpunit.pgsql.xml), because one
-# 4-vCPU runner needs about 14 minutes for all of them. The last job checks the JUnit files of both shards
+# The tests run in 3 shards on 3 runners (the Shard1, Shard2 and Shard3 suites of phpunit.pgsql.xml), because
+# one 4-vCPU runner needs about 17 minutes for all of them. The last job checks the JUnit files of all shards
# together and keeps the check name "PHP tests (PostgreSQL)".
on:
@@ -29,11 +29,11 @@ defaults:
jobs:
php:
- name: PHP tests (PostgreSQL) shard ${{ matrix.shard }} of 2
+ name: PHP tests (PostgreSQL) shard ${{ matrix.shard }} of 3
strategy:
fail-fast: false
matrix:
- shard: [1, 2]
+ shard: [1, 2, 3]
permissions:
contents: read
runs-on: ubuntu-26.04 # https://github.com/actions/runner-images
@@ -145,7 +145,7 @@ jobs:
fi
status=0
junits=()
- for shard in 1 2; do
+ for shard in 1 2 3; do
dir="$SHARDS/junit-php-pgsql-shard-$shard"
junits+=(--junit "$dir/junit.xml")
code=$(cat "$dir/exit-code")
diff --git a/phpunit.pgsql.xml b/phpunit.pgsql.xml
index aa8b6d2df7..155fa98633 100644
--- a/phpunit.pgsql.xml
+++ b/phpunit.pgsql.xml
@@ -21,14 +21,18 @@
./tests/Golden
./tests/Feature
./tests/Feature
./tests/Feature
+ ./tests/Unit
+
+
./tests/Feature
./tests/Feature
./tests/Feature
@@ -41,9 +45,10 @@
./tests/Feature
./tests/Feature
./tests/Feature
-
-
./tests/Feature
+ ./tests/Golden
+
+
./tests/Feature
./tests/Feature
./tests/Feature
@@ -54,8 +59,6 @@
./tests/Feature
./tests/Feature
./tests/Feature
- ./tests/Unit
- ./tests/Golden
diff --git a/phpunit.xml b/phpunit.xml
index a2e127ff8b..9f0101d5d7 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -13,6 +13,46 @@
./tests/Golden
+
+
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Unit
+
+
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Golden
+
+
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+ ./tests/Feature
+
diff --git a/scripts/test-ratchet b/scripts/test-ratchet
index 2ac5bb2fd2..053faae4df 100755
--- a/scripts/test-ratchet
+++ b/scripts/test-ratchet
@@ -28,8 +28,9 @@
* (for example one fixes tests while another adds the ratchet or breaks a known test), the branch
* that merges second must rebase, run `scripts/test-ratchet --update`, and commit the new list.
* Review the diff of the list: --update can add new failures, and only removed lines are normal.
- * The CI job uploads its JUnit file as the `junit-php` artifact. To take the list from a CI run:
- * scripts/test-ratchet --update --junit
+ * The CI shard jobs upload their JUnit files as the `junit-php-shard-1` to `junit-php-shard-3` artifacts.
+ * To take the list from a CI run:
+ * scripts/test-ratchet --update --junit --junit --junit
* Local runs need the Vite manifest (npm ci && npm run build), like the CI job.
*/
diff --git a/tests/known-failures-pgsql.txt b/tests/known-failures-pgsql.txt
index b1cd31e3a0..c3d0d22014 100644
--- a/tests/known-failures-pgsql.txt
+++ b/tests/known-failures-pgsql.txt
@@ -1,7 +1,7 @@
# Known failing tests of the PostgreSQL lane (.github/workflows/tests-pgsql.yaml, phpunit.pgsql.xml).
# The test ratchet fails when a test fails that is not in this list, and when a listed test passes.
# Remove a line when you fix its test. When this list has no plain lines, the lane can be a required check.
-# Regenerate with: scripts/test-ratchet --update --list tests/known-failures-pgsql.txt --junit --junit (the artifacts of a CI run)
+# Regenerate with: scripts/test-ratchet --update --list tests/known-failures-pgsql.txt --junit --junit --junit (the artifacts of a CI run)
tests/Feature/Api/DestinationsApiTest.php::`POST /api/v1/servers/{server_uuid}/destinations` → returns conflict when the database unique constraint wins a create race
tests/Feature/AuditEventsTest.php::audit persistence failures do not fail the action
tests/Feature/AuditEventsTest.php::auditable model mutations succeed when audit persistence fails