Not your client. Not your boss. You donʼt go to the doctor and say: You know what doc? Iʼm in a hurry, why wonʼt you skip washing your hands?ˮ - Michael Toppa
PHP (and Go) • Developed by Sebastian Feldmann in 2016 • Installed with Composer • Configured using JSON • Ensures everyone is running the same hooks at a project level • Extensible via bash scripts and custom PHP classes
Configuration $ composer require captainhook/captainhook $ composer require captainhook/plugin-composer ... captainhook/plugin-composer contains a Composer plugin which is currently not in your allow-plugins config. Do you trust "captainhook/plugin-composer" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json) [ y,n,d,?]
beautification • Test staged files only Pre-Commit Pre-Push • Execute longer quality checks • Test entire codebase • Run test suites • Security checks • Check for todo / fixme
successful for hook to complete and Git action to execute • Used for critical actions, such as running quality and security checks Ensured • “failOnErrorˮ: false • Optional actions which do not prevent a hook completing - and will report successful regardless • Used for non-critical actions, such as notifications, updates to changelogs, etc Non-Ensured
differ • Can run actions to checkout submodules to applicable commit, including creating matching branches • Pick one option - donʼt mix and match! Considerations • Install only in parent project and checks on submodules using single source of truth • Default configuration for parent; additional configuration to run against each submodule • Checks will not run where submodules are maintained externally Option 1 Single Source of Truth • Installed per module • Each module maintains its own hooks individually and configuration • Requires additional setup and configuration to ensure checks are run consistently and without duplication Option 2 Independent Modules
• Static Analysis without Magento codebase • Unit tests requiring Magento installation • Developers can skip checks (--no-verify or just disabling in captainhook.json) • Increased commit and push time, especially with long-running actions • “Quick and dirtyˮ POCs can become tedious
quality with opinionated, pre-configured checks • Declarative configuration in YAML • Quick and simple setup GrumPHP • Flexible hook manager supporting range of actions • Granular configuration in JSON • More complex setup - especially for custom actions Captain Hook
• Powerful tool to improve code quality and management of a project – with limitations • Balancing act between features and day-to-day usability • Not a replacement for CI/CD and reviews