.circleci/config.yml
version: 2.1
orbs:
browser-tools: circleci/browser-tools@1.4.6
jobs:
build:
parallelism: 3
docker:
- image: cimg/ruby:3.1.3-node
environment:
BUNDLE_PATH: vendor/bundle
COVERAGE: true
PGHOST: 127.0.0.1
PGUSER: mr-member-portal-test-user
RAILS_ENV: test
- image: cimg/postgres:11.17
environment:
POSTGRES_USER: mr-member-portal-test-user
POSTGRES_DB: mr_member_portal_test
steps:
- checkout
- browser-tools/install-chrome
- browser-tools/install-chromedriver
- run:
name: Install system dependencies
command: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends imagemagick libmagickwand-dev
wget http://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
- restore_cache:
keys:
- rails-demo-bundle-v2-20221217-{{ checksum "Gemfile.lock" }}
- rails-demo-bundle-v2-20221217-
- run:
name: Bundle Install
command: |
bundle config without local
bundle config deployment true
bundle config path vendor/bundle
bundle check || bundle install
- save_cache:
key: rails-demo-bundle-v2-20221217-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- run:
name: Wait for DB
command: dockerize -wait tcp://localhost:5432 -timeout 1m
- run:
name: Setup Code Climate test-reporter
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- run:
name: Database setup
command: bin/rails db:test:prepare
- run:
name: Run rspec in parallel
command: |
./cc-test-reporter before-build
bin/rspec \
--profile 10 \
--color \
--format RspecJunitFormatter \
--out test-results/rspec.xml \
--format documentation \
-- $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
- store_test_results:
path: test-results
- store_artifacts:
path: tmp/capybara
- run:
name: Format CodeClimate Test Coverge
command: |
./cc-test-reporter format-coverage -t simplecov -o "coverage/codeclimate.$CIRCLE_NODE_INDEX.json"
- persist_to_workspace:
root: coverage
paths:
- codeclimate.*.json
upload-coverage:
docker:
- image: cimg/ruby:3.1.3-node
environment:
CC_TEST_REPORTER_ID: c3ff91e23ea0fea718bb62dae0a8a5440dc082d5d2bb508af6b33d0babac479a
working_directory: ~/bikeindex/bike_index
steps:
- attach_workspace:
at: ~/bikeindex/bike_index
- run:
name: Install Code Climate Test Reporter
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- run:
command: |
./cc-test-reporter sum-coverage --output - codeclimate.*.json | ./cc-test-reporter upload-coverage --debug --input -
workflows:
version: 2
commit:
jobs:
- build
- upload-coverage:
requires:
- build