Hacker News new | ask | show | jobs
by mpdehaan2 4041 days ago
The 'merged once deployed to production' thing, yes, I know even if advocated by GitHub, seems extremely weird to me. It does seem they have a staging check first, which is good.

It seems you'd want to merge it first, so that you know it when merged with "all the things" on master, so it more closely mirrors what you are going to get once it's merged in.

So they could just merge first, and then if staging passes in their CI system, automatically deploy to prod, which is the way many orgs do it.

My point is though, you'd want to deal with the merge fun (if any) first, else you are deciding to test branches (pull requests) that only have ALL of the commits from master (rebased, etc), so it's easier to just make sure they hop on master first, else you might "remove" something from prod for a while until it's merged in. Not good.

They may have some things to deal with that, but in this case, it doesn't seem like something I'd recommend for most people, and feels weird and organically evolved. One branch may not have the commits another has and both could be deployed without merging, leaving the github deployed code state fluctuating back and forth as one commit drops out and another drops in, before finally both are in at the same time.

I wonder how this is handled?

3 comments

I'm guessing that the master branch is first merged down to their develop branch or directly to their release branch. That way their release branch does have everything in master already.
Indeed that is the case:

> Since master is our stable release branch, we want to ensure that any branches being deployed are caught up with the latest code in master. Before proceeding with a deployment, Hubot will detect if our branch is behind and automatically merge in master if required.

We've adopted some aspects of this flow, and our take is that we test feature branches on stage thoroughly including CI test run and code review.

Then we merge to master and let all the CI run again while we manually verify. Any troubles and you revert. All green? Deploy right away. We try never to deploy more than 2-3 changes to production at a time.

The main bottleneck for us is the speed of our CI runs. It's tempting to merge in a lot of changes to master and let them accumulate on QA. Reducing the test run time is an ongoing goal and should make this system pretty scalable for our team.

Usually, you won't have merge conflicts if you deploy early and often and keep feature branches deliberately small. For larger stories, consider breaking it into discrete feature branches that implement part of the functionality (ex: behind a feature gate).

The deployment system automatically merges master into the branch being tested on deployment, and will not deploy any branch that does not contain master. In fact, there is a check that nags the main app team if master is not deployed to production for some reason (usually someone merging docs changes while someone is testing a "real" branch). It's considered an abnormal state, and I will often block all deployments until we figure out why master hasn't gone out.

Even forced deployments (which ignore CI and a few other checks for emergencies or maintenance mode) won't deploy a branch that's 24 hours behind master.