We have someone (let’s call him Ted) that is responsible for testing new features and bug fixes.
We’re using Git and GitHub. master
should be/is always deployable and development
is where we commit/merge new features or bug fixes, but only after they have been tested by Ted.
The project is in PHP.
I’d like the testing process to go like this:
- A developer wants to work on a new feature (let’s say the feature/bug #123 as Ted documented in the issue tracker), so he pulls
origin/development
todevelopment
on his local repository and creates a new branch (let’s sayissue-123
) from there. - Once he’s happy with his work, he commits and pushes his new branch to
origin
. - Ted connects to
test.ourproject.com/choose-branch
and sees a list of the branches onorigin
and chooses to switch onissue-123
(it should be doable through the webpage). He then goes ontest.ourproject.com
, tests the hell out of the web application (he’s really pitiless) and after some back and forth with the developer, he’s happy with the feature. - Ted tells the developer that he can merge
issue-123
ontodevelopment
onorigin
. - Rinse and repeat.
For the third step, I could hack something that does the job (showing and switching branches from a specific page), but I feel that what I’ve described is a very common pattern.
So my question is:
Is this a good / sustainable / maintainable workflow for branching? Can you back up your answer by citing some examples of other projects following this workflow?
6
The branch workflow sounds a lot like gitflow http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow and there are support tools around it. It is highly recommended.
If there is only one tester, your testing workflow sounds fine, but if there are multiple people then development might move between start and finish, and of course testing should ideally be fully performed after any merge. This is where automated testing can really help or a slow (thorough) tester might never finish!
Another problem is that with many features and branches it becomes temping to mix and match features into a release (or to choose to evict after acceptance and merging) or perhaps if features are dependent on each other. The problem is if you start getting temped to rewrite history (rebase/delete a commit or merge) on a PUBLISHED branch-meaning one which has been pushed to a multidev repo. This is rewriting public history. It can be done for good or evil and even if done for good can cause problems to the unwary, and best practice is to avoid it so the question will never come up. However, some integration branch workflows make this very tempting, so if you have strong protection on such branches (eg gitolite per user branch restrictions) and people expect such activity so always rebase their code on such a branch, proceed–with caution!
I’d also like to recommend reading http://sethrobertson.github.com/GitBestPractices/ which discusses all of these matters and has many good references.
1
I am not sure the switching page itself is a common pattern. Most projects probably simply have the tester check it out with git command.
The general approach definitely sounds reasonable.
Google even wrote Gerrit to support similar style; it’s more about reviewing the code, but approving integration normally involves both review and testing. Usually it is also interconnected with continuous integration server which builds all the submissions first (I am not sure whether they use Jenkins in Google, but I believe I’ve seen appropriate connectors somewhere).
Git itself uses a slight variation on the theme. It’s maintainer has a script that merges all pending submissions into a branch called pu
(for “proposed updates” presumably; the branch is deleted and re-created each time as the pending submissions are often rebased). This is than tested by various people. If it’s fine, than the submissions that are considered complete are merged into next
(that’s the same as your development
). If not, than somebody tests the individual submissions to see which one is broken. This makes it a bit easier for the tester since they don’t have to switch branches most of the time; they simply report whether the test integration works.
If your testing is done automatically rather than manually, I think Travis (a CI system for GitHub) will pretty much do what you want–it automatically runs tests on all pull requests. (More information about this process, including screenshots.)
Note that tests are run not on the branch, but the branch after it’s been merged into master. (i.e. what you would get after merging the branch into master–you’re guaranteed that tests will still run successfully post-merge.)
If commits are added to the branch, tests are re-run. (Though for some reason adding commits to master doesn’t seem to re-run the tests.)
2