Upload
arto-artnik
View
98
Download
2
Embed Size (px)
DESCRIPTION
Tools our team uses for development.
Citation preview
Toolbox of a Ruby team
@Artto
Team Ro
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
Issue tracking?
● Jira
● Pivotal Tracker
● Trello
Development environment
● No need for a virtual machine!
● rvm
● .env
● Database - Postgres App
● Pow
is a command-line tool which
allows you to easily install, manage, and work
with multiple ruby environments from
interpreters to sets of gems.
Examples
>rvm use 2.1.1
>rvm gemset create rails4
>rvm use 2.1.1@rails4
>gem install …
>bundle install …
.ruby-version, .ruby-gemset
Specify the gemset name and ruby version by
including these two files in the root folder of the
Rails project.
.env
Shim to load environment variables from .env
into ENV in development.
gem ‘dotenv-rails’
.env example
FACEBOOK_API_KEY=f4c3b00kt3st
GA_CODE=UA-546094580-1
MAIL_HOSTNAME=example.com
Postgres.app
The easiest way to get started with PostgreSQL on the Macrake db:create db:migrate
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)!
.powrc
if [ -f "$rvm_path/scripts/rvm" ];
then
source "$rvm_path/scripts/rvm"
rvm use .
fi
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/
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.
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.
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,
Code quality
● Code review!
● Naforo - not currently maintained :(
● Github pull requests - good enough
Pull Requests
When merging feature branches into master,
do it via pull requests - this provides good
basics for code review.
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?
CI and Deployment
● Heroku - making it super simple, but has
downsides
● Mina and Capistrano
● Circle CI
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.
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
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
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($$$).
$ bundle exec cap staging deploy
$ bundle exec cap production deploy
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
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”
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
Error Tracking
Watch those overage fees!!!
Also includes some handy performance metrics
WebHooks:
● github pushes
● CI - tests and deployment
● code review notifications
● error tracking
Animated GIFs!
HipChat - Github
HipChat - Circle CI
HipChat - Error Tracking
:(
HipChat - Cat Facts
?
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/