Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build and unit test on push?

I'm considering having the central repository (Mercurial) run a pre-commit hook that validates the code that has come in, and if it results in a failed build or unit test, disallows the push.

One obvious downside for this is that the build takes a couple of minutes, and would leave the developer hanging until it was complete.

Has anyone done anything similar, or have any comments?

like image 665
moswald Avatar asked Mar 02 '11 03:03

moswald


People also ask

Can you run unit tests on GitHub?

Verifying code changes with unit tests is a critical process in typical development workflows. GitHub Actions provides a number of custom actions to collect and process the results of tests allowing developers to browse the results, debug failed tests, and generate reports.

Can I test code on GitHub?

You can automatically build and test your projects with GitHub Actions.


2 Answers

To me, this is an anti-pattern. Mercurial, a VERSION CONTROL SYSTEM, is to version your sources. It is not a build system, continuous integration system, unit testing suite or anything like that. You should delegate things like this to the appropriate tool and a pre-commit type hook is not the place. I would use the open source continuous integration suite called Jenkins (http://jenkins-ci.org/) and do the build/test/etc upon commit/push. You can configure Jenkins to do a plethora of things based on the build results.

like image 121
Jeremy Whitlock Avatar answered Nov 07 '22 17:11

Jeremy Whitlock


Its called a gated check-in, or pretested-commit. Some CI systems allow it, some don't.

Here's a blog article about TFS doing such a thing: http://spandothers.wordpress.com/2010/06/08/tfs-2010-gated-check-ins/

IMHO, its a meh feature. Check-in, break the build, fix-it, and move-on. Breaking the build should not be that big of a deal.

like image 25
Ritch Melton Avatar answered Nov 07 '22 17:11

Ritch Melton