From ac3ee323a1bc2a4b6928392adca851606b458d02 Mon Sep 17 00:00:00 2001 From: Rushaway Date: Sun, 29 Nov 2026 16:01:44 +0100 Subject: [PATCH 1/7] chore(ci): cancel the outdated run when a pull request is pushed again Every workflow that runs on pull requests gets a concurrency group keyed on the PR number, with cancel-in-progress. Other events (push, tag, schedule, manual) key on the run id, so they never cancel or queue behind each other. Refs #115 --- .github/workflows/api-contract.yml | 7 +++++++ .github/workflows/docs-build.yml | 7 +++++++ .github/workflows/docs-screenshots-build.yml | 7 +++++++ .github/workflows/e2e.yml | 7 +++++++ .github/workflows/phpstan.yml | 7 +++++++ .github/workflows/plugin-build.yml | 7 +++++++ .github/workflows/test.yml | 7 +++++++ .github/workflows/translations.yml | 7 +++++++ .github/workflows/ts-check.yml | 7 +++++++ CHANGELOG.md | 7 +++++++ 10 files changed, 70 insertions(+) diff --git a/.github/workflows/api-contract.yml b/.github/workflows/api-contract.yml index ca7369a76..d66c13117 100644 --- a/.github/workflows/api-contract.yml +++ b/.github/workflows/api-contract.yml @@ -20,6 +20,13 @@ on: - 'web/composer.json' - '.github/workflows/api-contract.yml' +# A new push to a pull request cancels that PR's outdated run (#115). +# Other events key on the run id, so pushes, tags and manual runs never +# cancel or queue behind each other. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }} + cancel-in-progress: true + jobs: api-contract: name: Generated JS contract is up to date diff --git a/.github/workflows/docs-build.yml b/.github/workflows/docs-build.yml index de513e753..2d4f648e6 100644 --- a/.github/workflows/docs-build.yml +++ b/.github/workflows/docs-build.yml @@ -22,6 +22,13 @@ on: - 'docs/**' - '.github/workflows/docs-build.yml' +# A new push to a pull request cancels that PR's outdated run (#115). +# Other events key on the run id, so pushes, tags and manual runs never +# cancel or queue behind each other. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }} + cancel-in-progress: true + jobs: build: name: Build Astro + Starlight diff --git a/.github/workflows/docs-screenshots-build.yml b/.github/workflows/docs-screenshots-build.yml index e3c39b04d..aa235c06d 100644 --- a/.github/workflows/docs-screenshots-build.yml +++ b/.github/workflows/docs-screenshots-build.yml @@ -27,6 +27,13 @@ on: - '.github/workflows/docs-screenshots-build.yml' - '.github/workflows/docs-screenshots-capture.yml' +# A new push to a pull request cancels that PR's outdated run (#115). +# Other events key on the run id, so pushes, tags and manual runs never +# cancel or queue behind each other. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }} + cancel-in-progress: true + jobs: build: name: Verify capture script diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index c9ad39f6a..4454678d7 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -18,6 +18,13 @@ on: - 'sbpp.sh' - '.github/workflows/e2e.yml' +# A new push to a pull request cancels that PR's outdated run (#115). +# Other events key on the run id, so pushes, tags and manual runs never +# cancel or queue behind each other. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }} + cancel-in-progress: true + jobs: playwright: name: Playwright + axe diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 96656a63e..99dbe3d19 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -12,6 +12,13 @@ on: - 'web/**' - '.github/workflows/phpstan.yml' +# A new push to a pull request cancels that PR's outdated run (#115). +# Other events key on the run id, so pushes, tags and manual runs never +# cancel or queue behind each other. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }} + cancel-in-progress: true + jobs: phpstan: name: Static analysis diff --git a/.github/workflows/plugin-build.yml b/.github/workflows/plugin-build.yml index e25ee6bce..97f3d468f 100644 --- a/.github/workflows/plugin-build.yml +++ b/.github/workflows/plugin-build.yml @@ -20,6 +20,13 @@ on: # `-i include` invocation, same shallow `*.sp` glob (nested sub-files like # sbpp_admcfg/sbpp_admin_groups.sp are `#include`d by their parent and # don't compile standalone). +# A new push to a pull request cancels that PR's outdated run (#115). +# Other events key on the run id, so pushes, tags and manual runs never +# cancel or queue behind each other. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }} + cancel-in-progress: true + jobs: plugin-build: name: Compile SourceMod plugins diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2d14d2afd..f5c175bba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,6 +12,13 @@ on: - 'web/**' - '.github/workflows/test.yml' +# A new push to a pull request cancels that PR's outdated run (#115). +# Other events key on the run id, so pushes, tags and manual runs never +# cancel or queue behind each other. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }} + cancel-in-progress: true + jobs: phpunit: name: PHPUnit diff --git a/.github/workflows/translations.yml b/.github/workflows/translations.yml index e7e74ebab..38c0f027a 100644 --- a/.github/workflows/translations.yml +++ b/.github/workflows/translations.yml @@ -11,6 +11,13 @@ on: - ".github/workflows/translations.yml" workflow_dispatch: +# A new push to a pull request cancels that PR's outdated run (#115). +# Other events key on the run id, so pushes, tags and manual runs never +# cancel or queue behind each other. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }} + cancel-in-progress: true + jobs: check: name: Translations diff --git a/.github/workflows/ts-check.yml b/.github/workflows/ts-check.yml index 7452d9b02..6a533505a 100644 --- a/.github/workflows/ts-check.yml +++ b/.github/workflows/ts-check.yml @@ -12,6 +12,13 @@ on: - 'web/**' - '.github/workflows/ts-check.yml' +# A new push to a pull request cancels that PR's outdated run (#115). +# Other events key on the run id, so pushes, tags and manual runs never +# cancel or queue behind each other. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }} + cancel-in-progress: true + jobs: ts-check: name: tsc --checkJs over web/scripts diff --git a/CHANGELOG.md b/CHANGELOG.md index f55b15d17..8c517c355 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,13 @@ Legend: ? = Other stuff ``` +(29/11/26): Version 2.2.26-srcdslab +----------------------- +``` +01. ? ci: a new push to a pull request cancels the run it replaces, in + every workflow that runs on pull requests (#115) +``` + (29/11/26): Version 2.2.25-srcdslab ----------------------- ``` From ac30a328a4e355d3ce5efcd2474513c60682a264 Mon Sep 17 00:00:00 2001 From: Rushaway Date: Sun, 29 Nov 2026 16:02:18 +0100 Subject: [PATCH 2/7] chore(ci): run PHPUnit and E2E nightly on main instead of on every push The merged commit already passed both suites on its pull request. A push to main now runs only the fast gates (PHPStan, ts-check, API contract, plugin build). PHPUnit and the Playwright E2E suite run on pull requests, every night on main, and on demand. Refs #115 --- .github/workflows/e2e.yml | 18 +++++++++--------- .github/workflows/test.yml | 15 +++++++++------ AGENTS.md | 7 +++++++ ARCHITECTURE.md | 4 +++- CHANGELOG.md | 8 ++++++++ 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 4454678d7..d0da791ac 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -1,15 +1,11 @@ name: E2E on: - push: - branches: - - main - paths: - - 'web/**' - - 'docker/**' - - 'docker-compose.yml' - - 'sbpp.sh' - - '.github/workflows/e2e.yml' + # The full suite runs on pull requests, every night on main, and on + # demand. A push to main does not run it again: the merged commit + # already passed it on its pull request, and a second run only queued + # ahead of deploy workflows on runners shared with them (#115). The + # nightly run catches what two PRs that each passed break together. pull_request: paths: - 'web/**' @@ -17,6 +13,10 @@ on: - 'docker-compose.yml' - 'sbpp.sh' - '.github/workflows/e2e.yml' + schedule: + # 02:45 UTC, after the PHPUnit nightly has started. + - cron: '45 2 * * *' + workflow_dispatch: # A new push to a pull request cancels that PR's outdated run (#115). # Other events key on the run id, so pushes, tags and manual runs never diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f5c175bba..25b936361 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,16 +1,19 @@ name: Tests on: - push: - branches: - - main - paths: - - 'web/**' - - '.github/workflows/test.yml' + # The full suite runs on pull requests, every night on main, and on + # demand. A push to main does not run it again: the merged commit + # already passed it on its pull request, and a second run only queued + # ahead of deploy workflows on runners shared with them (#115). The + # nightly run catches what two PRs that each passed break together. pull_request: paths: - 'web/**' - '.github/workflows/test.yml' + schedule: + # 02:30 UTC, outside the usual merge hours. + - cron: '30 2 * * *' + workflow_dispatch: # A new push to a pull request cancels that PR's outdated run (#115). # Other events key on the run id, so pushes, tags and manual runs never diff --git a/AGENTS.md b/AGENTS.md index 1c0190802..e216f2191 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -212,6 +212,13 @@ pushes (semver + `:latest`) and on push to `main` (`:main` only). PRs do not build the image. See the row's note + the `Prod Docker image specifics` block below. +On push to `main`, only the fast gates run again (PHPStan, ts-check, +API contract, plugin build). PHPUnit and Playwright E2E run on pull +requests, every night on `main` (`schedule`), and on demand +(`workflow_dispatch`): the merged commit already passed them on its PR. +A red nightly run is a real regression between two merged PRs; fix it +like any failing gate (#115). + | Gate | Local | CI workflow | | -------------- | ------------------------------------ | ---------------------- | | PHPStan | `./sbpp.sh phpstan` | `phpstan.yml` | diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index afd1def25..8776c3c74 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -1287,7 +1287,9 @@ dev-only and documented as such in `docker-compose.yml`. ## Quality gates -Six CI jobs run on every PR (`.github/workflows/`): +Six CI jobs run on every PR (`.github/workflows/`). On push to `main` +only the fast ones run again; PHPUnit and Playwright E2E run nightly on +`main` instead (`schedule`), and on demand (#115). | Gate | Workflow | Local command | What it covers | | -------------- | --------------------- | ---------------------------- | --------------------------------------------- | diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c517c355..432284d44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,14 @@ Legend: ? = Other stuff ``` +(29/11/26): Version 2.2.27-srcdslab +----------------------- +``` +01. ? ci: a push to main no longer runs PHPUnit and the Playwright E2E + suite a second time (the merged commit passed them on its pull + request). Both run every night on main and on demand (#115) +``` + (29/11/26): Version 2.2.26-srcdslab ----------------------- ``` From 9eeee43f120e55182d8ee7ec3cc31fa36e3e544c Mon Sep 17 00:00:00 2001 From: Rushaway Date: Sun, 29 Nov 2026 16:04:40 +0100 Subject: [PATCH 3/7] perf(tests): hash the fixture admin password once per process Fixture::reset() runs before every test and re-seeded the admin row with a fresh password_hash(). bcrypt costs 12 by default since PHP 8.4, about 0.22 s a hash, so ~1,770 resets spent most of the PHPUnit run hashing the same password. The hash is now computed once per process. BansTest (80 tests) locally: 24 s -> 8 s, same assertions. Refs #115 --- CHANGELOG.md | 8 ++++++++ web/tests/Fixture.php | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 432284d44..d4a32900a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,14 @@ Legend: ? = Other stuff ``` +(29/11/26): Version 2.2.28-srcdslab +----------------------- +``` +01. + tests: the test fixture hashes the seeded admin password once per + process instead of before every test (bcrypt cost 12 takes + about 0.2 s a hash, and the fixture resets ~1,770 times) (#115) +``` + (29/11/26): Version 2.2.27-srcdslab ----------------------- ``` diff --git a/web/tests/Fixture.php b/web/tests/Fixture.php index 893bce2e9..de3d685fb 100644 --- a/web/tests/Fixture.php +++ b/web/tests/Fixture.php @@ -12,6 +12,7 @@ class Fixture { private static bool $installed = false; private static int $adminAid = 0; + private static ?string $adminHash = null; public static function install(): void { @@ -186,7 +187,11 @@ private static function executeBatch(\PDO $pdo, string $sql): void private static function seedAdmin(\PDO $pdo): void { - $hash = password_hash('admin', PASSWORD_BCRYPT); + // bcrypt costs 12 by default since PHP 8.4: 0.22 s a hash (PHP + // 8.5.6, measured 29/11/2026), and reset() runs before every + // test, ~1,770 times. Hash once per process (#115): same + // password, same cost, same hash format. + $hash = self::$adminHash ??= password_hash('admin', PASSWORD_BCRYPT); $stmt = $pdo->prepare(sprintf( 'INSERT INTO `%s_admins` (user, authid, password, gid, email, validate, extraflags, immunity) VALUES (?, ?, ?, -1, ?, NULL, ?, 100)', DB_PREFIX From 0fd934a87af2baf5e060e3d1a72986098fde93b8 Mon Sep 17 00:00:00 2001 From: Rushaway Date: Sun, 29 Nov 2026 16:07:51 +0100 Subject: [PATCH 4/7] chore(ci): run the PHPUnit MariaDB on tmpfs without fsync Fixture::reset() truncates and re-seeds every table before each test, so the job was bound by fsync. MariaDB now starts from a step (a service container cannot pass server options) with its datadir on tmpfs, innodb_flush_log_at_trx_commit=0, no doublewrite buffer and no binlog. It boots while PHP and Composer install, listens on a free loopback port, has a per-run name, and is removed when the job ends, so a self-hosted runner keeps no leftover container. BansTest (80 tests) locally: 43-49 s on disk -> 8-9 s on tmpfs. Refs #115 --- .github/workflows/test.yml | 67 +++++++++++++++++++++++++------------- CHANGELOG.md | 8 +++++ 2 files changed, 52 insertions(+), 23 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 25b936361..35262f6b2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,24 +29,36 @@ jobs: defaults: run: working-directory: web - - services: - mariadb: - image: mariadb:10.11 - ports: - - 3306:3306 - env: - MARIADB_ROOT_PASSWORD: root - MARIADB_DATABASE: sourcebans_test - MARIADB_USER: sourcebans - MARIADB_PASSWORD: sourcebans - options: >- - --health-cmd="healthcheck.sh --connect --innodb_initialized" - --health-interval=5s - --health-timeout=5s - --health-retries=10 + env: + # One name per run and job: a self-hosted runner keeps containers + # between jobs, and several jobs may share one host. + DB_CONTAINER: sbpp-test-db-${{ github.run_id }}-${{ github.run_attempt }}-${{ strategy.job-index }} steps: + # MariaDB starts first so it boots while PHP and Composer install. + # It runs from a step, not a service container, because a service + # cannot pass server options. The test database is thrown away with + # the runner, so the datadir lives on tmpfs and InnoDB skips fsync + # and the doublewrite buffer: Fixture::reset() truncates and + # re-seeds every table before each of ~1,770 tests (#115). + # The port is a free one on loopback, so nothing on the host clashes. + - name: Start MariaDB + working-directory: . + run: | + docker run -d --name "$DB_CONTAINER" -p 127.0.0.1::3306 \ + --tmpfs /var/lib/mysql:rw \ + -e MARIADB_ROOT_PASSWORD=root \ + -e MARIADB_DATABASE=sourcebans_test \ + -e MARIADB_USER=sourcebans \ + -e MARIADB_PASSWORD=sourcebans \ + --health-cmd="healthcheck.sh --connect --innodb_initialized" \ + --health-interval=2s --health-timeout=5s --health-retries=30 \ + mariadb:10.11 \ + --innodb-flush-log-at-trx-commit=0 \ + --innodb-doublewrite=0 \ + --sync-binlog=0 \ + --skip-log-bin + - uses: actions/checkout@v7 - name: Setup PHP @@ -73,17 +85,22 @@ jobs: - name: Wait for MariaDB run: | - for i in {1..30}; do - if mysqladmin ping -h 127.0.0.1 -P 3306 -u root -proot --silent; then - echo "ready"; exit 0 + for i in {1..60}; do + status=$(docker inspect -f '{{.State.Health.Status}}' "$DB_CONTAINER") + if [ "$status" = healthy ]; then + port=$(docker port "$DB_CONTAINER" 3306/tcp | head -n1 | sed 's/.*://') + echo "DB_PORT=$port" >> "$GITHUB_ENV" + echo "ready on port $port"; exit 0 fi - sleep 2 + sleep 1 done - echo "MariaDB never came up" >&2; exit 1 + echo "MariaDB never came up" >&2 + docker logs "$DB_CONTAINER" >&2 + exit 1 - name: Grant test user CREATE/DROP on test database run: | - mysql -h 127.0.0.1 -u root -proot <<'SQL' + docker exec -i "$DB_CONTAINER" mariadb -uroot -proot <<'SQL' GRANT ALL PRIVILEGES ON *.* TO 'sourcebans'@'%'; FLUSH PRIVILEGES; SQL @@ -91,10 +108,14 @@ jobs: - name: Run PHPUnit env: DB_HOST: 127.0.0.1 - DB_PORT: 3306 DB_NAME: sourcebans_test DB_USER: sourcebans DB_PASS: sourcebans DB_PREFIX: sb DB_CHARSET: utf8mb4 run: includes/vendor/bin/phpunit --testdox + + - name: Stop MariaDB + if: always() + working-directory: . + run: docker rm -f "$DB_CONTAINER" >/dev/null 2>&1 || true diff --git a/CHANGELOG.md b/CHANGELOG.md index d4a32900a..c0e34c336 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,14 @@ Legend: ? = Other stuff ``` +(29/11/26): Version 2.2.29-srcdslab +----------------------- +``` +01. ? ci: the PHPUnit job runs MariaDB with its datadir on tmpfs, + without fsync and without the doublewrite buffer, on a free + loopback port, and removes it when the job ends (#115) +``` + (29/11/26): Version 2.2.28-srcdslab ----------------------- ``` From fa4a240dbf35812b898962d7bd2705d752533b95 Mon Sep 17 00:00:00 2001 From: Rushaway Date: Sun, 29 Nov 2026 16:14:20 +0100 Subject: [PATCH 5/7] chore(ci): run the Playwright E2E suite as three parallel shards The suite ran on one worker because every spec shares the sourcebans_e2e database. Each shard now brings up its own dev stack and database and runs --shard=N/3, so workers: 1 no longer sets the total time. From the per-test durations of the PR #114 run (428 s of tests), the three contiguous slices carry 158 / 132 / 138 s. fail-fast is off, so a red run still lists every failing spec, and on failure a report job merges the shards' blob reports into the usual playwright-report artifact. Refs #115 --- .github/workflows/e2e.yml | 70 ++++++++++++++++++++++++++++++++++----- AGENTS.md | 8 +++++ CHANGELOG.md | 8 +++++ 3 files changed, 77 insertions(+), 9 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index d0da791ac..4a7da1fac 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -27,8 +27,20 @@ concurrency: jobs: playwright: - name: Playwright + axe + name: Playwright + axe (shard ${{ matrix.shard }}/3) runs-on: ubuntu-24.04 + # Three shards, each with its own dev stack and its own + # `sourcebans_e2e`, so `workers: 1` (one shared DB per stack) no + # longer sets the total time (#115). Playwright cuts the suite into + # contiguous slices by test count; from the per-test durations of + # the PR #114 run (428 s of tests on 29/11/2026), three slices carry + # 158 / 132 / 138 s, while four would leave one at 175 s. Every + # shard runs to the end (no fail-fast) so a red run lists every + # failing spec, like the single job did. + strategy: + fail-fast: false + matrix: + shard: [1, 2, 3] # Generous overall timeout: first-run includes a full chromium # download + apt-install. Subsequent runs come back inside this # cap easily. Persistent failures (no retries left) still fail the @@ -62,28 +74,30 @@ jobs: # Run the suite. `./sbpp.sh e2e` exec's into the web container # and lazily installs @playwright/test + chromium + system deps - # on first run; CI pays this cost once per workflow because - # nothing is cached between runs (the install footprint is small - # enough that caching is more effort than it saves). + # on first run; CI pays this cost once per shard (about 26 s on + # the PR #114 run) because nothing is cached between runs. # # Retries are wired in `playwright.config.ts` via # `retries: process.env.CI ? 1 : 0` — one retry on flake, fail # the job on persistent failure. + # + # `blob` feeds the merged HTML report below; `list` keeps the + # per-test lines in the job log. - name: Run E2E env: CI: '1' - run: ./sbpp.sh e2e + run: ./sbpp.sh e2e --shard=${{ matrix.shard }}/3 --reporter=blob,list # Upload artifacts on failure so reviewers can debug from the # PR UI without re-running locally. The HTML report and the # raw test-results (traces, videos, axe report attachments) # together cover almost every "what failed and why" question. - - name: Upload Playwright report + - name: Upload blob report if: failure() uses: actions/upload-artifact@v7 with: - name: playwright-report - path: web/tests/e2e/playwright-report/ + name: blob-report-${{ matrix.shard }} + path: web/tests/e2e/blob-report/ retention-days: 7 if-no-files-found: ignore @@ -91,7 +105,7 @@ jobs: if: failure() uses: actions/upload-artifact@v7 with: - name: playwright-test-results + name: playwright-test-results-${{ matrix.shard }} path: web/tests/e2e/test-results/ retention-days: 7 if-no-files-found: ignore @@ -99,3 +113,41 @@ jobs: - name: Tear down if: always() run: ./sbpp.sh down + + # Only after a failure: merge the shards' blob reports into the one + # HTML report reviewers download from the PR, as before the split. + report: + name: Playwright report + needs: playwright + if: failure() + runs-on: ubuntu-24.04 + defaults: + run: + working-directory: web/tests/e2e + steps: + - uses: actions/checkout@v7 + + - uses: actions/setup-node@v7 + with: + node-version: 22 + + - name: Install Playwright + run: npm ci --no-audit --no-fund + + - name: Download blob reports + uses: actions/download-artifact@v8 + with: + pattern: blob-report-* + path: web/tests/e2e/all-blob-reports + merge-multiple: true + + - name: Merge into an HTML report + run: npx playwright merge-reports --reporter html ./all-blob-reports + + - name: Upload Playwright report + uses: actions/upload-artifact@v7 + with: + name: playwright-report + path: web/tests/e2e/playwright-report/ + retention-days: 7 + if-no-files-found: ignore diff --git a/AGENTS.md b/AGENTS.md index e216f2191..d1fef3974 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -307,6 +307,14 @@ Playwright E2E specifics: `forbidden / No access`, etc.). Until each worker has its own DB, parallelism here is unsound. Don't bump `workers` back up without shipping per-worker DB isolation. +- CI parallelism comes from **sharding** instead: `e2e.yml` runs the + suite as three jobs (`--shard=N/3`), each with its own dev stack and + its own `sourcebans_e2e`. Playwright cuts contiguous slices by test + count, so a spec that suddenly gets much slower can unbalance them; + re-check the shard durations when one job runs far longer than the + others. On failure, a `report` job merges the shards' blob reports + into the usual `playwright-report` artifact; traces are in + `playwright-test-results-N` (#115). - Flake tolerance is **off**: `retries: 1` in CI **plus** `failOnFlakyTests: true`. A spec that fails first try and passes on retry counts as a real failure — the retry exists so diff --git a/CHANGELOG.md b/CHANGELOG.md index c0e34c336..aa1eafc4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,14 @@ Legend: ? = Other stuff ``` +(29/11/26): Version 2.2.30-srcdslab +----------------------- +``` +01. ? ci: the Playwright E2E suite runs as three shards in parallel, + each with its own dev stack and database; a failed run still + publishes one merged HTML report (#115) +``` + (29/11/26): Version 2.2.29-srcdslab ----------------------- ``` From 0d94977ac62412f26d5907fb472e6cc7c9af1a15 Mon Sep 17 00:00:00 2001 From: Rushaway Date: Sun, 29 Nov 2026 16:18:50 +0100 Subject: [PATCH 6/7] perf(tests): seed the fixture admin with a precomputed password hash Hashing once per process still cost 0.22 s in every #[RunInSeparateProcess] child (165 tests) and on every E2E reset, which runs in a fresh process. The fixture now seeds a precomputed cost-12 bcrypt hash of 'admin': same password, cost and format, and password_needs_rehash() stays false. Refs #115 --- CHANGELOG.md | 7 ++++--- web/tests/Fixture.php | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4a32900a..311e2f5cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,9 +13,10 @@ Legend: (29/11/26): Version 2.2.28-srcdslab ----------------------- ``` -01. + tests: the test fixture hashes the seeded admin password once per - process instead of before every test (bcrypt cost 12 takes - about 0.2 s a hash, and the fixture resets ~1,770 times) (#115) +01. + tests: the test fixture seeds the admin with a precomputed bcrypt + hash of its password instead of hashing it before every test + (cost 12 takes 0.22 s a hash, and the fixture resets ~1,770 + times, plus once per separate-process test and E2E reset) (#115) ``` (29/11/26): Version 2.2.27-srcdslab diff --git a/web/tests/Fixture.php b/web/tests/Fixture.php index de3d685fb..2dcc062d3 100644 --- a/web/tests/Fixture.php +++ b/web/tests/Fixture.php @@ -12,7 +12,17 @@ class Fixture { private static bool $installed = false; private static int $adminAid = 0; - private static ?string $adminHash = null; + + /** + * bcrypt hash of the seeded admin's password, `admin`, at cost 12 + * (PASSWORD_BCRYPT's default since PHP 8.4, so password_needs_rehash() + * is false and a sign-in does not rewrite it). Precomputed because a + * cost-12 hash takes 0.22 s (PHP 8.5.6, 29/11/2026) and the row is + * seeded before every PHPUnit test, in every `#[RunInSeparateProcess]` + * child and on every E2E reset (#115). Regenerate with + * `php -r 'echo password_hash("admin", PASSWORD_BCRYPT);'`. + */ + private const ADMIN_PASSWORD_HASH = '$2y$12$mm1PIatepE5AWCSuWDxTA.54hus8vCow75mk9.xMSde79SrvM3X0y'; public static function install(): void { @@ -187,11 +197,7 @@ private static function executeBatch(\PDO $pdo, string $sql): void private static function seedAdmin(\PDO $pdo): void { - // bcrypt costs 12 by default since PHP 8.4: 0.22 s a hash (PHP - // 8.5.6, measured 29/11/2026), and reset() runs before every - // test, ~1,770 times. Hash once per process (#115): same - // password, same cost, same hash format. - $hash = self::$adminHash ??= password_hash('admin', PASSWORD_BCRYPT); + $hash = self::ADMIN_PASSWORD_HASH; $stmt = $pdo->prepare(sprintf( 'INSERT INTO `%s_admins` (user, authid, password, gid, email, validate, extraflags, immunity) VALUES (?, ?, ?, -1, ?, NULL, ?, 100)', DB_PREFIX From 876657ad52ba4a19fcd5638875937abfa55dbdcd Mon Sep 17 00:00:00 2001 From: Rushaway Date: Sun, 29 Nov 2026 16:29:38 +0100 Subject: [PATCH 7/7] chore(ci): take the E2E shard count from the matrix length Refs #115 --- .github/workflows/e2e.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 4a7da1fac..5a25f0e16 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -27,7 +27,7 @@ concurrency: jobs: playwright: - name: Playwright + axe (shard ${{ matrix.shard }}/3) + name: Playwright + axe (shard ${{ matrix.shard }}/${{ strategy.job-total }}) runs-on: ubuntu-24.04 # Three shards, each with its own dev stack and its own # `sourcebans_e2e`, so `workers: 1` (one shared DB per stack) no @@ -36,7 +36,9 @@ jobs: # the PR #114 run (428 s of tests on 29/11/2026), three slices carry # 158 / 132 / 138 s, while four would leave one at 175 s. Every # shard runs to the end (no fail-fast) so a red run lists every - # failing spec, like the single job did. + # failing spec, like the single job did. The shard count is the + # length of the list: a fork with a single self-hosted runner, where + # shards would only queue one after the other, can set `[1]`. strategy: fail-fast: false matrix: @@ -86,7 +88,7 @@ jobs: - name: Run E2E env: CI: '1' - run: ./sbpp.sh e2e --shard=${{ matrix.shard }}/3 --reporter=blob,list + run: ./sbpp.sh e2e --shard=${{ matrix.shard }}/${{ strategy.job-total }} --reporter=blob,list # Upload artifacts on failure so reviewers can debug from the # PR UI without re-running locally. The HTML report and the