Skip to content

Commit

Permalink
Add CircleCI configuration so we automatically run tests on a PR. (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
asedge authored Feb 7, 2023
1 parent b3cab9f commit e99c179
Showing 1 changed file with 109 additions and 0 deletions.
109 changes: 109 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
version: 2

references:
default_docker_ruby_executor: &default_docker_ruby_executor
image: cimg/ruby:2.7.7
environment:
BUNDLE_PATH: vendor/bundle
RAILS_ENV: test
COVERAGE: true
TZ: /usr/share/zoneinfo/America/Chicago

jobs:
build:
working_directory: ~/active_force/active_force_index
docker:
- *default_docker_ruby_executor
steps:
- checkout
- restore_cache:
keys:
- active_force-{{ checksum "active_force.gemspec" }}
- active_force-
- run:
name: Bundle Install
command: |
gem install bundler
bundle check || bundle install
- save_cache:
key: active_force-{{ checksum "active_force.gemspec" }}
paths:
- ~/active_force/active_force_index/node_modules
- ~/active_force/active_force_index/vendor/bundle

rspec-test:
working_directory: ~/active_force/active_force_index
parallelism: 1
docker:
- *default_docker_ruby_executor
steps:
- checkout
- restore_cache:
keys:
- active_force-{{ checksum "active_force.gemspec" }}
- active_force-
- run:
name: Bundle Install
command: |
gem install bundler
bundle check || bundle install
- save_cache:
key: active_force-{{ checksum "active_force.gemspec" }}
paths:
- ~/active_force/active_force_index/vendor/bundle
- 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:
name: Run RSpec
command: |
mkdir /tmp/test-results
./cc-test-reporter before-build
TESTFILES=$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
bundle exec rspec $TESTFILES --profile 10 --format RspecJunitFormatter --out /tmp/test-results/rspec.xml --format progress
- run:
name: Code Climate Test Coverage
command: |
./cc-test-reporter format-coverage -t simplecov -o "coverage/codeclimate.$CIRCLE_NODE_INDEX.json"
- persist_to_workspace:
root: coverage
paths:
- codeclimate.*.json
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
destination: test-results
- store_artifacts:
path: coverage
upload-coverage:
working_directory: ~/active_force/active_force_index
docker:
- *default_docker_ruby_executor
environment:
CC_TEST_REPORTER_ID: bd3425becf01f0b46ac11dd33e1e935d65d89f55051c087bfa035e0f89b290a2
steps:
- attach_workspace:
at: ~/active_force/active_force_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:
name: Combine and Upload Coverage
command: |
./cc-test-reporter sum-coverage --output - codeclimate.*.json | ./cc-test-reporter upload-coverage --debug --input -
workflows:
version: 2
build_and_test:
jobs:
- build
- rspec-test:
requires:
- build
- upload-coverage:
requires:
- rspec-test

0 comments on commit e99c179

Please sign in to comment.