feat: Add random test execution verification system#10015
feat: Add random test execution verification system#10015paulbalandan wants to merge 1 commit intocodeigniter4:developfrom
Conversation
4cb5947 to
9834111
Compare
There was a problem hiding this comment.
Pull request overview
Adds CI infrastructure to verify CodeIgniter4 component tests are order-independent by repeatedly executing component test suites with randomized PHPUnit ordering, both locally (script) and in GitHub Actions (workflow), with diagnostics to help identify inter-test dependencies (issue #9968).
Changes:
- Introduces a Bash orchestrator to run component test suites in parallel with randomized order, timeouts, and failure diagnostics.
- Adds a component allowlist config file to enable incremental rollout of random-order verification.
- Adds a GitHub Actions workflow that runs the random-order verification across a database platform matrix and supports
workflow_callinputs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
.github/workflows/test-random-execution.yml |
New CI workflow to run random-order verification across DB matrix and accept reusable-workflow inputs. |
.github/scripts/run-random-tests.sh |
New runner script to execute component tests in randomized order with concurrency, timeouts, and diagnostics. |
.github/scripts/random-tests-config.txt |
Initial component list for incremental enablement (currently API, CLI). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c25865a to
fbd33e9
Compare
fbd33e9 to
57eca25
Compare
michalsn
left a comment
There was a problem hiding this comment.
I don't have enough experience with Bash to comment on the implementation details, but the overall approach makes sense to me.
Can we add instructions for running these tests locally to tests/README.md, similar to the notes in the PR description?
Description
This PR introduces a comprehensive system for verifying that CodeIgniter4 component tests pass when executed in random order, addressing issue #9968. The system includes automated CI/CD integration and detailed failure diagnostics to help identify and fix test interdependencies.
What Changed
New Files:
.github/scripts/run-random-tests.sh(894 lines).github/scripts/random-tests-config.txt.github/workflows/test-random-execution.yml(224 lines)Why This Change
Test execution order dependencies are a common source of flaky tests and difficult-to-reproduce bugs. This system:
Key Features
Script Capabilities:
Workflow Features:
workflow_callsupport for manual/external invocationquiet,component,max-jobs,repeat,timeoutExample Usage:
Implementation Notes
Security Considerations:
^[a-zA-Z0-9/_-]+$..,//, leading/evalusage throughout scriptPerformance:
nproc/sysctl--no-coverageflag speeds up PHPUnit executionCompatibility:
timeout/gtimeout(falls back to manual watchdog)Testing Strategy
Incremental Rollout:
CI Integration:
phpunit.xml.distsystem/ortests/directoriesLocal Testing:
Related Issues
Addresses #9968 - Tests should pass in random execution order
This PR provides the infrastructure for verifying random test execution. Subsequent PRs will fix individual component tests that fail under random ordering.
Breaking Changes
None. This is purely additive CI/CD infrastructure.
Additional Context
Future Work:
Script Development:
Implementation progressed through 9 distinct phases with comprehensive testing and refinement at each stage, ensuring robust error handling and user-friendly output.
Checklist