Created
December 20, 2018 17:30
-
-
Save PortNumber53/8df3ee1881de6e4bc403ef4aaa863f3a to your computer and use it in GitHub Desktop.
Run docker-compose inside a git pre-commit hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
rc=0 | |
behat=0 | |
phpunit=0 | |
EXEC_BEHAT='docker-compose exec phpfpm sh -c "cd /app && vendor/bin/behat"' | |
script -q --return -c "${EXEC_BEHAT}" /dev/null | |
behat=$? | |
if [[ $behat != 0 ]]; then | |
echo " | |
██████╗ ███████╗██╗ ██╗ █████╗ ████████╗ ███████╗ █████╗ ██╗██╗ ██╗ | |
██╔══██╗██╔════╝██║ ██║██╔══██╗╚══██╔══╝ ██╔════╝██╔══██╗██║██║ ██║ | |
██████╔╝█████╗ ███████║███████║ ██║ █████╗ ███████║██║██║ ██║ | |
██╔══██╗██╔══╝ ██╔══██║██╔══██║ ██║ ██╔══╝ ██╔══██║██║██║ ╚═╝ | |
██████╔╝███████╗██║ ██║██║ ██║ ██║ ██║ ██║ ██║██║███████╗██╗ | |
╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ | |
" | |
rc=1 | |
fi | |
EXEC_PHPUNIT='docker-compose exec phpfpm sh -c "cd /app && vendor/bin/phpunit"' | |
script -q --return -c "${EXEC_PHPUNIT}" /dev/null | |
phpunit=$? | |
if [[ $phpunit != 0 ]]; then | |
echo " | |
██╗ ██╗███╗ ██╗██╗████████╗ ████████╗███████╗███████╗████████╗███████╗ ███████╗ █████╗ ██╗██╗ ███████╗██████╗ | |
██║ ██║████╗ ██║██║╚══██╔══╝ ╚══██╔══╝██╔════╝██╔════╝╚══██╔══╝██╔════╝ ██╔════╝██╔══██╗██║██║ ██╔════╝██╔══██╗ | |
██║ ██║██╔██╗ ██║██║ ██║ ██║ █████╗ ███████╗ ██║ ███████╗ █████╗ ███████║██║██║ █████╗ ██║ ██║ | |
██║ ██║██║╚██╗██║██║ ██║ ██║ ██╔══╝ ╚════██║ ██║ ╚════██║ ██╔══╝ ██╔══██║██║██║ ██╔══╝ ██║ ██║ | |
╚██████╔╝██║ ╚████║██║ ██║ ██║ ███████╗███████║ ██║ ███████║ ██║ ██║ ██║██║███████╗███████╗██████╔╝ | |
╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝ ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝╚══════╝╚══════╝╚═════╝ | |
" | |
rc=1 | |
fi | |
[ $rc -ne 0 ] && exit 1 | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment