From 5ea5e931a4d56fc97ff82d620a9e8cea52d76e30 Mon Sep 17 00:00:00 2001 From: Benjamin Kiah Stroud <32469930+bkiahstroud@users.noreply.github.com> Date: Fri, 18 Dec 2020 16:51:44 -0800 Subject: [PATCH] Update GitHub Workflows (#265) * update versions * fix rubocop warnings, update rubocop todo * update test CI workflow and test_app db/schema * try rspec instead of rake * use rspec binstub to run in CI --- .github/workflows/lint.yml | 15 +++++----- .github/workflows/test.yml | 17 ++++++----- .rubocop.yml | 1 + .rubocop_todo.yml | 26 ++++++++--------- app/models/bulkrax/exporter.rb | 2 +- .../concerns/bulkrax/export_behavior.rb | 4 +-- bin/rspec | 29 +++++++++++++++++++ spec/test_app/db/schema.rb | 6 +++- 8 files changed, 68 insertions(+), 32 deletions(-) create mode 100755 bin/rspec diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 912dce43..68faadb3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,20 +14,21 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: actions/cache@preview - id: cache + - name: Cache + uses: actions/cache@v2.1.3 with: - path: ~/local/rubies + path: vendor/bundle key: 2.6.5 - - uses: clupprich/ruby-build-action@master - id: ruby + - name: Setup Ruby + uses: ruby/setup-ruby@v1.59.1 with: ruby-version: 2.6.5 - cache-available: ${{ steps.cache.outputs.cache-hit == 'true' }} - name: Install dependencies - run: bundle install --without default development test + run: | + bundle config path vendor/bundle + bundle install --without default development test - name: Run Rubocop run: bin/rubocop -P diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 378af3de..3b79b48e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,26 +14,27 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: actions/cache@preview - id: cache + - name: Cache + uses: actions/cache@v2.1.3 with: - path: ~/local/rubies + path: vendor/bundle key: 2.6.5 - - uses: clupprich/ruby-build-action@master - id: ruby + - name: Setup Ruby + uses: ruby/setup-ruby@v1.59.1 with: ruby-version: 2.6.5 - cache-available: ${{ steps.cache.outputs.cache-hit == 'true' }} - name: Setup sqlite3 run: sudo apt-get install libsqlite3-dev - name: Install dependencies - run: bundle install + run: | + bundle config path vendor/bundle + bundle install - name: Migrate test database run: bin/rails db:migrate RAILS_ENV=test - name: Run rspec - run: rake + run: bin/rspec diff --git a/.rubocop.yml b/.rubocop.yml index 92034161..4366f67a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,6 +12,7 @@ AllCops: - 'node_modules/**/*' # Additions by Notch8 - 'spec/test_app/**/*' + - 'bin/*' inherit_from: .rubocop_todo.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index cfd82a12..a2844fad 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2020-04-03 16:00:02 -0700 using RuboCop version 0.63.1. +# on 2020-12-18 11:52:24 -0800 using RuboCop version 0.63.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -8,24 +8,24 @@ # Offense count: 16 Metrics/AbcSize: - Max: 47 + Max: 43 -# Offense count: 5 +# Offense count: 6 # Configuration parameters: CountComments. Metrics/ClassLength: - Max: 237 + Max: 231 -# Offense count: 10 +# Offense count: 7 Metrics/CyclomaticComplexity: Max: 13 -# Offense count: 3 +# Offense count: 5 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: Max: 301 -# Offense count: 14 +# Offense count: 17 # Configuration parameters: CountComments, ExcludedMethods. Metrics/MethodLength: Max: 28 @@ -35,7 +35,7 @@ Metrics/MethodLength: Metrics/ModuleLength: Max: 131 -# Offense count: 9 +# Offense count: 8 Metrics/PerceivedComplexity: Max: 17 @@ -45,14 +45,14 @@ Performance/RegexpMatch: Exclude: - 'bin/rubocop' -# Offense count: 6 +# Offense count: 8 RSpec/AnyInstance: Exclude: - 'spec/models/bulkrax/csv_entry_spec.rb' - 'spec/models/bulkrax/importer_spec.rb' - 'spec/models/bulkrax/rdf_entry_spec.rb' -# Offense count: 12 +# Offense count: 9 # Configuration parameters: Max. RSpec/ExampleLength: Exclude: @@ -63,7 +63,7 @@ RSpec/ExampleLength: - 'spec/models/bulkrax/xml_entry_spec.rb' - 'spec/parsers/bulkrax/csv_parser_spec.rb' -# Offense count: 17 +# Offense count: 20 RSpec/MessageChain: Exclude: - 'spec/jobs/bulkrax/child_relationships_job_spec.rb' @@ -72,13 +72,13 @@ RSpec/MessageChain: - 'spec/parsers/bulkrax/csv_parser_spec.rb' - 'spec/parsers/bulkrax/xml_parser_spec.rb' -# Offense count: 66 +# Offense count: 63 # Configuration parameters: . # SupportedStyles: have_received, receive RSpec/MessageSpies: EnforcedStyle: receive -# Offense count: 58 +# Offense count: 59 # Configuration parameters: IgnoreSharedExamples. RSpec/NamedSubject: Exclude: diff --git a/app/models/bulkrax/exporter.rb b/app/models/bulkrax/exporter.rb index 1c42c2de..67e61249 100644 --- a/app/models/bulkrax/exporter.rb +++ b/app/models/bulkrax/exporter.rb @@ -60,7 +60,7 @@ def work_visibility_list end def workflow_status_list - Sipity::WorkflowState.all.map {|s| [s.name&.titleize, s.name] }.uniq + Sipity::WorkflowState.all.map { |s| [s.name&.titleize, s.name] }.uniq end # If field_mapping is empty, setup a default based on the export_properties diff --git a/app/models/concerns/bulkrax/export_behavior.rb b/app/models/concerns/bulkrax/export_behavior.rb index 082625ea..d0e41b6f 100644 --- a/app/models/concerns/bulkrax/export_behavior.rb +++ b/app/models/concerns/bulkrax/export_behavior.rb @@ -48,10 +48,10 @@ def filename(file_set) ext_mime = MIME::Types.of(file_set.original_file.file_name).first if fn.include?(file_set.id) return fn if mime.to_s == ext_mime.to_s - return "#{fn}.#{mime.to_sym.to_s}" + return "#{fn}.#{mime.to_sym}" else return "#{file_set.id}_#{fn}" if mime.to_s == ext_mime.to_s - return "#{file_set.id}_#{fn}.#{mime.to_sym.to_s}" + return "#{file_set.id}_#{fn}.#{mime.to_sym}" end end end diff --git a/bin/rspec b/bin/rspec new file mode 100755 index 00000000..a6c78521 --- /dev/null +++ b/bin/rspec @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rspec' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rspec-core", "rspec") diff --git a/spec/test_app/db/schema.rb b/spec/test_app/db/schema.rb index 585919fe..375ec328 100644 --- a/spec/test_app/db/schema.rb +++ b/spec/test_app/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20200819054016) do +ActiveRecord::Schema.define(version: 20201117220007) do create_table "bookmarks", force: :cascade do |t| t.integer "user_id", null: false @@ -65,6 +65,10 @@ t.text "last_error" t.datetime "last_error_at" t.datetime "last_succeeded_at" + t.date "start_date" + t.date "finish_date" + t.string "work_visibility" + t.string "workflow_status" t.index ["user_id"], name: "index_bulkrax_exporters_on_user_id" end