Repository navigation
perf: the tests run in parallel, only the affected tests run locally, and CI runs in shards - #1750
Draft
dsebastien wants to merge 8 commits into
Draft
dsebastien wants to merge 8 commits into
dsebastien wants to merge 8 commits into
Conversation
gh pr checks --watch can return while a long job is still pending, and the merge was then lost. The script now polls every 60 seconds, for 90 minutes at most, until no check is pending and every required check is there. It reads the required checks from the branch protection of main, else from one list. It still merges only when every check is green.
tools/test/run.sh runs Pest in parallel (three quarters of the CPUs by default, TEST_PROCESSES changes it), with XDEBUG_MODE=off, PCOV off and the opcode cache of the command line. PHP_INI_SCAN_DIR adds the settings of tools/test/php/tests.ini, so every worker process gets them. On a sample of 726 tests (4 processes, load 4 to 6): 125 to 131 s with the settings of the container, 40 to 52 s with these (#1740).
The document comes from the code only, and each of the 20 tests exported it again (3 s each): the file took 69 s, now 4 s (#1740).
tools/test/affected.sh [base] runs all of tests/Unit and the feature tests that read the files of the tree, then the tests of the changed files with the test impact analysis of Pest (--tia --filtered). A change to Composer, the configuration, the routes, the migrations, the service providers or the test setup runs the full suite (#1740).
…the slow tests tests/.pest/shards.json lets Pest give each CI shard about the same time. tools/test/slow-tests.php warns for each test slower than 10 s and writes the slowest tests to the summary of the run (#1740).
The one job of 35 minutes becomes: the static checks, the front-end, and the back-end tests in 3 shards of 4 processes, at the same time. PHP runs without a coverage driver. Pint checks only the PHP files of the pull request (every file when pint.json or composer.lock changes): it took 3 minutes for 1 084 files. The job main waits for every job, so the required check keeps its name (#1740).
A builder runs tools/test/affected.sh; the pull request runs the full suite in CI (#1740).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1740.
The back-end tests were the slowest step of every change. This pull request makes each test cheaper, runs the suite in parallel by default, gives a builder a command that runs only the tests of a change, and splits CI into jobs that run at the same time.
What changes
tools/test/run.sh: Pest in parallel (three quarters of the CPUs,TEST_PROCESSESchanges it), with Xdebug and PCOV off and the opcode cache of the command line (tools/test/php/tests.ini, added withPHP_INI_SCAN_DIRso that every worker gets it).composer testuses it.tools/test/affected.sh [base](defaultorigin/main): all oftests/Unit, the feature tests that read the files of the tree, then the tests of the changed files with the native test impact analysis of Pest 5 (--tia --filtered, a coverage map recorded with PCOV). A change to Composer,config/,routes/, migrations, providers,bootstrap/or the test setup runs the full suite.composer test:affecteduses it.OpenApiDocumentTest: one export of the document for the file, not one per test (69 s to 4 s).Static checks,Front-end,Back-end tests (1/3),(2/3),(3/3)(time-balanced withtests/.pest/shards.json), andmain, which waits for all of them. PHP runs withcoverage: none. Pint reads only the PHP files of the pull request (all files whenpint.jsonorcomposer.lockchanges). A test slower than 10 s gets a warning, and the slowest tests go to the summary of the run.tools/merge/gate-merge.shpolls until no check is pending (60 s, 90 min at most) and reads the required checks from the branch protection.AGENTS.md,CONTRIBUTING.md,tools/README.md: a builder runstools/test/affected.sh; the pull request runs the full suite.Numbers
Measured on 2026-11-24 and 2026-11-25 in the development container (12 CPUs), with the load next to each number, while other work ran on the machine. The final numbers on an idle machine come later.
tests/Unitand 20 feature files (726 tests), 4 processesWhat each setting gives on the sample (726 tests, 4 processes): Xdebug off 128 s to 68 s; PCOV off 68 s to 62 s; the opcode cache 62 s to 52 s.
Measured and left out
migrate:freshtakes 3 s once per worker process (not per test); a dump saves under 2 % of a run and adds apsqlversion dependency in CI.RefreshDatabasealready uses one transaction per test after that first migration; the boot of the application takes 13 ms per test with the opcode cache. A lighter base for tests without a table gains little.Required checks
The required check
mainkeeps its name: it is now the job that waits for the others. The new checks areStatic checks,Front-end,Back-end tests (1/3),Back-end tests (2/3)andBack-end tests (3/3). No change to the branch protection is needed.Commits
fix(build): the merge gate waits until no check is pending.perf(qa):tools/test/run.shandtools/test/php/tests.ini(parallel, no Xdebug, no PCOV, the opcode cache),composer test.perf(qa): one OpenAPI export forOpenApiDocumentTest.perf(qa):tools/test/affected.sh,composer test:affected.perf(qa):tests/.pest/shards.jsonandtools/test/slow-tests.php.ci: the parallel jobs and the 3 shards.docs:AGENTS.md,CONTRIBUTING.md,tools/README.md,documentation/conventions/rules.md.Commands of a builder
docker compose exec -T -u sail laravel.test bash tools/test/affected.sh [base]while working (default baseorigin/main).docker compose exec -T -u sail laravel.test bash tools/test/run.sh [Pest arguments]for the whole suite or a part of it (TEST_PROCESSES=4for fewer processes).What is left
tools/test/run.shwith the default processes (9 of 12 CPUs), to write inCONTRIBUTING.md(target: under 3 minutes).tools/test/affected.sh: its first two parts ran (git in a worktree inside the container,tests/Unitand 14 feature files: 939 tests in 27 s, load about 5). The first--tiarun, which records the map with PCOV, was stopped before its end; a second run that replays the map is not checked yet.Questions for the owner
Static checks,Front-endandmain). Keep 3 shards? Recommended: yes; the free runners of a public repository are enough, and 2 shards would make the back-end jobs about 1 minute longer thanFront-end.concurrencyof the workflow CI stops the run of an older push of the same pull request. Keep it? Recommended: yes.