Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run all tests before pushing to GitHub?

Is there a service that offers this functionality:

When pushing to GitHub, it runs all RSpec and Jasmine tests. If any test fails, it rejects the push.

like image 229
B Seven Avatar asked Dec 05 '12 22:12

B Seven


People also ask

How do you test a pre Push hook?

pre-push hook is passed local and remote IDs. To run tests on every commit run a loop over git rev-list <remote-id>.. <local-id> . In the loop checkout every commit into a temporary directory, run tests and remove the directory.

How do you set up a pre-commit hook?

Open a terminal window by using option + T in GitKraken Client. Once the terminal windows is open, change directory to . git/hooks . Then use the command chmod +x pre-commit to make the pre-commit file executable.


2 Answers

Rejecting pushes can be done by githooks. A hook is typically just a script which exits with status 0 or 1. Depending on that result the action is allowed or disallowed.

See man githooks for a list of available hooks and how they work.

Also github seems to allow you to configure your hooks: http://developer.github.com/v3/repos/hooks/

like image 194
michas Avatar answered Oct 27 '22 04:10

michas


Have a look at the Gerrit/Jenkins combination. We use it to build our C++ code before it gets pushed to the real branch. You can also set it up to run tests before pushing it to the real branch. I think you can also set it up to use Github.

like image 1
gvd Avatar answered Oct 27 '22 04:10

gvd