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 5 update #1341

Closed
wants to merge 11 commits into from
Closed

Rails 5 update #1341

wants to merge 11 commits into from

Conversation

sonalkr132
Copy link
Member

Please read commit message for explanation of changes.

It is very likely that I may have missed deprecations which didn't show up in test, feel free to open issues when you see them.

I have removed quite_assets gem because their rails requirement wouldn't have allowed update and looks like gem is abandoned. The feature is now implemented in sprocket-rails, we just have to be wait for version release.

I really want to compare before and after performance, object allocation etc. I would really appreciate it if someone pointed me to relevant resources or took out time for general advice.

@dwradcliffe
Copy link
Member

I haven't looked at the commits yet, but if there are any of these things that are compatible with both Rails 5 and the current version we should get those into separate PRs and merge them sooner. Smaller changes are always better to test.

cc: @arthurnn @rafaelfranca

@sonalkr132
Copy link
Member Author

sonalkr132 commented Jun 26, 2016

if there are any of these things that are compatible with both Rails 5 and the current version we should get those into separate PRs and merge them sooner.

I am not sure if that would be a good idea. You won't be able to see anything in the logs other than deprecation warnings.

This PR is not as bad as it looks. Just gemfiles change amount for 128 lines, id: .. => params: { id: .. } cloc at 138 lines and adding version to migration is 88 line (82% total change).

@homu
Copy link
Contributor

homu commented Jun 26, 2016

☔ The latest upstream changes (presumably #1327) made this pull request unmergeable. Please resolve the merge conflicts.

@kmcphillips
Copy link
Contributor

To remove quiet_assets you need to add config.assets.quiet = true to environments/development.rb for the equivalent behaviour.

As soon as there is a sprockets-rails release we can make that change separate to this pr. cc @rafaelfranca

@sonalkr132
Copy link
Member Author

Thank you for checking out the PR @kmcphillips :octocat:

you need to add config.assets.quiet = true to environments/development.rb for the equivalent behaviour.

I didn't add it because I didn't want to add a configuration which did nothing at the point(commit) it was added. quite_assets isn't anything critical as in we can live without it for a day or two. I hope it makes sense 😅

@kmcphillips
Copy link
Contributor

#1352 simplifies this a bit. sprockets-rails 3.1.0 was released today.

@sonalkr132
Copy link
Member Author

sonalkr132 commented Jun 28, 2016

I have great news.. 😞

It has treading issue and as they go.. it is not reliably reproduceable. Failing build1, build2, build3.
Almost all of them are on increment function of GemDownload. How do I even report this?

@homu
Copy link
Contributor

homu commented Jul 1, 2016

☔ The latest upstream changes (presumably f32321d) made this pull request unmergeable. Please resolve the merge conflicts.

@sonalkr132 sonalkr132 force-pushed the rails-5-update branch 4 times, most recently from 17cb351 to 2d7257e Compare July 5, 2016 10:26
@sonalkr132
Copy link
Member Author

I have updated this to 5.0.0. Treading error was fixed here: rails/rails#25707
I guess we will have to wait for 5.0.1.

@@ -28,6 +25,9 @@ class Application < Rails::Application
config.plugins = [:dynamic_form]

config.autoload_paths << Rails.root.join('lib')

# Do not halt callback chains when a callback returns false.
ActiveSupport.halt_callback_chains_on_return_false = false
end

Choose a reason for hiding this comment

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

@sonalkr132 Did you run rails app:update, this config will go to config/initializers/new_framework_defaults.rb after that.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was hoping I would change config after we are sure that changes up to this point don't break anything.
However, now it seems like it is going to be a while before this gets deployed.. I have added the changes of rails app:update. Thanks for having a look at the PR :)

@sonalkr132 sonalkr132 force-pushed the rails-5-update branch 4 times, most recently from 384b0fa to 8133cc1 Compare July 6, 2016 13:39
@homu
Copy link
Contributor

homu commented Jul 8, 2016

☔ The latest upstream changes (presumably e0006da) made this pull request unmergeable. Please resolve the merge conflicts.

group :development do
gem 'rails-erd'
end
gem 'rails-erd', group: :development
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Sure, but why changed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh! It has to do with rebase 😝 I had removed quite_assets changed group to one line but quite_assets was removed in different PR and I had to rebase.

I guess it saves two lines, but yes, the change is unnecessary. May be I can restore it when I update the PR for 5.0.1 if you think it is important.

Copy link
Member

Choose a reason for hiding this comment

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

Since this PR is changing 169 files I think it will be nice to keep it as minimal as it is possible for future reviewers.

@simi
Copy link
Member

simi commented Jul 12, 2016

I'm not sure if ApplicationRecord is needed and it will save a lot of line changes since it is not used (it is just blank abstract class). Is it really worth it now?

@user = User.find_by_slug!(params[:id])
rubygems = @user.rubygems_downloaded
@rubygems = rubygems.slice!(0, 10)
@extra_rubygems = rubygems
Copy link
Member

Choose a reason for hiding this comment

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

Is this removal of @extragems_rubygems and rubygems var assignments and following view change related to Rails 5 update or is it just a code cleanup/refactoring?

@simi
Copy link
Member

simi commented Jul 12, 2016

I left some notes @sonalkr132 to your awesome work!.
Anyway I'm just random passerby so it will be good to wait for someone from RubyGems.org team to reply if those comments make sense.

…emplate

HTTP request methods will accept only the following keyword arguments
in future Rails versions: params, headers, env, xhr, as

