Last active
July 30, 2018 12:47
-
-
Save EtienneDepaulis/8c6a7ce580b650a2a028ccfdc56c871f to your computer and use it in GitHub Desktop.
CircleCI V2 Rails + Postgres + Headless Chrome + Rubocop + Heroku we currently use @ Lifen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2 | |
jobs: | |
checkout_code: | |
docker: | |
- image: circleci/ruby:2.5.1-node-browsers | |
- image: circleci/postgres:10.3-alpine | |
working_directory: ~/circleci-app | |
steps: | |
- checkout | |
- save_cache: | |
key: v1-repo-{{ .Environment.CIRCLE_SHA1 }} | |
paths: | |
- ~/circleci-app | |
bundle_dependencies: | |
docker: | |
- image: circleci/ruby:2.5.1-node-browsers | |
- image: circleci/postgres:10.3-alpine | |
working_directory: ~/circleci-app | |
steps: | |
- restore_cache: | |
keys: | |
- v1-repo-{{ .Environment.CIRCLE_SHA1 }} | |
- restore_cache: | |
keys: | |
- v1-bundle-{{ checksum "Gemfile.lock" }} | |
- run: bundle install --path vendor/bundle | |
- save_cache: | |
key: v1-bundle-{{ checksum "Gemfile.lock" }} | |
paths: | |
- ~/circleci-app/vendor/bundle | |
lint: | |
docker: | |
- image: circleci/ruby:2.5.1-node-browsers | |
environment: | |
RAILS_ENV: test | |
working_directory: ~/circleci-app | |
steps: | |
- restore_cache: | |
keys: | |
- v1-repo-{{ .Environment.CIRCLE_SHA1 }} | |
- restore_cache: | |
keys: | |
- v1-bundle-{{ checksum "Gemfile.lock" }} | |
- run: bundle --path vendor/bundle | |
- run: git diff-tree -r --no-commit-id --name-only 'origin/develop..HEAD' | xargs --no-run-if-empty bundle exec rubocop --config .rubocop.yml --force-exclusion --fail-level warn | |
test: | |
docker: | |
- image: circleci/ruby:2.5.1-node-browsers | |
environment: | |
RAILS_ENV: test | |
DATABASE_URL: postgres://[email protected]:5432/db_name | |
- image: circleci/postgres:10.3-alpine | |
environment: | |
POSTGRES_USER: root | |
POSTGRES_DB: db_name | |
working_directory: ~/circleci-app | |
steps: | |
- restore_cache: | |
keys: | |
- v1-repo-{{ .Environment.CIRCLE_SHA1 }} | |
- restore_cache: | |
keys: | |
- v1-bundle-{{ checksum "Gemfile.lock" }} | |
- run: bundle --path vendor/bundle | |
- run: | |
name: Wait for DB | |
command: dockerize -wait tcp://localhost:5432 -timeout 1m | |
- run: bundle exec rails db:create db:schema:load | |
- run: bundle exec rspec --color --require spec_helper --format RspecJunitFormatter --out ~/rspec/rspec.xml spec --format progress | |
- store_test_results: | |
path: ~/rspec | |
- store_artifacts: | |
path: coverage | |
deploy_master: | |
docker: | |
- image: circleci/ruby:2.5.1-node-browsers | |
steps: | |
- checkout | |
- run: | |
name: Deploy master branch to Heroku | |
command: | | |
git push https://heroku:[email protected]/app-production.git master:master | |
deploy_staging: | |
docker: | |
- image: circleci/ruby:2.5.1-node-browsers | |
steps: | |
- checkout | |
- run: | |
name: Deploy develop branch to Heroku | |
command: | | |
git push https://heroku:[email protected]/app-staging.git develop:master | |
workflows: | |
version: 2 | |
main: | |
jobs: | |
- checkout_code | |
- bundle_dependencies: | |
requires: | |
- checkout_code | |
- lint: | |
requires: | |
- bundle_dependencies | |
- test: | |
requires: | |
- lint | |
- deploy_master: | |
requires: | |
- test | |
filters: | |
branches: | |
only: master | |
- deploy_staging: | |
requires: | |
- test | |
filters: | |
branches: | |
only: develop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment