.circleci/config.yml
version: 2
jobs:
build:
docker:
- image: cimg/ruby:3.3.5-node
environment:
RAILS_ENV: test
RACK_ENV: test
PGHOST: localhost
PGUSER: osuny
- image: cimg/postgres:14.10
environment:
POSTGRES_PASSWORD: ""
POSTGRES_USER: osuny
POSTGRES_DB: osuny_test
working_directory: ~/repo
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "Gemfile.lock" }}
# Install binaries for Active Storage Previews
- run:
name: Install binaries for Active Storage Previews
command: |
sudo apt-get update
sudo apt-get install ffmpeg poppler-utils -y
# Bundler configuration
- run:
name: Configure Bundler
command: |
echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV
source $BASH_ENV
gem install bundler
# Restore yarn cache
- restore_cache:
keys:
- app-yarn-{{ checksum "yarn.lock" }}
# Install gem dependencies
- run:
name: install dependencies
command: |
bundle install --jobs=4 --retry=3 --path vendor/bundle
# Install yarn dependencies
- run: bin/yarn install
# Store bundle cache
- save_cache:
paths:
- ./vendor/bundle
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
# Store yarn cache
- save_cache:
paths:
- ~/.yarn-cache
key: app-yarn-{{ checksum "yarn.lock" }}
# Database setup
- run: bundle exec rake db:create db:schema:load
# Code Climate setup
- run: curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- run: chmod +x ./cc-test-reporter
# run tests!
- run:
name: run tests
command: |
bundle exec rake test $(circleci tests glob "test/**/*_test.rb" | circleci tests split --split-by=timings)
# CodeClimate coverage
- run: ./cc-test-reporter format-coverage --output "coverage/codeclimate.$CIRCLE_NODE_INDEX.json"
- run:
name: report CodeClimate coverage
command: |
./cc-test-reporter sum-coverage --output - --parts $CIRCLE_NODE_TOTAL coverage/codeclimate.*.json | ./cc-test-reporter upload-coverage --input -