cnimmo / test-only-changed
Run Paratest on only changed files
Installs: 65
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/cnimmo/test-only-changed
Requires
- cnimmo/granular-testsuites: ^1.1
- cnimmo/list-deps: ^1.0
Requires (Dev)
- brianium/paratest: ^7.1
README
This Github action allows you to execute your PHP unit tests more quickly in CI, by running only tests which are related to files changed since the last successful workflow run.
In other words, we only run the tests which may actually be failing.
This package is inspired by the --onlyChanged flag in Jest.
We use Paratest as the test runner for blazingly fast parallel execution.
Prerequisites
The action should be used in a Github actions workflow with PHP and composer already set up.
Usage
See an example workflow.
Supported arguments:
branch-nameName of branch to scan for last successful workflow run. Defaults to current branch.workflow-idName of workflow to check for success. Defaults to current workflow.tests-directoryThe directory where the tests are located relative to the root. Defaults to tests.ignore-pathsFiles to ignore when determining which files to run. Defaults tovendor,node_modules,_ide_helper.phplist-onlyThis option allows the flexibility to configure Paratest/bring your own test runner. When set to true, the action will not run your tests, but instead write a list of all testsuites to thefilesoutput, joined by theseparator(see below).separatorTo be used alongside thelist-onlyargument. Specifies the separator that should be used between each testsuite name. Defaults to a comma.
How it works
The package builds a dependency graph for each of your test files, and then compares this to the files changed since your tests last passed successfully.
If the dependency graph includes the file being checked, the file is included in the test run.
We then generate a phpunit.xml on the fly, based on your existing phpunit.xml, with a testsuite specified for each of the relevant test files, as Paratest doesn't support running specific files within a larger test suite.
Caveats
- Currently only supports PHP namespaces via "use" imports. Dynamic imports are not detected.