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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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.

1
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:

1
2
3
4
5
6
7
8
9
10
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