Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 6.0 #95

Merged
merged 5 commits into from
Dec 15, 2020
Merged

Rails 6.0 #95

merged 5 commits into from
Dec 15, 2020

Conversation

NickLaMuro
Copy link
Member

Based off the v0.2.z branch, since master is v0.3.z+

Links

@NickLaMuro NickLaMuro mentioned this pull request Nov 4, 2020
39 tasks
@NickLaMuro NickLaMuro changed the title Rails 6.0 [WIP] Rails 6.0 Nov 4, 2020
@miq-bot miq-bot added the wip label Nov 4, 2020
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency "activerecord", "~> 5.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, agreed. Since this is a gem we publish, and there is seemingly no other change, just supporting Rails 5 and 6 should be sufficient for our purposes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we can do this now, since there is a .update_attributes change I did. I probably can remove that change, but wanted to get everyone else's opinion before I do.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NickLaMuro it looks like the only changes from #update_attributes to #update were in specs, I'm good with ">=5.0", "< 6.1"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I think I saw lib/inventory_refresh/inventory_collection/helpers/initialize_helper.rb in the files changed diff, and didn't take a look at the contents, which only changes a comment and is fine.

Allow the 2.x release to support Rails 6.0 applications as well.
@NickLaMuro NickLaMuro changed the title [WIP] Rails 6.0 Rails 6.0 Dec 11, 2020
@miq-bot miq-bot removed the wip label Dec 11, 2020
@agrare
Copy link
Member

agrare commented Dec 14, 2020

cc @slemrmartin

@NickLaMuro once this is passing specs I'm good with this if Martin is good from the topo side. As for MIQ we'll need to backport it to the v2 branch

@NickLaMuro
Copy link
Member Author

@agrare I will look into the failures. That said...

As for MIQ we'll need to backport it to the v2 branch

This PR is already targeting the v0.2.z so it should actually be the reverse that needs to be done.

@agrare
Copy link
Member

agrare commented Dec 15, 2020

Gah sorry I missed that this was to the v2 branch I just assumed it was master my mistake

@NickLaMuro
Copy link
Member Author

No worries, I did the same when I originally opened up the fix months ago, so it wasn't a wrong assumption to make, just one that I already have addressed (since it was causing major failures in cross-repo if I hadn't already solved for this).

@slemrmartin
Copy link
Contributor

Hi @agrare yeah this PR won't affect us as it won't be merged to 0.3.z. We'll upgrade Rails probably in the Spring

spec/models/disk.rb Outdated Show resolved Hide resolved
Due to a performance fix introduced in Rails 6:

  rails/rails@cc2d614e

Columns named "present" end up with the following error:

  ActiveRecord::DangerousAttributeError:
    present? is defined by Active Record. Check to make sure that you
    don't have an attribute or method with the same name.

In manageiq, we kinda punted on fixing this column since it is hard to
know where it might be used elsewhere (Automate, etc.) so if a rename is
the final route we code with it is something that ideally happens in a
targeted effort outside the Rails 6 upgrade.  But here, since it is only
example models for specs, changing here isn't as dangerous so being
cavalier about the change isn't really an issue.
Seems like in `Rails.6`, `String#strip_heredoc` isn't available unless
`active_support/all` is explicitly required.  Requiring in the
`spec_helper.rb` is the most pragmatic solution and will apply it for
all specs.
When running the specs, the following type of error was presented:

    DEPRECATION WARNING: Static attributes will be removed in FactoryBot
    5.0. Please use dynamic attributes instead by wrapping the attribute
    value in a block:

    cpu_sockets { 1 }

    To automatically update from static attributes to dynamic ones,
    install rubocop-rspec and run:

    rubocop \
      --require rubocop-rspec \
      --only FactoryBot/AttributeDefinedStatically \
      --auto-correct

     (called from block (3 levels) in <top (required)> at ./inventory_refresh/spec/factories/hardware.rb:4)

The result of this commit is what was generated via:

  bundle exec rubocop --require rubocop-rspec                            \
                      --only RSpec/FactoryBot/AttributeDefinedStatically \
                      --auto-correct
Fixing the following deprecation warning:

  DEPRECATION WARNING: update_attributes is deprecated and will be
  removed from Rails 6.1 (please, use update instead)
@miq-bot
Copy link
Member

miq-bot commented Dec 15, 2020

Checked commits NickLaMuro/inventory_refresh@628dfe8~...5ce534d with ruby 2.6.3, rubocop 0.82.0, haml-lint 0.35.0, and yamllint
10 files checked, 1 offense detected

**

  • 💣 💥 🔥 🚒 - Linter/Rubocop - Linter::Rubocop STDERR:
404 "Not Found" while downloading remote config file https://raw.githubusercontent.com/ManageIQ/guides/master/.rubocop_base.yml
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/remote_config.rb:78:in `rescue in handle_response'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/remote_config.rb:73:in `handle_response'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/remote_config.rb:49:in `block in request'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/remote_config.rb:63:in `generate_request'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/remote_config.rb:47:in `request'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/remote_config.rb:21:in `file'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/config_loader.rb:40:in `load_file'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/config_loader_resolver.rb:143:in `block in base_configs'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/config_loader_resolver.rb:142:in `map'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/config_loader_resolver.rb:142:in `base_configs'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/config_loader_resolver.rb:22:in `resolve_inheritance'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/config_loader.rb:50:in `load_file'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/config_loader.rb:89:in `configuration_from_file'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/config_store.rb:44:in `for'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/target_finder.rb:107:in `excluded_dirs'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/target_finder.rb:85:in `find_files'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/target_finder.rb:60:in `target_files_in_dir'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/target_finder.rb:31:in `find'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/runner.rb:64:in `find_target_files'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/runner.rb:34:in `run'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/cli/command/execute_runner.rb:21:in `execute_runner'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/cli/command/execute_runner.rb:13:in `run'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/cli/command.rb:10:in `run'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/cli/environment.rb:17:in `run'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/cli.rb:65:in `run_command'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/cli.rb:72:in `execute_runners'
/usr/share/gems/gems/rubocop-0.82.0/lib/rubocop/cli.rb:41:in `run'
/usr/share/gems/gems/rubocop-0.82.0/exe/rubocop:13:in `block in <top (required)>'
/usr/share/ruby/benchmark.rb:308:in `realtime'
/usr/share/gems/gems/rubocop-0.82.0/exe/rubocop:12:in `<top (required)>'
/usr/bin/rubocop:23:in `load'
/usr/bin/rubocop:23:in `<main>'

@bdunne bdunne mentioned this pull request Dec 15, 2020
@agrare agrare self-assigned this Dec 15, 2020
@agrare agrare merged commit e88e6bc into ManageIQ:v0.2.z Dec 15, 2020
@agrare
Copy link
Member

agrare commented Dec 15, 2020

Released v0.2.3 with this change

@agrare
Copy link
Member

agrare commented Dec 15, 2020

I should mention I'm very excited about the ability to use this with rails 6 because of the introduction of #upsert which might be able to replace our raw SQL ON CONFLICT UPDATE logic for concurrent safe batch saving.

@NickLaMuro
Copy link
Member Author

@agrare Nice! The cross-repo PR for Rails 6.0 is now running with all of these newly released gems:

ManageIQ/manageiq-cross_repo-tests#179

I think those were the last hold out for merging them into master... 🤞

agrare added a commit to agrare/inventory_refresh that referenced this pull request Feb 3, 2022
Rails 6.0

(cherry picked from commit e88e6bc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants