-
Notifications
You must be signed in to change notification settings - Fork 110
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
Enable spring by default when executing packwerk init #153
Enable spring by default when executing packwerk init #153
Conversation
To add some context: This is a partial revert of #128 |
Hey @rafaelfranca would you be able to provide any feedback on this approach to supporting spring with packwerk based on the context in #150? |
ecb1f9f
to
f9f8638
Compare
lib/packwerk/generators/binstub.rb
Outdated
|
||
private | ||
|
||
def generate_packwerk_validate_script |
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 is not part of the revert, you added this, right? I wonder why we didn't need this before.
We also had the SpringCommand
before, which I'm not quite sure what it does 🤷🏼
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.
It was part of the revert:
It was called ApplicationValidation
, which was generated when initializing packwerk here: https://github.com/Shopify/packwerk/pull/128/files#diff-ac5ae86965a90253f8d378798aa32f4041ec009d6b79c4420e88be6e67108e88L80
That application validation generation copied the binstub here: https://github.com/Shopify/packwerk/pull/128/files#diff-5cc7180b28a34feeec40fbab8714e5bb0dd61d6db8f1554084f63f9d2ca1e9b2L39
I just called it a binstub
because that's really its main point. Before it was called ApplicationValidation
I think because it was intended to be what you called when validating the application, but now it's what we will expect people to call always regardless of if validating or if running bin/packwerk update-deprecations
, etc.
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.
OK, that makes sense!
OK, so I just tried this out on our monolith. Findings:
So, I assume that spring is not actually being used... Maybe we do need to register a spring command, as the previous implementation did. UPDATE: |
README.md
Outdated
@@ -47,7 +47,7 @@ Or install it yourself as: | |||
|
|||
$ gem install packwerk | |||
|
|||
3. Run `packwerk init` to generate the configuration files | |||
3. Run `bundle exec packwerk init` to generate the configuration files |
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 curious, did this work without bundler before, and if so, how? 😄
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.
yeah, init
definitely doesn't work without bundle exec
on master.
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.
It works by having gem install packwerk
. We have it in our Gemfile
.
db27121
to
7d753a9
Compare
@@ -3,4 +3,10 @@ | |||
|
|||
require "packwerk" | |||
|
|||
Packwerk::Cli.new(style: Packwerk::OutputStyles::Coloured.new).run(ARGV.dup) | |||
# Needs to be run in test environment in order to have test helper paths available in the autoload paths |
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 is what the previous binstub template did
9d9570c
to
23f0916
Compare
After discussing at length with @exterm , we've made changes to the original implementation. I kept the old PR description for posterity. Namely, we decided: I tested this locally and it looks good in our application! |
assert_equal("packwerk", command.exec_name) | ||
assert_equal("packwerk", command.gem_name) | ||
assert_equal("test", command.env(nil)) | ||
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.
I think you copied this test over from the previous PR, right?
Do you think it is useful?
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.
Yep, copied it over. I think it's probably not very useful.... but I think it's basically like a syntax + interface implementation test. This loads packwerk/spring_command
so it will at least catch some simple mistakes. I think it can't hurt to keep.
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 agree. The test is not very useful but as we don't expect the command to change often, it also doesn't incur a huge cost.
Modified this PR @exterm ! |
Just did a final test of As However, these are the results:
I assume the speedup is from spring caching the bundle. Pretty cool. |
I have looked over your changes again and they make perfect sense to me. If you squash the commits into some small number that makes sense, I think this is ready to merge! 👏🏼 |
e9272d0
to
3f3f2da
Compare
Sounds like packwerk 2.0 to me if I think about it - eliminating the application caches is a major (positive) change IMO. Although technically backwards compatible 🤔
👍🏼 |
Will need your help to merge @exterm
|
yep, I was just running a full The good news is that the run was successful 🎉 |
Summary
This is a preamble to #150. As discussed in the thread, we want to make
bin/packwerk init
generate a spring-enabled bin so users can execute commands likebin/packwerk check
andbin/packwerk update-deprecations
more quickly.Commits
What are you trying to accomplish?
This is a pre-requisite to removing the need to maintain a list of custom inflections and load_paths, since we will soon be asking the rails application itself for these things on the fly. We want to make it easy for people to use
spring
withpackwerk
so this doesn't cause a performance degradation when runningcheck
orupdate-deprecations
on single files or directories.What approach did you choose and why?
In the short-term, we simply generate the binstub so
spring
helps make loading the rails application quicker.In the long-term, if we can remove our dependency on zeitwerk (Shopify/constant_resolver#26), we can remove the need to load rails altogether.
What should reviewers focus on?
Making sure my understanding of how spring plays into things is correct.
Type of Change
Additional Release Notes
Include any notes here to include in the release description. For example, if you selected "breaking change" above, leave notes on how users can transition to this version.
If no additional notes are necessary, delete this section or leave it unchanged.
The docs suggest using
bin/packwerk
. Users who do not have a binstub yet can generate one withbundle exec packwerk init
Checklist