-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid shelling out for generator generate
action
#37516
Avoid shelling out for generator generate
action
#37516
Conversation
The build errors are coming from Active Job. I will take a closer look tomorrow. |
While digging into the Active Job errors, I realized a use case which does require that The benefits of not shelling out are still very desirable, though. My current thinking is to at least add a Thoughts, anyone? |
I think this third issue would be solved by rails/thor#651? |
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.
鉂わ笍
@@ -288,14 +292,12 @@ def log(*args) # :doc: | |||
def execute_command(executor, command, options = {}) # :doc: | |||
log executor, command | |||
env = options[:env] || ENV["RAILS_ENV"] || "development" | |||
rails_env = " RAILS_ENV=#{env}" unless options[:without_rails_env] |
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.
Why are we inlining this?
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.
I'm not sure I understand the question. Are you referring to the concerns you brought up in #34980 (comment)?
Is there a way to make Rails.application reload itself? Or what's the stuff that isn't reloaded properly? Do we just not have the appropriate reloaders in place to pick up e.g. |
05c1142
to
233c04b
Compare
Build errors are now unrelated. (They've been happening since ace8d6d, though I suspect the cause is some upstream dependency.) |
There does not seem to be a way to have Rails reload app config code, e.g. My current approach is to add an |
If I understand that PR correctly, However, I did add a change to this PR so that |
233c04b
to
bae33d6
Compare
I'm not sure. Rails does this:
It would seem to me that the expected behaviour is to actually not raise in some cases, but in others ("when accessing via CLI"), the thor PR would fix the issue? |
@deivid-rodriguez I think rails/thor#651 is intended to address the case where |
This change addresses a few issues: First, shelling out to the `rails` command requires the destination directory to contain certain files that the command uses to initialize itself. While this is not an issue when running generators normally, it is troublesome when testing generator-invoking generators which output to ephemeral destination directories. Second, shelling out to the `rails` command is very slow. This also is not a particular concern when running generators normally, but it makes test suites for generator-invoking generators painfully slow. Third, shelling out to the `rails` command fails silently by default. Such silent failures can be surprising, and can lead to confusing downstream failures.
bae33d6
to
dcc3c85
Compare
Perfect @jonathanhefner, thanks for preserving backwardscompatibilty too. What's the next step to get this speed boost? Is it mostly for our own generator tests? |
Follow-up to rails#37516.
@kaspth Any generator which invokes the |
This change addresses a few issues:
First, shelling out to the
rails
command requires the destination directory to contain certain files that the command uses to initialize itself. While this is not an issue when running generators normally, it is troublesome when testing generator-invoking generators which output to ephemeral destination directories.Second, shelling out to the
rails
command is very slow. This also is not a particular concern when running generators normally, but it makes test suites for generator-invoking generators painfully slow.Third, shelling out to the
rails
command fails silently by default. Such silent failures can be surprising, and can lead to confusing downstream failures.Some previous history regarding the
generate
action:generate
action in generators when testing聽#34418 was created to prevent generator sub-invocations from failing silently. It was rejected due to concerns about backward compatibility.generate
action in generators when testing聽#34418, but the solution is opt-in.RAILS_ENV
in generate action聽#34980 was created to fix a regression introduced by Abort early if generator command fails聽#34420, specific togenerate
.The changes in this PR are similar to #34418, but with backward-compatibility concerns mostly addressed. However, unlike the alternative #34420,
generate
will now always raise on failure. This could be made opt-in behavior, but I could not think of a scenario where you would wantgenerate
to fail silently.This PR does not revert #34420, which affected more than
generate
, but this PR does obsolete theabort_on_failure
option forgenerate
. Sinceabort_on_failure
was previously only tested withgenerate
, this PR adds tests for theabort_on_failure
option with other actions.This PR does revert #34980, which is no longer necessary.(See #37979)Also, a crude and informal performance measurement: for a test suite with fewer than a dozen generator-invoking-generator tests, this change reduced the run time from 57 seconds to 3.3 seconds. 馃殌