RefSpectacular 'a variant of linear branching'
Whats the main goal of Source Control, to protect and share your code, to retain a history on your “source”.
Main points of refspec push flow.
branch | purpose |
---|---|
develop | The main trunk of our codebase. HEAD of this branch is always deployed to the acceptance environment. This is done with circle ci. (can be any ci tool, I just like circle) |
staging | This branch is used to pre-deploy the release to a pre-production (staging) environment. This is used for regression testing, automation runs, hot fixes and a chance to test the deploy itself. |
performance | This branch is used to test performance in a performance environment, typically in alignment with acceptance but can point to anything. |
production | The code that is currently deployed to Production. |
branch | purpose |
---|---|
feature/chore/bug/so on | These branches are used to develop new code, this could be a feature/bug/chore/task whatever work type your project supports. These branches are merged into develop via strict peer review process. |
release | These branches are used to release software. We use build tooling to auto cut and auto generate the release and release notes. These are typically only a few commits, we try to release often, at least once a day but can be many times in one day. |
hotfix | These branches are used to release burning issues, typically stemming from the last release. But are rare events in todays world, we typically just get commits into head and do a normal release since we keep so close to head. |
git push remote src:dst
example:
git push origin release/3.2.2:production
main thing to focus on:
dst is name of the remote thing you want to update.
If dst exists it will try to fast forward, if no ff allowed, just force (minus develop branch), we dont care about history on anything but trunk (develop).
git push origin release/3.2.2:production -f
Other great sources of info on refspec
https://git-scm.com/docs/git-push
https://stackoverflow.com/questions/38494546/git-push-what-is-the-difference-between-headrefs-heads-branch-and-branch
Step 1.
Create your repo and load your assets, begin development.
Step 2.
Cut your branch off develop for feature work
$> git checkout develop
$> git pull
$> git checkout -b feature/new-feature-jiraproject-1234567
write some Code
Submit PR for your code into develop. I wont go over Peer Review guidelines in this flow, I will address it later.
Step 3.
Fast forward 5 Develop merges and you finally have something to test. Refspec push develop branch to acceptance branch for testing.
$> git checkout develop
$> git pull
$> git push origin develop:acceptance
Circle triggers an acceptance deployment on successful acceptance branch build.
Step 4.
Refspec push acceptance branch to performance branch
$> git checkout acceptance
$> git pull
$> git push origin acceptance:performance
Circle triggers an performance deployment on successful performance branch build. Post successfull deploy we auto trigger a performance test.
Step 5.
We finally have a set of releasable items, lets cut a release branch.
This flow is cut off head
$> git checkout develop
$> git pull
$> git checkout -b release/1.xx.0
$> git push origin release/x.xx.x
This flow is reset back to a specific sha
$> git checkout develop
$> git pull
$> git checkout -b release/1.xx.0
$> git reset --hard <short sha>
$> git push origin release/x.xx.x
Once the release is green in circle, refspec push the release branch to staging branch
$> git push origin release/x.xx.x:staging
staging branch will deploy to staging environment via circle build
Step 6. cut regression fix branch off of release branch
$> git checkout release/3.xx.0
$> git pull origin release/3.xx.0
$> git checkout -b bug/fix-show-stopper-1234567
# write some code
$> git push origin bug/fix-show-stopper-1234567
# wait for some Peer Review
$> git checkout release/x.xx.0
$> git pull origin release/x.xx.0
# if any changes were pulled...
$> git checkout bug/fix-show-stopper-1234567
$> git rebase release/x.xx.0
$> git checkout release/x.xx.0
$> git merge --no-ff bug/fix-show-stopper-1234567
$> git push origin release/3.xx.0
Once the release is green in circle, refspec push the release branch to staging branch
$> git push origin release/x.xx.x:staging
staging branch will deploy to staging environment via circle build
Step 7. We follow a dual PR flow where release/hotfix regression is put into release/hotfix and develop.
Once your fix is in the release/hotfix, do an interactive rebase on your release fix branch then do a PR into develop.
$> git pull origin develop
$> git checkout bug/fix-show-stopper-WMMW-123
$> git rebase develop -i
Drop any commits that are not part of your fix, and then push your changes. Open a PR against develop
Step 8.
Once signed off by all parties, push release branch to production branch, this triggers production deployment.
$> git checkout release/x.xx.x
$> git pull
$> git push origin release/x.xx.x:production
Step 9.
Tag the release in github
Tag version:
x.xx.x
Target:
release/x.xx.x
Title:
x.xx.x
Description:
Intranet link to releasenotes
Hotfixes are Cut from last released Tag. Check for last released Tag.
git fetch
git tag
git checkout x.xx.x
You’ll be in a detached head state
git checkout -b release/x.xx.x
git push origin release/x.xx.x
Follow steps 6 - 9 to finish out the Hotfix.
Rollbacks in Refspec are achieved by refspecing last successfully released tag to production branch.
Check in github to see what the last released tag is. That will be your last good commit before your latest push that broke things. Verify that the last released tag matches the commit on production branch just before you pushed your broken code.
git checkout production branch; git fetch; git pull;
git reset --hard ${SHA}
git show-ref production
git push origin production -f
This will push the last good code to Production branch and will deploy it Production Environment
We put robust peer review in place.
We have many stacks/apps and provisioning/deployment tools. Finding a little sanity in the way we manage our code is key. Watching shas progress in the RefSpec flow, is something to see. Your Network graphs will clean up, it will be easy to deploy and manage environments. The majority of the manual steps can be automated.
We have slimmed down our branches and environments to just use
Weve reorg’d testing and where its done.