Created
May 21, 2019 07:23
-
-
Save powerwlsl/ecb5f3e7a6028fbc30b623238b975fe2 to your computer and use it in GitHub Desktop.
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
# Ruby CircleCI 2.0 configuration file | |
# | |
# Check https://circleci.com/docs/2.0/language-ruby/ for more details | |
# | |
# List of available images: https://hub.docker.com/u/circleci/ | |
# | |
version: 2 | |
jobs: | |
build-job: | |
docker: | |
# specify the version you desire here | |
- image: kris72164378/ruby:2.6.0-node-browsers-legacy-ffmpeg | |
environment: | |
PGHOST: 127.0.0.1 | |
PGUSER: postgres | |
RAILS_ENV: test | |
QURATE_TWITTER_APP_KEY: app-key | |
QURATE_TWITTER_APP_SECRET: app-secret | |
QURATE_FACEBOOK_APP_KEY: app-key | |
QURATE_FACEBOOK_APP_SECRET: app-secret | |
# Specify service dependencies here if necessary | |
# CircleCI maintains a library of pre-built images | |
# documented at https://circleci.com/docs/2.0/circleci-images/ | |
- image: postgres:9.6 | |
environment: | |
POSTGRES_PASSWORD: "mysecretpassword" | |
- image: circleci/redis:4.0.10 | |
working_directory: ~/repo | |
steps: | |
- checkout | |
# Download and cache dependencies | |
- restore_cache: | |
keys: | |
- v1-dependencies-{{ checksum "Gemfile.lock" }} | |
# fallback to using the latest cache if no exact match is found | |
- v1-dependencies- | |
- run: | |
name: install dependencies | |
command: | | |
bundle install --jobs=4 --retry=3 --path vendor/bundle | |
- save_cache: | |
paths: | |
- ./vendor/bundle | |
key: v1-dependencies-{{ checksum "Gemfile.lock" }} | |
# Only necessary if app uses webpacker or yarn in some other way | |
- type: cache-restore | |
name: Restore yarn cache | |
key: my-app-{{ checksum "yarn.lock" }} | |
- run: | |
name: Yarn Install | |
command: yarn install | |
# Store yarn / webpacker cache | |
- type: cache-save | |
name: Store yarn cache | |
key: my-app-{{ checksum "yarn.lock" }} | |
paths: | |
- ~/.yarn-cache | |
- run: | |
name: redis-cli Install | |
command: sudo apt-get install -y redis-tools | |
# Database setup | |
- run: | |
name: Set up database | |
environment: | |
- RAILS_ENV: test | |
command: | | |
echo 'test: | |
adapter: postgresql | |
encoding: unicode | |
database: qurate_platform_test | |
password: mysecretpassword | |
username: postgres | |
pool: 5 | |
host: 127.0.0.2 | |
' > config/database.yml | |
bundle exec rake db:create db:migrate | |
# run tests! | |
- run: mkdir ~/reports | |
- run: | |
name: Run tests | |
environment: | |
- RAILS_ENV: test | |
- RACK_ENV: test | |
command: bundle exec rake test TESTOPTS="--ci-dir=./reports" | |
when: always | |
# collect reports | |
- store_test_results: | |
path: ~/reports | |
deploy-job: | |
docker: | |
- image: kris72164378/ruby:2.6.0-node-browsers-legacy-ffmpeg | |
working_directory: ~/repo | |
steps: | |
- checkout | |
- run: | |
name: Deploy if tests pass and branch is master | |
command: ~/repo/bin/deploy-staging.sh | |
workflows: | |
version: 2 | |
build-deploy: | |
jobs: | |
- build-job | |
- deploy-job: | |
requires: | |
- build-job | |
filters: | |
branches: | |
only: master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment