diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..c5898d5 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,47 @@ +version: 2 + +jobs: + build: + parallelism: 3 + docker: + - image: circleci/ruby:2.4.2-jessie-node + environment: + BUNDLE_JOBS: 3 + BUNDLE_RETRY: 3 + BUNDLE_PATH: vendor/bundle + RAILS_ENV: test + steps: + - checkout + + # Which version of bundler? + - run: + name: Which bundler? + command: bundle -v + + # Restore bundle cache + - restore_cache: + keys: + - kirico-bundle-v2-{{ checksum "Gemfile.lock" }} + - kirico-bundle-v2- + + - run: + name: Bundle Install + command: bundle check || bundle install + + # Store bundle cache + - save_cache: + key: kirico-bundle-v2-{{ checksum "Gemfile.lock" }} + paths: + - vendor/bundle + + - run: + name: Run Rubocop + command: ./script/circleci/run_rubocop.sh + + - run: + name: Run rspec in parallel + command: ./script/circleci/run_rspec.sh + + # Save test results for timing analysis + - store_test_results: + path: test_results diff --git a/circle.yml b/circle.yml deleted file mode 100644 index a585923..0000000 --- a/circle.yml +++ /dev/null @@ -1,7 +0,0 @@ -machine: - timezone: - Asia/Tokyo - -test: - pre: - - bundle exec rubocop --display-cop-names diff --git a/script/circleci/run_rspec.sh b/script/circleci/run_rspec.sh new file mode 100755 index 0000000..5f5099f --- /dev/null +++ b/script/circleci/run_rspec.sh @@ -0,0 +1,7 @@ +#!/bin/bash -e +test_reports_dir=$CIRCLE_TEST_REPORTS/rspec +mkdir -p $test_reports_dir + +circleci tests glob "spec/**/*_spec.rb" | \ +circleci tests split --split-by=timings --timings-type=filename | \ +xargs bundle exec rspec --color --format RspecJunitFormatter --out $test_reports_dir/hanica.xml --format progress --require spec_helper --tag ~type:profiling --profile -- diff --git a/script/circleci/run_rubocop.sh b/script/circleci/run_rubocop.sh new file mode 100755 index 0000000..d68f515 --- /dev/null +++ b/script/circleci/run_rubocop.sh @@ -0,0 +1,8 @@ +#!/bin/bash -e +test_reports_dir=$CIRCLE_TEST_REPORTS/rubocop +mkdir -p $test_reports_dir +junit_formatter_ruby=$(bundle show rubocop-junit-formatter 2>/dev/null)/lib/rubocop/formatter/junit_formatter.rb + +bundle exec rubocop -L | \ +circleci tests split --split-by=timings --timings-type=filename | \ +xargs bundle exec rubocop -D -R -r $junit_formatter_ruby -c .rubocop.yml --format RuboCop::Formatter::JUnitFormatter --out $test_reports_dir/rubocop.xml