It's literally been months since I've manually typed "cap production deploy". For the past several months, we've been implementing a lean startup process and using continuous deployment to push code to production. Continuous deployment's core premise is to deploy code to production with every commit. From my standpoint, it's been a dream come true.
Just Ship It!
The theory behind continuous deployment is rather simple, "unreleased code is a liability". Features that takes weeks to build without getting real feedback are distracting you from focusing on what your customers are seeing every day. Using continuous deployment forces you to think differently about feature development. Large complex features become incremental deployments with user feedback at each step to ensure you're headed in the right direction (and to pull the plug as quickly as possible if you're not). If you're able to adjust your feature during the development cycle, you save time (and money) that would be wasted on going in a wrong direction.
Effective and thorough testing are all that stands between a bad commit and a busted production environment, which means that continuous integration is absolutely critical. The Testing Nazi in me taken full advantage of this to push the envelope on the importance of testing. I've even hired a set of angry midgets to enforce proper testing standards...
If it's not tested, it's CRAP!
Cruisecontrol.rb is the heart and soul of our continuous deployment, but it's actually a very simple process. We register a custom rake task which runs our complete testsuite and if all tests pass, cruisecontrol flips the switch and deploys the code. Our rake task looks something like this:
- unit tests (Test::Unit)
- functional tests (ActionController::TestCase)
- integration tests (ActionController::IntegrationTest)
- acceptance tests (Selenium)
It's important to remember that you shouldn't go overboard building out infrastructure to support a continuous deployment process. The same rule of "undeployed code is a liability" applies to your testing environment. You absolutely can not afford to waste time building out a suite of tools until you need it. Simply take incremental steps from where you are today and slowly add in infrastructure as needed. Each step will incrementally move you towards a better system overall.