Skip to content

Commit

Permalink
Update GitHub Workflows (#265)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bkiahstroud authored Dec 19, 2020
1 parent 1f51be1 commit 5ea5e93
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 32 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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
17 changes: 9 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ AllCops:
- 'node_modules/**/*'
# Additions by Notch8
- 'spec/test_app/**/*'
- 'bin/*'

inherit_from: .rubocop_todo.yml

Expand Down
26 changes: 13 additions & 13 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# 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
# versions of RuboCop, may require this file to be generated again.

# 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
Expand All @@ -35,7 +35,7 @@ Metrics/MethodLength:
Metrics/ModuleLength:
Max: 131

# Offense count: 9
# Offense count: 8
Metrics/PerceivedComplexity:
Max: 17

Expand All @@ -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:
Expand All @@ -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'
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion app/models/bulkrax/exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/bulkrax/export_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions bin/rspec
Original file line number Diff line number Diff line change
@@ -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")
6 changes: 5 additions & 1 deletion spec/test_app/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 5ea5e93

Please sign in to comment.