Skip to content

Instantly share code, notes, and snippets.

@PortNumber53
Created December 20, 2018 17:30
Show Gist options
  • Save PortNumber53/8df3ee1881de6e4bc403ef4aaa863f3a to your computer and use it in GitHub Desktop.
Save PortNumber53/8df3ee1881de6e4bc403ef4aaa863f3a to your computer and use it in GitHub Desktop.
Run docker-compose inside a git pre-commit hook
#!/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