-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Problem
The current GrumPHP phpunit task runs the suite across all matching test directories on every commit. Even for small, localized changes this takes roughly ~1 minute to complete, which is too slow for a pre-commit / commit-time check and negatively impacts developer productivity.
Desired behavior
Introduce a custom “Code Quality” wrapper around phpunit that restricts execution to only the modules affected by the current staged changes. The wrapper would inspect staged files, derive the module(s) being updated, and then run phpunit only for those modules.
Proposal
- Extend the existing Code Quality tooling (GrumPHP integration) with a new phpunit wrapper script.
- In that wrapper:
- Inspect staged files, for example via
git diff --name-only --cached. - Map changed paths to their top-level module paths, e.g.:
web/modules/custom/my_module
- De-duplicate the list of module paths.
- For each affected module, run phpunit scoped to that module, e.g.:
ddev phpunit web/modules/custom/my_module- or use
phpunit.xmlwith a directory filter / testsuite if that fits better.
- Inspect staged files, for example via
- Wire this wrapper into GrumPHP so the pre-commit phpunit step uses it instead of running the full
Trimble unit testssuite every time.
Acceptance criteria
- Pre-commit / commit-time phpunit checks complete significantly faster for small, localized changes (e.g. when only one or two modules are touched).
- The wrapper correctly handles:
- Multiple modules changed in a single commit.
- Changes outside of testable PHP code (e.g. only YAML / front-end changes), ideally skipping unnecessary phpunit runs or minimizing them.
- Running inside DDEV using
ddev phpunit.
- Documentation is added to:
- Explain how the wrapper determines affected modules.
- Show how to manually run the same scoped tests, e.g.
ddev phpunit web/modules/custom/my_module.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels