diff --git a/.engine_cart.yml b/.engine_cart.yml deleted file mode 100644 index 3dbcf41930..0000000000 --- a/.engine_cart.yml +++ /dev/null @@ -1,3 +0,0 @@ -rails_options: - - "--database=postgresql" - - "--skip-javascript" \ No newline at end of file diff --git a/CONTAINERS.md b/CONTAINERS.md index db9160971a..6b12368ae6 100644 --- a/CONTAINERS.md +++ b/CONTAINERS.md @@ -71,8 +71,6 @@ Let's break down the above command: _**Note:**_ The `bundle exec rspec` portion of the command runs the whole test suite. See the [rspec command documentation](https://github.com/rspec/rspec-core#the-rspec-command) for how to refine your test runs. -_**Note**: The `/app/samvera/hyrax-webapp` is analogous to the `.internal_test_app` that we generate as part of the Hyrax engine Continuous Integration._ - #### The Docker Container Named "app" As a developer, you may need to run commands against the Hyrax-based application and/or the Hyrax engine. Examples diff --git a/Gemfile b/Gemfile index 341ed79b46..b99fd8c745 100644 --- a/Gemfile +++ b/Gemfile @@ -14,25 +14,5 @@ group :development, :test do gem "simplecov", require: false end -test_app_path = ENV['RAILS_ROOT'] || - ENV.fetch('ENGINE_CART_DESTINATION', File.expand_path('.internal_test_app', File.dirname(__FILE__))) -test_app_gemfile = File.expand_path('Gemfile', test_app_path) - -# rubocop:disable Bundler/DuplicatedGem -if File.exist?(test_app_gemfile) - begin - Bundler.ui.info "[Hyrax] Including test application dependencies from #{test_app_gemfile}" - eval_gemfile test_app_gemfile - rescue Bundler::GemfileError => e - Bundler.ui.warn '[Hyrax] Skipping Rails application dependencies:' - Bundler.ui.warn e.message - end -elsif ENV['RAILS_VERSION'] == 'edge' - gem 'rails', github: 'rails/rails', source: 'https://rubygems.org' - ENV['ENGINE_CART_RAILS_OPTIONS'] = '--edge --skip-turbolinks' -elsif ENV['RAILS_VERSION'] - gem 'rails', ENV['RAILS_VERSION'], source: 'https://rubygems.org' -else - Bundler.ui.warn '[Hyrax] Skipping all Rails dependency injection' -end -# rubocop:enable Bundler/DuplicatedGem +# Install gems from test app +eval_gemfile File.expand_path('Gemfile', ".koppie") diff --git a/Rakefile b/Rakefile index f7ed7364cc..55decbd2db 100755 --- a/Rakefile +++ b/Rakefile @@ -9,17 +9,6 @@ end Bundler::GemHelper.install_tasks -task :setup_test_server do - require 'engine_cart' - EngineCart.load_application! -end - Dir.glob('tasks/*.rake').each { |r| import r } task default: :ci - -# Load the test app's rake tasks so they can be run from the app namespace (e.g. app:db:migrate) -if File.exist?(File.expand_path(".internal_test_app/Rakefile", __dir__)) - APP_RAKEFILE = File.expand_path(".internal_test_app/Rakefile", __dir__) - load 'rails/tasks/engine.rake' -end diff --git a/bin/rails b/bin/rails index 0abd2497c2..0362239677 100755 --- a/bin/rails +++ b/bin/rails @@ -6,7 +6,6 @@ ENGINE_ROOT = File.expand_path("..", __dir__) ENGINE_PATH = File.expand_path("../lib/hyrax/engine", __dir__) -# APP_PATH = File.expand_path("../.internal_test_app/config/application", __dir__) # Set up gems listed in the Gemfile. ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) diff --git a/hyrax.gemspec b/hyrax.gemspec index fb0d4a555d..4570011dc7 100644 --- a/hyrax.gemspec +++ b/hyrax.gemspec @@ -89,7 +89,6 @@ SUMMARY spec.add_development_dependency "capybara", '~> 3.29' spec.add_development_dependency 'capybara-screenshot', '~> 1.0' spec.add_development_dependency 'database_cleaner', '~> 1.3' - spec.add_development_dependency 'engine_cart', '~> 2.5' spec.add_development_dependency "equivalent-xml", '~> 0.5' spec.add_development_dependency "factory_bot", '~> 4.4' spec.add_development_dependency 'fcrepo_wrapper', '~> 0.5', '>= 0.5.1' @@ -108,6 +107,5 @@ SUMMARY spec.add_development_dependency 'bixby', '~> 5.0', '>= 5.0.2' # bixby 5 briefly dropped Ruby 2.5 spec.add_development_dependency 'shoulda-callback-matchers', '~> 1.1.1' spec.add_development_dependency 'shoulda-matchers', '~> 3.1' - spec.add_development_dependency 'webdrivers', '~> 4.4' spec.add_development_dependency 'webmock' end diff --git a/karma.conf.js b/karma.conf.js index cfcb735695..d6767f86ad 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -23,7 +23,7 @@ module.exports = function(config) { }, // list of files / patterns to load in the browser - // uses dotenv to allow for .internal_test_app or .dassie as the Rails root + // uses dotenv to allow for .dassie as the Rails root files: [ {pattern: 'spec/javascripts/fixtures/*.html', watched: true, included: false, served: true}, diff --git a/lib/generators/hyrax/templates/db/seeds.rb b/lib/generators/hyrax/templates/db/seeds.rb index a3846eb6d9..bdf1a26607 100644 --- a/lib/generators/hyrax/templates/db/seeds.rb +++ b/lib/generators/hyrax/templates/db/seeds.rb @@ -7,7 +7,7 @@ # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Character.create(name: 'Luke', movie: movies.first) # -# To use this file, run the following command in the .internal_test_app: +# To use this file, run the following command in the test app: # rails generate hyrax:sample_data # # To re-use this file, you will likely want to clean out the test app content diff --git a/lib/hyrax/specs/capybara.rb b/lib/hyrax/specs/capybara.rb index 49107fbc51..dc1f111d3c 100644 --- a/lib/hyrax/specs/capybara.rb +++ b/lib/hyrax/specs/capybara.rb @@ -15,57 +15,40 @@ def after_teardown require 'capybara/rails' require 'capybara-screenshot/rspec' require 'selenium-webdriver' -require 'webdrivers' unless ENV['IN_DOCKER'].present? || ENV['HUB_URL'].present? Capybara.save_path = ENV['CI'] ? "/tmp/test-results" : Rails.root.join('tmp', 'capybara') -if ENV['IN_DOCKER'].present? || ENV['HUB_URL'].present? - options = Selenium::WebDriver::Chrome::Options.new.tap do |opts| - opts.add_argument("--headless") if ENV["CHROME_HEADLESS_MODE"] - opts.add_argument("--disable-gpu") if Gem.win_platform? - # Workaround https://bugs.chromium.org/p/chromedriver/issues/detail?id=2650&q=load&sort=-id&colspec=ID%20Status%20Pri%20Owner%20Summary - opts.add_argument("--disable-site-isolation-trials") - opts.add_argument("--window-size=1440,1440") - opts.add_argument("--enable-features=NetworkService,NetworkServiceInProcess") - opts.add_argument("--disable-features=VizDisplayCompositor") - end - - Capybara.register_driver :selenium_chrome_headless_sandboxless do |app| - driver = Capybara::Selenium::Driver.new(app, - browser: :remote, - capabilities: options, - url: ENV['HUB_URL']) +options = Selenium::WebDriver::Chrome::Options.new.tap do |opts| + opts.add_argument("--headless") if ENV["CHROME_HEADLESS_MODE"] + opts.add_argument("--disable-gpu") if Gem.win_platform? + # Workaround https://bugs.chromium.org/p/chromedriver/issues/detail?id=2650&q=load&sort=-id&colspec=ID%20Status%20Pri%20Owner%20Summary + opts.add_argument("--disable-site-isolation-trials") + opts.add_argument("--window-size=1440,1440") + opts.add_argument("--enable-features=NetworkService,NetworkServiceInProcess") + opts.add_argument("--disable-features=VizDisplayCompositor") +end - # Fix for capybara vs remote files. Selenium handles this for us - driver.browser.file_detector = lambda do |args| - str = args.first.to_s - str if File.exist?(str) - end +Capybara.register_driver :selenium_chrome_headless_sandboxless do |app| + driver = Capybara::Selenium::Driver.new(app, + browser: :remote, + capabilities: options, + url: ENV['HUB_URL']) - driver + # Fix for capybara vs remote files. Selenium handles this for us + driver.browser.file_detector = lambda do |args| + str = args.first.to_s + str if File.exist?(str) end - Capybara.server_host = '0.0.0.0' - Capybara.server_port = 3010 - - ip = IPSocket.getaddress(Socket.gethostname) - Capybara.app_host = "http://#{ip}:#{Capybara.server_port}" -else - TEST_HOST = 'localhost:3000'.freeze - # @note In January 2018, TravisCI disabled Chrome sandboxing in its Linux - # container build environments to mitigate Meltdown/Spectre - # vulnerabilities, at which point Hyrax could no longer use the - # Capybara-provided :selenium_chrome_headless driver (which does not - # include the `--no-sandbox` argument). - Capybara.register_driver :selenium_chrome_headless_sandboxless do |app| - browser_options = ::Selenium::WebDriver::Chrome::Options.new - browser_options.args << '--headless' - browser_options.args << '--disable-gpu' - browser_options.args << '--no-sandbox' - Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options) - end + driver end +Capybara.server_host = '0.0.0.0' +Capybara.server_port = 3010 + +ip = IPSocket.getaddress(Socket.gethostname) +Capybara.app_host = "http://#{ip}:#{Capybara.server_port}" + Capybara.default_driver = :rack_test # This is a faster driver Capybara.javascript_driver = :selenium_chrome_headless_sandboxless # This is slower Capybara.default_max_wait_time = ENV.fetch('CAPYBARA_WAIT_TIME', 10) # We may have a slow application, let's give it some time. diff --git a/spec/controllers/hyrax/generic_works_controller_json_spec.rb b/spec/controllers/hyrax/generic_works_controller_json_spec.rb index 939375ede3..c32656e3da 100644 --- a/spec/controllers/hyrax/generic_works_controller_json_spec.rb +++ b/spec/controllers/hyrax/generic_works_controller_json_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true # This tests the Hyrax::WorksControllerBehavior module -# which is included into .internal_test_app/app/controllers/hyrax/generic_works_controller.rb RSpec.describe Hyrax::GenericWorksController, :active_fedora do routes { Rails.application.routes } diff --git a/spec/controllers/hyrax/generic_works_controller_spec.rb b/spec/controllers/hyrax/generic_works_controller_spec.rb index 25def825f7..ba1061754d 100644 --- a/spec/controllers/hyrax/generic_works_controller_spec.rb +++ b/spec/controllers/hyrax/generic_works_controller_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true # This tests the Hyrax::WorksControllerBehavior module -# which is included into .internal_test_app/app/controllers/hyrax/generic_works_controller.rb require 'hyrax/specs/spy_listener' RSpec.describe Hyrax::GenericWorksController, :active_fedora do diff --git a/spec/controllers/hyrax/monographs_controller_spec.rb b/spec/controllers/hyrax/monographs_controller_spec.rb index 94f0a813a7..a420ade041 100644 --- a/spec/controllers/hyrax/monographs_controller_spec.rb +++ b/spec/controllers/hyrax/monographs_controller_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true # This tests the Hyrax::WorksControllerBehavior module with a Valkyrie resource. -# Included into .internal_test_app/app/controllers/hyrax/monographs_controller.rb RSpec.describe Hyrax::MonographsController do routes { Rails.application.routes } let(:main_app) { Rails.application.routes.url_helpers } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 20f51efcee..c1ba4d78ac 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -16,7 +16,6 @@ def ci_build? SimpleCov.root(File.expand_path('../..', __FILE__)) SimpleCov.start('rails') do - add_filter '/.internal_test_app' add_filter '/lib/generators' add_filter '/spec' add_filter '/tasks' @@ -26,19 +25,12 @@ def ci_build? require 'factory_bot' -if ENV['IN_DOCKER'] - require File.expand_path("config/environment", '../hyrax-webapp') - db_config = ActiveRecord::Base.configurations[ENV['RAILS_ENV']] - ActiveRecord::Tasks::DatabaseTasks.create(db_config) - - ActiveRecord::Migrator.migrations_paths = [Pathname.new(ENV['RAILS_ROOT']).join('db', 'migrate').to_s] - ActiveRecord::Tasks::DatabaseTasks.migrate - ActiveRecord::Base.descendants.each(&:reset_column_information) -else - require 'engine_cart' - EngineCart.load_application! -end - +require File.expand_path("config/environment", '../hyrax-webapp') +db_config = ActiveRecord::Base.configurations[ENV['RAILS_ENV']] +ActiveRecord::Tasks::DatabaseTasks.create(db_config) +ActiveRecord::Migrator.migrations_paths = [Pathname.new(ENV['RAILS_ROOT']).join('db', 'migrate').to_s] +ActiveRecord::Tasks::DatabaseTasks.migrate +ActiveRecord::Base.descendants.each(&:reset_column_information) ActiveRecord::Migration.maintain_test_schema! require 'active_fedora/cleaner' diff --git a/spec/test_app_templates/Gemfile.extra b/spec/test_app_templates/Gemfile.extra deleted file mode 100644 index 8e55aaccb7..0000000000 --- a/spec/test_app_templates/Gemfile.extra +++ /dev/null @@ -1,8 +0,0 @@ -# Use this file to reference specific commits of gems. - -group :development do - gem 'better_errors' - gem 'binding_of_caller' -end - -gem 'sprockets', '~> 3.7' diff --git a/spec/test_app_templates/disable_animations_in_test_environment.rb b/spec/test_app_templates/disable_animations_in_test_environment.rb deleted file mode 100644 index d81a00e2c0..0000000000 --- a/spec/test_app_templates/disable_animations_in_test_environment.rb +++ /dev/null @@ -1 +0,0 @@ -require 'hyrax/specs/disable_animations_in_test_environment' diff --git a/spec/test_app_templates/lib/generators/test_app_generator.rb b/spec/test_app_templates/lib/generators/test_app_generator.rb deleted file mode 100644 index 706fbf33c9..0000000000 --- a/spec/test_app_templates/lib/generators/test_app_generator.rb +++ /dev/null @@ -1,235 +0,0 @@ -require 'rails/generators' - -class TestAppGenerator < Rails::Generators::Base - # Generator is executed from /path/to/hyrax/.internal_test_app/lib/generators/test_app_generator/ - # so the following path gets us to /path/to/hyrax/spec/test_app_templates/ - source_root File.expand_path('../../../../spec/test_app_templates/', __FILE__) - - def install_turbolinks - gem 'turbolinks', '~> 5' - - Bundler.with_clean_env do - run "bundle install" - end - end - - def install_engine - generate 'hyrax:install', '-f' - end - - def browse_everything_install - generate "browse_everything:install --skip-assets" - end - - def add_valkyrie_migrations - rake 'valkyrie_engine:install:migrations' - end - - def create_collection_resource - generate 'hyrax:collection_resource CollectionResource with_basic_metadata' - - gsub_file "config/metadata/collection_resource.yaml", "attributes: {}", - <<-YAML - ---- -attributes: - target_audience: - type: string - form: - primary: true - multiple: true - department: - type: string - form: - primary: true - course: - type: string - form: - primary: false -YAML - - # create the collection, but don't register it as 'the' collection - gsub_file "config/initializers/hyrax.rb", /[^#] config.collection_model/, " # config.collection_model" - end - - def create_generic_work - generate 'hyrax:work GenericWork' - end - - def create_nested_work - generate 'hyrax:work NamespacedWorks::NestedWork' - gsub_file 'app/models/namespaced_works/nested_work.rb', - 'include ::Hyrax::WorkBehavior', - <<-EOS.strip_heredoc - property :created, predicate: ::RDF::Vocab::DC.created, class_name: TimeSpan - include ::Hyrax::WorkBehavior - EOS - - gsub_file 'app/models/namespaced_works/nested_work.rb', - 'include ::Hyrax::BasicMetadata', - <<-EOS.strip_heredoc - include ::Hyrax::BasicMetadata - accepts_nested_attributes_for :created - EOS - end - - def create_time_span - create_file 'app/models/time_span.rb' do - <<-EOS.strip_heredoc - class TimeSpan < ActiveTriples::Resource - def initialize(uri = RDF::Node.new, _parent = ActiveTriples::Resource.new) - uri = if uri.try(:node?) - RDF::URI(\"#timespan_\#{uri.to_s.gsub('_:', '')}\") - elsif uri.to_s.include?('#') - RDF::URI(uri) - end - super - end - - def persisted? - !new_record? - end - - def new_record? - id.start_with?('#') - end - - configure type: ::RDF::Vocab::EDM.TimeSpan - property :start, predicate: ::RDF::Vocab::EDM.begin - property :finish, predicate: ::RDF::Vocab::EDM.end - end - EOS - end - end - - def create_work_resource - generate 'hyrax:work_resource Monograph monograph_title:string' - - append_file 'config/metadata/monograph.yaml' do - <<-YAML - record_info: - type: string - form: - required: true - primary: true - place_of_publication: - type: string - form: - required: false - primary: true - genre: - type: string - form: - primary: true - series_title: - type: string - form: - primary: false - target_audience: - type: string - form: - multiple: true - table_of_contents: - type: string - form: - multiple: false - date_of_issuance: - type: string -YAML - end - end - - def banner - say_status("info", "ADDING OVERRIDES FOR TEST ENVIRONMENT", :blue) - end - - def comment_out_web_console - gsub_file "Gemfile", - "gem 'web-console'", "# gem 'web-console'" - end - - def add_analytics_config - append_file 'config/analytics.yml' do - <<-EOS.strip_heredoc - analytics: - google: - analytics_id: UA-XXXXXXXX - app_name: My App Name - app_version: 0.0.1 - privkey_value: - privkey_path: /tmp/privkey.p12 - privkey_secret: s00pers3kr1t - client_email: oauth@example.org - matomo: - base_url: https://fake.example.com - site_id: 5 - auth_token: 3123c4e9c98860aa240ffadcb98 - EOS - end - end - - def enable_analytics - gsub_file "config/initializers/hyrax.rb", - "# config.analytics = false", "config.analytics = true" - end - - def enable_riiif_image_server - gsub_file "config/initializers/hyrax.rb", - "# config.iiif_image_server = false", "config.iiif_image_server = true" - end - - def enable_i18n_translation_errors - gsub_file "config/environments/development.rb", - "# config.action_view.raise_on_missing_translations = true", "config.action_view.raise_on_missing_translations = true" - gsub_file "config/environments/test.rb", - "# config.action_view.raise_on_missing_translations = true", "config.action_view.raise_on_missing_translations = true" - end - - def enable_arkivo_api - generate 'hyrax:arkivo_api' - end - - def relax_routing_constraint - gsub_file 'config/initializers/arkivo_constraint.rb', 'false', 'true' - end - - def disable_animations_for_more_reliable_feature_specs - prepend_file 'config/environments/test.rb' do - "require 'hyrax/specs/disable_animations_in_test_environment'\n" - end - inject_into_file 'config/environments/test.rb', after: "Rails.application.configure do\n" do - " config.middleware.use DisableAnimationsInTestEnvironment\n" - end - end - - def configure_action_cable_to_use_redis - gsub_file 'config/cable.yml', - "development:\n adapter: async", - "development:\n adapter: redis\n url: redis://localhost:6379" - end - - def install_universal_viewer - raise '`yarn install` failed!' unless system('yarn install') - end - - def create_sample_metadata_configuration - copy_file 'sample_metadata.yaml', 'config/metadata/sample_metadata.yaml' - end - - def add_valkyrie_test_adapter - append_file 'spec/spec_helper.rb' do - <<-CONFIG - -require 'valkyrie' -Valkyrie::MetadataAdapter - .register(Valkyrie::Persistence::Memory::MetadataAdapter.new, :test_adapter) -CONFIG - end - end - - def enable_cache_store - gsub_file 'config/environments/test.rb', 'config.action_controller.perform_caching = false', - 'config.action_controller.perform_caching = true' - gsub_file 'config/environments/test.rb', 'config.cache_store = :null_store', 'config.cache_store = :memory_store' - end -end diff --git a/spec/test_app_templates/sample_metadata.yaml b/spec/test_app_templates/sample_metadata.yaml deleted file mode 100644 index c556bdbc64..0000000000 --- a/spec/test_app_templates/sample_metadata.yaml +++ /dev/null @@ -1,3 +0,0 @@ -attributes: - sample_attribute: - type: string \ No newline at end of file diff --git a/tasks/hyrax_dev.rake b/tasks/hyrax_dev.rake index 851f9cfd70..72c38ac5c9 100644 --- a/tasks/hyrax_dev.rake +++ b/tasks/hyrax_dev.rake @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'English' require 'rspec/core/rake_task' -require 'engine_cart/rake_task' require 'rubocop/rake_task' desc 'Run style checker' @@ -34,28 +33,8 @@ task :i18n_sorter do end end -if Gem.loaded_specs.key? 'engine_cart' - namespace :engine_cart do - # This generate task should only add its action to an existing engine_cart:generate task - raise 'engine_cart:generate task should already be defined' unless Rake::Task.task_defined?('engine_cart:generate') - task :generate do |_task| - puts 'Running post-generation operations...' - Rake::Task['engine_cart:after_generate'].invoke - end - - desc 'Operations that need to run after the test_app migrations have run' - task :after_generate do - puts 'Creating default collection type...' - EngineCart.within_test_app do - raise "EngineCart failed on with: #{$CHILD_STATUS}" unless - system('bundle exec rake hyrax:default_collection_types:create') - end - end - end -end - -desc 'Generate the engine_cart and spin up test servers and run specs' -task ci: ['rubocop', 'engine_cart:generate'] do +desc 'Run rubocop and then run specs' +task ci: ['rubocop'] do puts 'running continuous integration' Rake::Task['spec_with_app_load'].invoke end