ManageIQ/manageiq

View on GitHub
bin/update

Summary

Maintainability
Test Coverage
#!/usr/bin/env ruby
require_relative '../lib/manageiq/environment'

if ARGV.any?
  puts <<~EOS
    Usage: bin/update

    Environment Variable Options:
        SKIP_DATABASE_SETUP  Skip the migration and seeding of the database.
        SKIP_UI_UPDATE       Skip the update of UI assets.
        SKIP_AUTOMATE_RESET  Skip the reset of the automate domain.
        SKIP_TEST_RESET      Skip the creation of the test enviroment.  Defaults to
                             true in production mode since the tasks do not exist.
  EOS
  exit 1
end

ENV["SKIP_TEST_RESET"] = "true" if ENV["RAILS_ENV"] == "production"

Dir.chdir(ManageIQ::Environment::APP_ROOT) do
  ManageIQ::Environment.ensure_config_files

  puts '== Installing dependencies =='
  ManageIQ::Environment.install_bundler
  ManageIQ::Environment.bundle_config
  ManageIQ::Environment.bundle_update(force: true)

  ui_thread = ManageIQ::Environment.update_ui_thread unless ENV["SKIP_UI_UPDATE"]

  unless ENV["SKIP_DATABASE_SETUP"]
    ManageIQ::Environment.migrate_database
    ManageIQ::Environment.seed_database
  end

  ManageIQ::Environment.setup_test_environment unless ENV["SKIP_TEST_RESET"]
  ManageIQ::Environment.reset_automate_domain  unless ENV["SKIP_AUTOMATE_RESET"]

  ui_thread&.join

  # Make sure update_ui is done before compiling assets
  ManageIQ::Environment.compile_assets if ENV['RAILS_ENV'] == 'production'

  ManageIQ::Environment.clear_logs_and_temp
end