-
-
Save fokosun/49f33f683728ec6c4221cbfb4ecbeb41 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/php | |
<?php | |
$projectName = basename(getcwd()); // get the name of your app | |
echo PHP_EOL; | |
echo '+ Starting unit tests'.PHP_EOL; | |
exec('vendor/bin/phpunit', $output, $returnCode); // command to run tests with any testing framework you like | |
if ($returnCode !== 0) { | |
$testSummary = $output; | |
printf("%s Test Summary: ", $projectName); | |
echo PHP_EOL; | |
printf("( %s ) %s%2\$s", $testSummary[14], PHP_EOL); | |
printf("ABORTING COMMIT!\n"); | |
exit(1); // git halts | |
} | |
exit(0); // git continues with push event |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment