Run CI on wercker with Ruby on Rails 5


This article describe how to run RSpec on wercker for Rails 5 application.


🏈 Preparation

Sign up / Log in to wercker

Sign up / Log in - wercker

Add application

wercker_creating_application

Registration repository

choose_repository

Configure Access

configure_access

🐡 Adding wercker.yml to your project

Please add wercker.yml to your project root. Official document is as follows:

wercker - docs

box: ruby:2.3.1

# You can also use services such as databases. Read more on our dev center:
# http://devcenter.wercker.com/docs/services/index.html
# http://devcenter.wercker.com/docs/services/postgresql.html
services:
- id: postgres
env:
POSTGRES_PASSWORD: secret_password

# http://devcenter.wercker.com/docs/pipelines/index.html
unit-test:
# http://devcenter.wercker.com/docs/steps/index.html
steps:
- bundle-install:
jobs: 4

# Prepare postgresql for Rails
- rails-database-yml:
service: postgresql-docker

- install-packages:
name: Install node.js, build-essential, libpq-dev
packages: build-essential libpq-dev nodejs

- script:
name: Set up db
code: |
RAILS_ENV=test bundle exec rake db:schema:load

- script:
name: Run RSpec
code: bundle exec rspec

after-steps:
- slack-notifier:
url: $SLACK_URL
channel: $SLACK_CHANNEL
username: werckerbot
notify_on: failed

🍄 Add your environment variables

Please set environment variables to application environment variable on wercker.

SLACK_URL https://webhook.slack.com/xxx

env_variables

🐠 Run CI on wercker

After adding wercker.yml and git commit & git push, you can run your CI scrpit on wercker!

run_wercker

🗽 Appendix: Deploy to Elasticbeanstalk

If you want to deploy by wercker, please use following configuration:

deploy:
steps:
- hotakasaito/elastic-beanstalk-deploy:
key: $AMAZON_KEY
secret: $AMAZON_SECRET_KEY
app_name: My Application
env_name: production
region: ap-northeast-1
nohup: true
opts: --debug

If you want to know more detail please read hotakasaito/elastic-beanstalk-deploy.

🎉 Special Thanks

🖥 Recommended VPS Service

VULTR provides high performance cloud compute environment for you. Vultr has 15 data-centers strategically placed around the globe, you can use a VPS with 512 MB memory for just $ 2.5 / month ($ 0.004 / hour). In addition, Vultr is up to 4 times faster than the competition, so please check it => Check Benchmark Results!!