Famous last words: "Works for me!" Sometimes, even though code works for you, when you push it to the remote repository or install it on the production site, suddenly you're faced with pesky errors that escaped the testing process. The later bugs are found during development, the more expensive a project becomes in terms of time, frustration, and money. One way to improve your code quality is to use automated testing with Git hooks.
In this session, Milton Bryant will walk you through some practical applications of automated testing using Git hooks. He'll demonstrate how to get Git hooks working with existing PHPUnit tests, to allow you to test your code as you commit it.
Presented at the Joomla World Conference 2014 in Cancun, Mexico - November 7, 2014
5. Changes to Commit
Commit
Push
Repo
Update
Local
Remote
pre-commit
prepare-commit-msg
commit-msg
post-commit
pre-receive
update
post-receive
6. Changes to Commit
Commit
Push
Repo
Update
Local
Remote
pre-commit
prepare-commit-msg
commit-msg
post-commit
pre-receive
update
post-receive
Checkout
Rebase
post-checkout
pre-rebase
Merge
post-merge
7. Changes to Commit
Commit
Push
Repo
Update
Local
Remote
pre-commit
prepare-commit-msg
commit-msg
post-commit
pre-receive
update
post-receive
pre-commit
code validation
unit tests
check for missing files
If fail, aborts with message and no commit
11. Changes to Commit
Commit
Push
Repo
Update
Local
Remote
pre-commit
prepare-commit-msg
commit-msg
post-commit
pre-receive
update
post-receive
commit-msg
runs during commit
use to ensure standards followed
Example: abort commit if JIRA issue resolution comments missing
13. Changes to Commit
Commit
Push
Repo
Update
Local
Remote
pre-commit
prepare-commit-msg
commit-msg
post-commit
pre-receive
update
post-receive
post-commit
runs only after successful commit
use for notifications