We run 2 different environments on our server – say, production.mydomain.com and staging.mydomain.com
The staging environment is nearly identical to the production environment, except that it often has several new features which are being reviewed (eg new_user_profile, image_tagging, etc). These features are individually accepted by the client at different times.
What is the best way to push any individual feature (eg new_user_profile) from staging to production?
Our setup is listed below, but would like to hear alternatives you use also:
- Ruby on Rails
- Git (we have several feature branches, which get merged into a “staging” branch when nearing completion)
- Capistrano, with multi-staging ext.
We have tried the following two approaches, neither of which works terribly well:
- Having lots of if/else statements throughout our code, eg if new_user_profile ….
- Deploying individual git branches (eg branch new_user_profile) to staging, getting this reviewed, and then merging to production
Without additional ifs, your best bet would probably be to merge feature branches into master when they’re ready to deploy. Alternatively, you could implement a feature toggle pattern. I don’t know that there’s a common gem for it, but I’ve used a similar pattern in my own projects. Martin Fowler wrote a good post on feature toggles here if you want to check it out. He makes a pretty valid argument that feature branches go against ideas of continuous integration. I don’t feel so strongly about that, so long as the branches are being run through a CI server, but your milage may vary. I’d like to see a good library that just uses blocks with a feature toggle, so you could do something like:
Dont know of a well implemented solution for that though. Make a gem and put it on github 🙂