user623990
user623990

Reputation:

Having a remote test repository with git

In my current set up, my development server has a bunch of bare git repositories from which me and some other users push to. However, now, I'd like to integrate PHPUnit testing on the server itself.

My initial idea was to have a sub directory in each repo named tests, then have something like VisualPHPUnit run the tests so I can see the results through the server's "website". However, seeing as the remote repositories are bare, I can't exactly tell VPHPU to look for the test directories -- as they aren't really there.

Is there a better way of doing things? I was thinking of maybe having another repository that would contain tests for all the projects and just making it not bare -- but that goes against git standards and could possibly break stuff.

Upvotes: 0

Views: 947

Answers (2)

michas
michas

Reputation: 26545

I would suggest managing your remote git repository with gerrit and setting up jenkins for running all automatic tests using the gerrit plugin.

That way you push your change to gerrit, gerrit will notify jenkins, jenkins runs all test on the freshly pushed code. Now gerrit opens a review presenting the change and the result of the tests. Then when jenkins is happy and the change looks sane, you merge your changes to the official branch from which another developer can fetch it again.

This procedure might seem a bit complex, but it makes sure only successfully tested code will reside in your repository, and if you break any test you can be sure you broke it. - That's the whole point of automatic testing. ;)

Upvotes: 1

John Szakmeister
John Szakmeister

Reputation: 47032

I'd think you'd do better to setup Jenkins or QuickBuild. Jenkins is open-source, whereas QuickBuild is not. But QuickBuild does have a free version, and I've found it to be more reliable than the former. Both will allow you to checkout your source, run tests, and post the results. And over the long haul, it'll allow you to do more, such as packaging your product for deployment.

If you're dead set on trying to make your current idea work, you'll need a post-receive hook that will checkout the code somewhere, run your tests against the checkout, and post the results to a known location. You'll need to think about a few things though. For instance, do you want to test every branch? Just a single one? The post-receive hook will tell you about all branches being updated, so you might need to filter if you only want to test master. Pro Git has some information on hooks and how to customize them.

I'd avoid using a bare repository. You'll have to deal with things like pushing into a bare repository, which is frowned upon. I think in the end, you'll really want Jenkins or QuickBuild to help you.

Upvotes: 1

Related Questions