How to force run unit tests when running Git push?
#!/bin/bash
while read oldrev newrev refname
do
# Only run this script for the master branch. You can remove this
# if block if you wish to run it for others as well.
if [[ $refname = "refs/heads/master" ]] ; then
# Anything echo'd will show up in the console for the person
# who's doing a push
echo "Preparing to run phpunit for $newrev ... "
# Since the repo is bare, we need to put the actual files someplace,
# so we use the temp dir we chose earlier
git archive $newrev | tar -x -C /home/jani/tmp/example
echo "Running phpunit for $newrev ... "
# This part is the actual code which is used to run our tests
# In my case, the phpunit testsuite resides in the tests directory, so go there
cd /home/jani/tmp/example/tests
# And execute the testsuite, while ignoring any output
phpunit > /dev/null
# $? is a shell variable which stores the return code from what we just ran
rc=$?
if [[ $rc != 0 ]] ; then
# A non-zero return code means an error occurred, so tell the user and exit
echo "phpunit failed on rev $newrev - push deniend. Run tests locally and confirm they pass before pushing"
exit $rc
fi
fi
done
# Everything went OK so we can exit with a zero
exit 0
Are there any code examples left?
New code examples in category TypeScript
-
TypeScript 2022-03-27 19:30:45 typescript promise
-
TypeScript 2022-03-27 17:25:44 how to search for imports in vscode
-
TypeScript 2022-03-27 17:15:20 angular formgroup mark as touched
-
TypeScript 2022-03-27 17:05:06 use of slice and splice add elements array
-
TypeScript 2022-03-27 16:50:23 android studio loop through all objects in layout
-
TypeScript 2022-03-27 14:35:08 wergensherts meaning
-
TypeScript 2022-03-27 13:50:15 remove all the elements from a numpy array python
-
TypeScript 2022-03-27 12:35:49 redux toolkit typescript install
-
TypeScript 2022-03-27 12:35:30 laravel middleware for apis