Skip to content

Instantly share code, notes, and snippets.

@croaky
Created September 22, 2012 19:11
Show Gist options
  • Save croaky/3767459 to your computer and use it in GitHub Desktop.
Save croaky/3767459 to your computer and use it in GitHub Desktop.

Protocol

A guide for getting things done.

Set up laptop

Set up your laptop with this script and these dotfiles.

Create Rails app

Get Suspenders.

gem install suspenders

Create the app.

suspenders app-name --heroku true --github organization/app-name

Set up Rails app

Get the code.

git clone git@github.com:organization/app.git

Set up the app's dependencies.

cd project
bundle --binstubs
rake db:setup

Add Heroku remotes for staging and production environments.

git remote add staging git@heroku.com:<app>-staging.git
git remote add production git@heroku.com:<app>-production.git

Use Heroku config to get ENV variables.

heroku config:pull --app <app>-staging

Delete extra lines in .env, leaving only those needed for app to function properly. For example: BRAINTREE_MERCHANT_ID and S3_SECRET.

Use Foreman to run the app locally.

foreman start

It uses your .env file and Procfile to run processes just like Heroku's Cedar stack.

Write a feature

Create a local feature branch based off master.

git checkout master
git pull --rebase
git checkout -b your-initials-new-feature

Rebase frequently to incorporate upstream changes.

git fetch origin
git rebase origin/master
<resolve conflicts>

When feature is complete and tests pass, commit the changes.

rake
git add -A
git status
git commit -v

Write a good commit message.

Present-tense summary under 50 characters

* More information about commit (under 72 characters).
* More information about commit (under 72 characters).

Share your branch.

git push origin [branch]

Submit a Github pull request.

Ask for a code review in Campfire.

Review code

A team member other than the author reviews the pull request.

They make comments and ask questions directly on lines of code in the Github web interface or in Campfire.

For changes which they can make themselves, they check out the branch.

git checkout <branch>
rake db:migrate
rake
git diff staging/master..HEAD

They make small changes right in the branch, test the feature in browser, run tests, commit, and push.

When satisfied, they comment on the pull request Ready to merge.

Merge

Rebase interactively. Squash commits like "Fix whitespace" into one or a small number of valuable commit(s). Edit commit messages to reveal intent.

git rebase -i origin/master
rake

View a list of new commits. View changed files. Merge branch into master.

git log origin/master..[branch]
git diff --stat origin/master
git checkout master
git merge [branch] --ff-only
git push

Delete your remote feature branch.

git push origin :[branch]

Delete your local feature branch.

git branch -d [branch]

Deploy

View a list of new commits. View changed files. Deploy to Heroku staging.

git fetch staging
git log staging/master..master
git diff --stat staging/master
git push staging

Run migrations (if necessary).

heroku run rake db:migrate -r staging

Restart the dynos if migrations were run.

heroku restart -r staging

Introspect to make sure everything's ok.

watch heroku ps -r staging

Test the feature in browser.

Deploy to production.

git fetch production
git log production/master..master
git diff --stat production/master
git push production
heroku run rake db:migrate -r production
heroku restart -r production
watch heroku ps -r production

Watch logs and metrics dashboards.

Close pull request and comment Merged.

Use scripts from thoughtbot/dotfiles to quickly access the Heroku console, backup the production database, and transfer production data to staging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment