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?
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.
You can automatically build and test your projects with GitHub Actions.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With