Guest User

Untitled

a guest
Apr 17th, 2018
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. references:
  2. commands:
  3. setup_heroku: &setup_heroku
  4. name: Setup Heroku
  5. command: bash .circleci/setup-heroku.sh
  6. deploy_heroku: &deploy_heroku
  7. name: Deploy Heroku
  8. command: |
  9. git push -f git@heroku.com:$HEROKU_APP_NAME.git master
  10. heroku run rake db:migrate -a $HEROKU_APP_NAME
  11. sleep 5 # sleep for 5 seconds to wait for dynos
  12. heroku restart -a $HEROKU_APP_NAME
  13.  
  14. version: 2
  15. jobs:
  16. build:
  17. parallelism: 1
  18. docker:
  19. - image: circleci/ruby:2.5.0-node-browsers
  20. environment:
  21. BUNDLE_JOBS: 3
  22. BUNDLE_RETRY: 3
  23. BUNDLE_PATH: vendor/bundle
  24. REDIS_HOST: 127.0.0.1
  25. PGHOST: 127.0.0.1
  26. PGUSER: postgres
  27. RAILS_ENV: test
  28. - image: circleci/postgres:9.4.16-alpine-postgis
  29. environment:
  30. POSTGRES_USER: postgres
  31. POSTGRES_DB: tsukulink_test
  32. POSTGRES_PASSWORD: xxxxxxxx
  33. - image: redis:4.0.8-alpine
  34. steps:
  35. - checkout
  36.  
  37. # Which version of bundler?
  38. - run:
  39. name: Which bundler?
  40. command: bundle -v
  41.  
  42. # Restore bundle cache
  43. - restore_cache:
  44. keys:
  45. - rails-tsukulink-bundle-v2-{{ checksum "Gemfile.lock" }}
  46. - rails-tsukulink-bundle-v2-
  47.  
  48. - run:
  49. name: Bundle Install
  50. command: bundle check || bundle install
  51.  
  52. # Store bundle cache
  53. - save_cache:
  54. key: rails-tsukulink-bundle-v2-{{ checksum "Gemfile.lock" }}
  55. paths:
  56. - vendor/bundle
  57.  
  58. # # Only necessary if app uses webpacker or yarn in some other way
  59. # - restore_cache:
  60. # keys:
  61. # - rails-tsukulink-yarn-{{ checksum "yarn.lock" }}
  62. # - rails-tsukulink-yarn-
  63. #
  64. # - run:
  65. # name: Yarn Install
  66. # command: yarn install --cache-folder ~/.cache/yarn
  67. #
  68. # # Store yarn / webpacker cache
  69. # - save_cache:
  70. # key: rails-tsukulink-yarn-{{ checksum "yarn.lock" }}
  71. # paths:
  72. # - ~/.cache/yarn
  73.  
  74. - run:
  75. name: Wait for DB
  76. command: dockerize -wait tcp://localhost:5432 -timeout 1m
  77.  
  78. - run:
  79. name: Database setup
  80. command: bin/rails db:schema:load --trace
  81.  
  82. # Run rspec in parallel
  83. - type: shell
  84. command: |
  85. bundle exec rspec --profile 10 \
  86. --format RspecJunitFormatter \
  87. --out test_results/rspec.xml \
  88. --format progress \
  89. $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
  90. # Save test results for timing analysis
  91. - store_test_results:
  92. path: test_results
  93.  
  94. deploy_staging:
  95. machine:
  96. enabled: true
  97. environment:
  98. HEROKU_APP_NAME: tsukulink-staging
  99. steps:
  100. - checkout
  101. - add_ssh_keys:
  102. fingerprints:
  103. - "xxxxx"
  104. - run: *setup_heroku
  105. - run: *deploy_heroku
  106.  
  107. deploy_release:
  108. machine:
  109. enabled: true
  110. environment:
  111. HEROKU_APP_NAME: tsukulink
  112. steps:
  113. - checkout
  114. - add_ssh_keys:
  115. fingerprints:
  116. - "xxxxx"
  117. - run: *setup_heroku
  118. - run: *deploy_heroku
  119.  
  120. workflows:
  121. version: 2
  122. build-and-deploy:
  123. jobs:
  124. - build
  125. - deploy_staging:
  126. requires:
  127. - build
  128. filters:
  129. branches:
  130. only: master
  131. - deploy_release:
  132. requires:
  133. - build
  134. filters:
  135. branches:
  136. only: release
Add Comment
Please, Sign In to add comment