-
Notifications
You must be signed in to change notification settings - Fork 143
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
[WIP] Don't merge, testing 5.1 #606
Conversation
@h-kataria @himdel can you help on the rails 5.1 asset deprecations on this PR? This is the same error I was seeing on UI-classic and it happens because we disable live compilation of assets in test:
Basically, because we disable compilation, the asset can't be found in the pipeline in the test environment. If I allow compilation in test.rb, the deprecation goes away: index c41a2eb9b2..dd254fda87 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -23,7 +23,7 @@ Vmdb::Application.configure do
end
config.assets.debug = true
- config.assets.compile = %w(spec:javascript spec).include?(ENV['TEST_SUITE'])
+ config.assets.compile = true I feel like we should enable compilation, the default behavior in test... Are you opposed to doing this? |
The main reason to disable compilation was that it was saving 3 minutes per test run. (ManageIQ/manageiq#18228) If that issue has not gone away, maybe we should try keeping it false... Are we talking about just that one file? --- a/app/views/dashboard/login.html.haml
+++ b/app/views/dashboard/login.html.haml
@@ -1,7 +1,7 @@
- auth_mode = ::Settings.authentication.mode
%span#badge
- %img{:src => ::Settings.server.custom_logo ? '/upload/custom_logo.png' : image_path("layout/login-screen-logo.png")}
+ %img{:src => ::Settings.server.custom_logo ? '/upload/custom_logo.png' : image_path("layout/login-screen-logo.png", :skip_pipeline => ENV['TEST_SUITE'] == 'spec:javascript')}
.container
.row would do the trick? (Or, possibly we could if ENV['TEST_SUITE'] == "spec:javascript"
helper do
def image_path(path, options = {})
path
end
end
end in ApplicationController (well, a mixin/helper/something)?) |
How do I verify this is still a problem when running a test locally? Does it hang at some point that's predictable and observable?
No. There were many. I was looking at a larger solution as it's the same problem I was hitting with ui-classic. The workaround I had in ui-classic was to force any tests on travis or locally to precompile assets and in the case of travis still run yarn. I don't have the exact numbers but I know there were tens of places that ui-classsic + api tests had this complaint. I don't really like the need to compile assets. I can try adding in-line skip_pipeline. I'll also try the monkey patch of image_path. Why isn't this a problem for core rails apps? Whenever we change default behaviors, it feels like there's other options we can choose as this sometimes bites us. |
The first test after 'render_view' that calls asset_path or its children (from the original PR)
No idea, sorry, maybe they have less assets? Or they always run assets:precompile? |
Cc @martinpovolny in case you remember a specific test.. |
@jrafanie Thinking a bit more, maybe the precompilation time will go down once Patternfly is no longer going through the asset pipeline (ManageIQ/manageiq-ui-classic#5679). That should cut the time down to seconds, and at that point we can probably merrily compile :). (But, that's just a theory at this point, fonts and images are not yet resolved in the PR.) |
@himdel I tried a thing... Let's see if it works... Why does sprockets-rails need to stat_tree all the assets to determine if it's precompiled in test mode? If it's not there, we want to live compile it, right? Here's the partial flamegraph: That was from running bundle exec Before:
After:
|
Ooh, that looks great, thanks! :) Does it affect what asset_path actually returns, or just the time? |
@himdel I don't know. I can try it later. Do we have tests that use asset_path I could try? I see only 1 test failure on ui-classic using this technique: https://travis-ci.org/ManageIQ/manageiq-ui-classic/jobs/544451084 Do you understand why the sprockets-rails code was stat'ing all of the asset locations at rails engine boot? ManageIQ/manageiq@e2dc951 While I like the results, I don't know if my monkey patch is doing the right thing. I don't understand all of the complexity of asset compilation vs. pre-compilation in test vs. dev vs prod. It feels wrong to build a list of all asset paths throughout the app in test mode at engine load time if we're going to dynamically compile things anyway. |
I think we mostly try not to have them, as long as no new tests are breaking that's probably fine.
Well, heh heh, nobody undestands sprockets :) So.. I'm really treating sprockets as a legacy thing that will go away. |
Checked commit jrafanie@6fb09fd with ruby 2.3.3, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 |
@jrafanie Anything remaining to be done with this? |
Nope, thanks! |
No description provided.