-
Notifications
You must be signed in to change notification settings - Fork 22k
Use rails_command :inline option #38429
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
Use rails_command :inline option #38429
Conversation
Follow-up to rails#37516.
@@ -316,7 +316,7 @@ def update_bin_files | |||
|
|||
def update_active_storage | |||
unless skip_active_storage? | |||
rails_command "active_storage:update" | |||
rails_command "active_storage:update", inline: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line had a noticeable effect on test run time (when run locally).
rails_command "webpacker:install", inline: true | ||
if options[:webpack] && options[:webpack] != "webpack" | ||
rails_command "webpacker:install:#{options[:webpack]}", inline: true | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines were hit by the tests I ran (I added logging to verify), but made no difference in test run time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...Because these specifc calls to rails_command
are stubbed when tested:
rails/railties/test/generators/app_generator_test.rb
Lines 903 to 924 in 7745146
def test_webpack_option_with_js_framework | |
command_check = -> command, *_ do | |
case command | |
when "webpacker:install" | |
@webpacker ||= 0 | |
@webpacker += 1 | |
assert_equal 1, @webpacker, "webpacker:install expected to be called once, but was called #{@webpacker} times." | |
when "webpacker:install:react" | |
@react ||= 0 | |
@react += 1 | |
assert_equal 1, @react, "webpacker:install:react expected to be called once, but was called #{@react} times." | |
end | |
end | |
generator([destination_root], webpack: "react").stub(:rails_command, command_check) do | |
generator.stub :bundle_command, nil do | |
quietly { generator.invoke_all } | |
end | |
end | |
assert_gem "webpacker" | |
end |
That being the case, perhaps it's not safe to add inline: true
here, since it isn't really being exercised?
@@ -49,7 +49,7 @@ def create_actiontext_files | |||
end | |||
|
|||
def create_migrations | |||
rails_command "railties:install:migrations FROM=active_storage,action_text" | |||
rails_command "railties:install:migrations FROM=active_storage,action_text", inline: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line was not hit by the tests I ran locally, so I am currently unsure of its impact.
@@ -9,7 +9,7 @@ class InstallGenerator < ::Rails::Generators::Base | |||
source_root File.expand_path("templates", __dir__) | |||
|
|||
def install_javascript_dependencies | |||
rails_command "app:update:bin" | |||
rails_command "app:update:bin", inline: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line was not hit by the tests I ran locally, so I am currently unsure of its impact.
All the tests pass, but I'm unable to see a reduction in build time on Buildkite. That's not entirely unexpected though, since Buildkite run times are highly variable. Overall, I'm not sure if this patch is worth it. Perhaps others can chime in. |
I think these are fine, despite no noticeable runtime gain. I'd like to exercise the |
@kaspth Very well then! Thank you for your reviews and guidance! 💛 |
Follow-up to rails#38429. `Rails::Command.invoke` passes arguments through to the appropriate command class. However, some command classes were ignoring those arguments, and instead relying on the contents of ARGV. In particular, RakeCommand expected ARGV to contain the arguments necessary to the Rake task, and no other arguments. This caused the `webpacker:install` task to fail when the `--dev` option from `rails new --dev` remained in ARGV. This commit changes the relevant command classes to not rely on the previous contents of ARGV. This commit also adds a missing `require` for use of `Kernel#silence_warnings`. Fixes rails#38459.
Follow-up to #37516.
Running locally (on a not-very-powerful machine), I saw the time for
railties/test/generators/app_generator_test.rb
reduced from ~260 seconds to ~232 seconds. However, all that time came from a single call site (see my review comments below).