Skip to content

Instantly share code, notes, and snippets.

@hiroki-uchida
Created October 21, 2017 13:54
Show Gist options
  • Save hiroki-uchida/5d585c05fd36aabd18c2e09d31b9f145 to your computer and use it in GitHub Desktop.
Save hiroki-uchida/5d585c05fd36aabd18c2e09d31b9f145 to your computer and use it in GitHub Desktop.
Wercker + Rails + PostgreSQL
box: ruby:2.4.2
services:
- id: postgres:9.6
env:
POSTGRES_PASSWORD: postgres_password
POSTGRES_USER: postgres_user
build:
steps:
- bundle-install:
# 並列実行数 Werckerのcore数は16なので合わせる。
jobs: 16
- script:
name: Rubocopによるコーディングスタイルチェック
# XDG_CACHE_HOME Werkerのキャッシュディレクトリを指定することで、違反情報を全ビルドで共有し最適化。
#
# rubocop
# --display-cop-names 違反したルール名を表示
# --parallel 並列実行オプション
# --cache `XDG_CACHE_HOME` にキャッシュを保存
code: XDG_CACHE_HOME=$WERCKER_CACHE_DIR/rubocop_cache bin/bundle exec rubocop --display-cop-names --parallel --cache true
- script:
name: rails_best_practicesによるコーディングスタイルのチェック
code: bin/bundle exec rails_best_practices .
- script:
name: brakemanによるセキュリティ診断
code: bin/bundle exec brakeman
- script:
name: bundle-auditによるGemの脆弱性診断
code: bin/bundle exec bundle-audit check --update
# `config/database.yml` を生成
- rails-database-yml
- script:
name: index_shotgunによる重複インデックスのチェック
code: RAILS_ENV=test bin/bundle exec rake index_shotgun:fire
- script:
name: RSpec実行
code: BULLET=$BULLET AUTODOC=$AUTODOC COVERAGE=$COVERAGE RAILS_ENV=test bin/bundle exec rails db:reset spec
- script:
name: yardによるドキュメント自動生成
code: bin/bundle exec yard doc app/**/*.rb lib/**/*.rb
# RSpecで生成したカバレッジ結果をs3に保存
- s3sync:
key-id: $S3_SYNC_KEY
key-secret: $S3_SYNC_SECRET
bucket-url: s3://$S3_SYNC_BUCKET/$WERCKER_GIT_BRANCH/coverage/
source-dir: coverage
opts: --acl-public
# yardで生成したドキュメントをs3に保存
- s3sync:
key-id: $S3_SYNC_KEY
key-secret: $S3_SYNC_SECRET
bucket-url: s3://$S3_SYNC_BUCKET/$WERCKER_GIT_BRANCH/doc/
source-dir: doc
opts: --acl-public
after-steps:
# slack-notifierではメッセージ内容が固定なので、step-pretty-slack-notifyを使用
# Ruby環境でしか動作しないので、他のプロジェクトでは注意する
#
# See: https://app.wercker.com/applications/53e31d00631d554c4802d374/tab/details/
- wantedly/pretty-slack-notify:
webhook_url: $SLACK_URL
channel: $SLACK_CHANNEL
username: $SLACK_USERNAME
passed_message: "[Coverage Report](http://$S3_SYNC_BUCKET.s3-website-ap-northeast-1.amazonaws.com/$WERCKER_GIT_BRANCH/coverage/) / [API Document](http://$S3_SYNC_BUCKET.s3-website-ap-northeast-1.amazonaws.com/$WERCKER_GIT_BRANCH/doc/api/toc.html) / [Yardoc](http://coverage-rails-membr-api.s3-website-ap-northeast-1.amazonaws.com/$WERCKER_GIT_BRANCH/doc/yard/)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment