38
Toolbox of a Ruby team

Toolbox of a Ruby Team

Embed Size (px)

DESCRIPTION

Tools our team uses for development.

Citation preview

Page 1: Toolbox of a Ruby Team

Toolbox of a Ruby team

Page 2: Toolbox of a Ruby Team

@Artto

Team Ro

Page 3: Toolbox of a Ruby Team

The basics of development in a team

● A code repository

● Consistent development environment

● Code quality and code style consistency

● CI and deployment procedure

● Error tracking

● Communication

Page 4: Toolbox of a Ruby Team

Issue tracking?

● Jira

● Pivotal Tracker

● Trello

Page 5: Toolbox of a Ruby Team

Development environment

● No need for a virtual machine!

● rvm

● .env

● Database - Postgres App

● Pow

Page 6: Toolbox of a Ruby Team

is a command-line tool which

allows you to easily install, manage, and work

with multiple ruby environments from

interpreters to sets of gems.

Page 7: Toolbox of a Ruby Team

Examples

>rvm use 2.1.1

>rvm gemset create rails4

>rvm use 2.1.1@rails4

>gem install …

>bundle install …

Page 8: Toolbox of a Ruby Team

.ruby-version, .ruby-gemset

Specify the gemset name and ruby version by

including these two files in the root folder of the

Rails project.

Page 9: Toolbox of a Ruby Team

.env

Shim to load environment variables from .env

into ENV in development.

gem ‘dotenv-rails’

Page 10: Toolbox of a Ruby Team

.env example

FACEBOOK_API_KEY=f4c3b00kt3st

GA_CODE=UA-546094580-1

MAIL_HOSTNAME=example.com

Page 11: Toolbox of a Ruby Team

Postgres.app

The easiest way to get started with PostgreSQL on the Macrake db:create db:migrate

Page 12: Toolbox of a Ruby Team

Pow: Zero-configuration Rack server for Mac OS X

$ cd ~/.pow

$ ln -s /path/to/myapp

Then just go to http://myapp.dev/ and POW, it’s

running (or maybe you forgot to run bundle install)!

Page 13: Toolbox of a Ruby Team

.powrc

if [ -f "$rvm_path/scripts/rvm" ];

then

source "$rvm_path/scripts/rvm"

rvm use .

fi

Page 14: Toolbox of a Ruby Team

Development environment setup steps:

>git clone [git repo]

>cd newapp

ruby-2.1.2 - #gemset created /Users/user/.rvm/gems/ruby-2.1.2@newapp

ruby-2.1.2 - #generating newapp wrappers - please wait

>bundle install

>rake db:create db:migrate

>cd ~/.pow

>ln -s /path/to/newapp

http://newap.dev/

Page 15: Toolbox of a Ruby Team

Code style and consistency

The Ruby and RoR community is strict when it

comes to coding style and conventions!

This is really helpful for teams working on

projects, onboarding of new developers is easy.

Page 16: Toolbox of a Ruby Team

Sublime Text settings

For basic stuff, there’s these Sublime settings:

● Auto-delete trailing whitespaces

● Add newlines at the end of filesThis will save you a bunch of unnecessary headaches.

Page 17: Toolbox of a Ruby Team

Mandatory Sublime Settings

// Set to true to removing trailing whitespace on save

"trim_trailing_white_space_on_save": true,

// Set to true to ensure the last line of the file ends in a newline

// character when saving

"ensure_newline_at_eof_on_save": true,

Page 18: Toolbox of a Ruby Team

Code quality

● Code review!