Rails discourages use of assert_template and the feature is moved out
to gem. Possibly we will be adding tests which test for elements in view.
`assigns` is moved out to a gem in rails 5 and its use is discouraged.
Use of plain fixes:
DEPRECATION WARNING: `render :text` is deprecated because it does not
actually render a `text/plain` response. Switch to `render plain: 'plain
text'` to render as `text/plain`, `render html: '<strong>HTML</strong>'`
to render as `text/html`, or `render body: 'raw'` to match the deprecated
behavior and render with the default Content-Type, which is `text/plain`.

Use of request.env fixes:
DEPRECATION WARNING: env is deprecated and will be removed from Rails 5.1
Use of request.env mentioned at: rails/rails@05934d2
Reusing params in ES suggestion view was showing error for unsafe use of
params.
`count` takes `conditions` as argument , but we don't need even that.
Sytax of content_type changed.
Rails now uses async queue_adapter which uses a different thread to
work off jobs. We can't let that happen in our integration test because
we are relying on the mail being delievered and doing that in
a different thread leads to unpredictable delay.
Use of symbol or string as middleware name is deprecated. I moved it
to env files because Redirect was env specific.
Now errors in transactional callbacks are raised by default.
serve_static_file and static_cache_control has been deprecated in
favour of public_file_server.
Tests now run after_commit callbacks by default.
New rails test runner is cool 😎
@sonalkr132 sonalkr132 force-pushed the rails-5-update branch 2 times, most recently from 6819da7 to e696b48 Compare August 12, 2016 03:50
We are not adding puma and actioncable config here.
@indirect
Copy link
Member

@sonalkr132 can you re base this and update to 5.0.1 to fix the connection pool issue?

@sonalkr132
Copy link
Member Author

Rails 5.0.1 is not released yet. rails 5.0.1 Milestone
Rails 5.0.0.1 was released and it was just a security update.

@indirect
Copy link
Member

@sonalkr132 ah, I see. 😞 I guess this is blocked until Rails 5.0.1 comes out, then.

@homu
Copy link
Contributor

homu commented Sep 4, 2016

☔ The latest upstream changes (presumably #1398) made this pull request unmergeable. Please resolve the merge conflicts.

@arthurnn
Copy link
Member

I agree 100% with @dwradcliffe . We cannot ship one big update PR to upgrade Rails version. it is too risky.
We need to slowly introduce the changes in master, and make sure they run on both versions. Once we have master able to run on rails 4.2 and 5, and we test it out the move to 5

@@ -47,7 +47,7 @@ def response_body
context "on GET to show when hide email" do
setup do
@user.update(hide_email: true)
get :show, id: @user.handle, format: format
get :show, params: { id: @user.handle }, format: format

Choose a reason for hiding this comment

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

Changes like this should be done in a follow-up PR, in my opinion. This adds unnecessary review overhead to the Pull Request.

@connorshea
Copy link

This would be a lot smaller if we didn't bother fixing deprecation warnings in this PR. We should focus on doing that afterward.

Copy link

@connorshea connorshea left a comment

Choose a reason for hiding this comment

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

Some comments on what we should remove from this PR to keep it lean, what we can backport, etc.

@@ -16,7 +16,7 @@ gem 'daemons'
gem 'dalli'
gem 'delayed_job'
gem 'delayed_job_active_record'
gem 'doorkeeper'
gem 'doorkeeper', '~> 4.0.0.rc4'

Choose a reason for hiding this comment

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

This can be backported (and can use the stable 4.0.0 version)

Copy link
Member

Choose a reason for hiding this comment

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

This is actually gone in master now.

nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
parser (2.3.1.2)
ast (~> 2.2)
paul_revere (2.0.0)
rails (~> 4.0)
paul_revere (2.1.0.rc1)

Choose a reason for hiding this comment

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

paul_revere seems to be abandoned from what I can tell, can we replace it with something else?

@@ -7,9 +7,9 @@ def show
sign_in User.authenticate(username, password)
if current_user
respond_to do |format|
format.any(:all) { render text: current_user.api_key }
format.any(:all) { render plain: current_user.api_key }

Choose a reason for hiding this comment

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

Replacing render text with render plain seems like an unnecessary deprecation warning fix? Should be a follow-up PR.

# Be sure to restart your server when you modify this file.

# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]

Choose a reason for hiding this comment

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

Does this override an existing filter_parameters config?

@@ -1,7 +1,6 @@
class Api::BaseController < ApplicationController
before_action :doorkeeper_authorize!, if: :doorkeeper_token
before_action :authenticate_with_oauth, if: :doorkeeper_token
skip_before_action :require_ssl

Choose a reason for hiding this comment

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

What's the explanation for this change?

@@ -142,7 +144,7 @@ GEM
activesupport (>= 4.1.0)
gravtastic (3.2.6)
hashie (3.4.4)
high_voltage (2.4.0)
high_voltage (3.0.0)

Choose a reason for hiding this comment

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

This seems to be something we can backport.

@sonalkr132
Copy link
Member Author

Thanks for review @connorshea I will keep your comments in mind when I make changes.

We cannot ship one big update PR to upgrade Rails version. it is too risky.

If it's okay I would like to open a new PR with ☝️. It doesn't it has to wait for rails 5.0.1 for people to review it.

We need to slowly introduce the changes in master, and make sure they run on both versions.

I haven't read (blog/implementation) anything related to this. Can someone please explain it with a little more detail? Would it be something like this, where we check for rails versions?

@connorshea
Copy link

See also what I'm doing for GitLab: https://gitlab.com/gitlab-org/gitlab-ce/issues/14286

Lots of things can be backported to master to make this PR a lot smaller.

@sonalkr132
Copy link
Member Author

@connorshea thanks :) That was helpful. I will send a new PR soon.

@sonalkr132
Copy link
Member Author

See #1615

@sonalkr132 sonalkr132 closed this May 1, 2017
@sonalkr132 sonalkr132 deleted the rails-5-update branch June 1, 2019 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants