diff --git a/.circleci/config.yml b/.circleci/config.yml index 961629a..a8fab36 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -92,11 +92,18 @@ jobs: curl -H "Content-type:application/octet-stream" --data-binary @solr_hyrax_config.zip "http://localhost:8985/solr/admin/configs?action=UPLOAD&name=hyrax" curl -H 'Content-type: application/json' http://localhost:8985/api/collections/ -d '{create: {name: hydra-test, config: hyrax, numShards: 1}}' + - run: + command: | + curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + chmod +x ./cc-test-reporter + ./cc-test-reporter before-build + - run: name: Run rspec command: | mkdir /tmp/test-results - bundle exec rake spec + COVERAGE=true bundle exec rake spec + ./cc-test-reporter after-build -t simplecov --exit-code $? - run: name: Clean dependencies diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 0000000..21ddc1f --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,32 @@ +--- +prepare: + fetch: + - url: "https://raw.githubusercontent.com/samvera-labs/bixby/master/bixby_default.yml" + path: "bixby_default.yml" + - url: "https://raw.githubusercontent.com/samvera-labs/bixby/master/bixby_rails_enabled.yml" + path: "bixby_rails_enabled.yml" + - url: "https://raw.githubusercontent.com/samvera-labs/bixby/master/bixby_rspec_enabled.yml" + path: "bixby_rspec_enabled.yml" +engines: + brakeman: + enabled: true + duplication: + enabled: false + rubocop: + enabled: true + channel: rubocop-0-50 + config: + file: .rubocop.cc.yml +ratings: + paths: + - Gemfile.lock + - "**.erb" + - "**.rb" + - "**.js" + - "**.es6" + - "**.coffee" + - "**.rake" + - "**.scss" +exclude_paths: +- config/ +- vendor/ diff --git a/.rubocop.cc.yml b/.rubocop.cc.yml new file mode 100644 index 0000000..f26b53d --- /dev/null +++ b/.rubocop.cc.yml @@ -0,0 +1,7 @@ +inherit_from: + - bixby_default.yml + - .rubocop.exceptions.yml + +AllCops: + TargetRubyVersion: 2.3 + DisplayCopNames: true diff --git a/.rubocop.exceptions.yml b/.rubocop.exceptions.yml new file mode 100644 index 0000000..eddfd2a --- /dev/null +++ b/.rubocop.exceptions.yml @@ -0,0 +1,23 @@ +Naming/FileName: + Exclude: + - 'Gemfile' + - 'hyrax-batch_ingest.gemspec' + +Bundler/DuplicatedGem: + Exclude: + - 'Gemfile' + +RSpec/ExampleLength: + Exclude: + - 'spec/lib/hyrax/batch_ingest/routing/batch_item_routes_spec.rb' + +Metrics/BlockLength: + Exclude: + - 'spec/**/*_spec.rb' + +RSpec/DescribeClass: + Exclude: + - 'spec/services/batch_runner_spec.rb' + +Style/RaiseArgs: + Enabled: false diff --git a/.rubocop.yml b/.rubocop.yml index 559a0c8..6cbd446 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,9 @@ inherit_gem: bixby: bixby_default.yml +inherit_from: + - .rubocop.exceptions.yml + AllCops: TargetRubyVersion: 2.3 DisplayCopNames: true diff --git a/hyrax-batch_ingest.gemspec b/hyrax-batch_ingest.gemspec index 17cd803..777e1d4 100644 --- a/hyrax-batch_ingest.gemspec +++ b/hyrax-batch_ingest.gemspec @@ -17,15 +17,20 @@ Gem::Specification.new do |s| s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"] - s.add_dependency "rails", "~> 5.1.6" - s.add_dependency "hyrax", "~> 2.2" + s.add_dependency 'rails', '~> 5.1.6' + s.add_dependency 'hyrax', '~> 2.2' s.add_development_dependency 'bixby' s.add_development_dependency 'capybara' + s.add_development_dependency 'codeclimate-test-reporter' s.add_development_dependency 'coffee-rails' - s.add_development_dependency "factory_bot_rails", "~> 4.11" + s.add_development_dependency 'factory_bot_rails', '~> 4.11' s.add_development_dependency 'fcrepo_wrapper' - s.add_development_dependency "sqlite3" - s.add_development_dependency "rspec-rails", "~> 3.8" + s.add_development_dependency 'rspec-rails', '~> 3.8' + s.add_development_dependency 'simplecov' s.add_development_dependency 'solr_wrapper' + s.add_development_dependency 'sqlite3' + + # Pinned dependencies + s.add_development_dependency 'sass', '=3.6.0' end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index cd7063c..87cc1e7 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,6 +1,17 @@ # frozen_string_literal: true # This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' + +if ENV['COVERAGE'] + require 'simplecov' + require 'codeclimate-test-reporter' + + SimpleCov.start('rails') do + add_filter '/spec' + end + SimpleCov.command_name 'spec' +end + ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../.internal_test_app/config/environment', __FILE__) # Prevent database truncation if the environment is production