● Naforo - not currently maintained :(

● Github pull requests - good enough

Page 19: Toolbox of a Ruby Team

Pull Requests

When merging feature branches into master,

do it via pull requests - this provides good

basics for code review.

Page 20: Toolbox of a Ruby Team

Code repository

● Git● When pulling from origin, do it using the --

rebase option, to avoid unnecessary merge

commits

● Don’t change merge commit messages!

● Is it sometimes acceptable to do a force

push, to make the repo cleaner?

Page 21: Toolbox of a Ruby Team

CI and Deployment

● Heroku - making it super simple, but has

downsides

● Mina and Capistrano

● Circle CI

Page 22: Toolbox of a Ruby Team

Easy to configure, runs tests, deploys code.

Hooks up to github, so it all runs every time you

push something into the repo. Deployment procedure descirbed in the circle.yml file.

Page 23: Toolbox of a Ruby Team

Example circle.ymlmachine:

services:

- postgresql

deployment:

staging:

branch: master

commands:

- '[[ ! -s "$(git rev-parse --git-dir)/shallow" ]] || git fetch --unshallow'

- git push --force [email protected]:staging-theapp.git $CIRCLE_SHA1:master:

timeout: 900

- heroku run rake db:migrate --app staging-theapp

- curl https://api.rollbar.com/api/1/deploy/ -F access_token=$RB_AT -F environment=staging -F

revision=$(git log -n 1 --pretty=format:"%H") -F local_username=CircleCI

Page 24: Toolbox of a Ruby Team

Example circle.ymlproduction:

branch: production

commands:

- '[[ ! -s "$(git rev-parse --git-dir)/shallow" ]] || git fetch --unshallow'

- git push --force [email protected]:production-theapp.git $CIRCLE_SHA1:master:

timeout: 900

- heroku run rake db:migrate --app production-theapp

- git config user.name "DLabs CircleCi"

- git config user.email "[email protected]"

- git tag -a $(date "+%Y%m%d%H%M")-production $CIRCLE_SHA1 -m "$(date "+%Y%m%d%H%M") deployed to

production"

- '[[ ! -s "$(git rev-parse --git-dir)/shallow" ]] || git fetch --unshallow'

- git push [email protected]:dlabs/theapp.git --tags

- curl https://api.rollbar.com/api/1/deploy/ -F access_token=$RB_ATP -F environment=production -F

revision=$(git log -n 1 --pretty=format:"%H") -F local_username=CircleCI

Page 25: Toolbox of a Ruby Team

Wonders of Heroku

Super easy to deploy and scale your app.

Just push into your Heroku app’s repo and it will set it up

automatically. Use $$$liders to scale up your app!

No static IP

DNS is tricky (many DNS providers don’t offer CNAME

domain records for root domains), if you need a static IP,

you’ll need to set up your own proxy or use Proximo($$$).

Page 26: Toolbox of a Ruby Team

$ bundle exec cap staging deploy

$ bundle exec cap production deploy

Page 27: Toolbox of a Ruby Team

Example Capistrano Task

server 'example.com', roles: [:web, :app]

server 'example.org', roles: [:db, :workers]

desc "Report Uptimes"

task :uptime do

on roles(:all) do |host|

execute :any_command, "with args", :here, "and here"

info "Host #{host} (#{host.roles.to_a.join(', ')}):\t#{capture(:uptime)}"

end

end

Page 28: Toolbox of a Ruby Team

Really fast deployer and server automation tool

“Mina works really fast because it’s a deploy Bash script

generator. It generates an entire procedure as a Bash

script and runs it remotely in the server”

Page 29: Toolbox of a Ruby Team

Mina example deploy$ mina deploy --verbose

-----> Creating the build path

$ mkdir tmp/build-128293482394

-----> Cloning the Git repository

$ git clone https://github.com/nadarei/flipstack.git . -n --recursive

Cloning... done.

-----> Installing gem dependencies using Bundler

$ bundle install --without development:test

Using i18n (0.6.0)

Using multi_json (1.0.4)

...

Your bundle is complete! It was installed to ./vendor/bundle

-----> Moving to releases/4

$ mv "./tmp/build-128293482394" "releases/4"

-----> Symlinking to current

$ ln -nfs releases/4 current

-----> Launching

$ cd releases/4

$ sudo service nginx restart

-----> Done. Deployed v4

Page 30: Toolbox of a Ruby Team

Error Tracking

Watch those overage fees!!!

Also includes some handy performance metrics

Page 31: Toolbox of a Ruby Team

WebHooks:

● github pushes

● CI - tests and deployment

● code review notifications

● error tracking

Animated GIFs!

Page 32: Toolbox of a Ruby Team
Page 33: Toolbox of a Ruby Team

HipChat - Github

Page 34: Toolbox of a Ruby Team

HipChat - Circle CI

Page 35: Toolbox of a Ruby Team

HipChat - Error Tracking

:(

Page 36: Toolbox of a Ruby Team

HipChat - Cat Facts

Page 37: Toolbox of a Ruby Team

?

Page 38: Toolbox of a Ruby Team

Linkshttp://rvm.io/

http://postgresapp.com/

http://pow.cx/

http://www.sublimetext.com/

https://circleci.com/

http://nadarei.co/mina/

http://capistranorb.com/

https://www.hipchat.com/

https://www.heroku.com/

https://rollbar.com

https://appsignal.com/