Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CircleCI configuration so we automatically run tests on a PR. #4

Merged
merged 1 commit into from
Feb 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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