-
Notifications
You must be signed in to change notification settings - Fork 481
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
Consolidate asset config #31153
Consolidate asset config #31153
Conversation
02a5efc
to
b8e7fef
Compare
c9b6a7e
to
8147588
Compare
9a14b8b
to
3359225
Compare
next | ||
end | ||
|
||
system 'rm', '-rf', dashboard_dir('tmp', 'cache', 'assets') |
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 looks like this line was intended to clear dashboard assets between CircleCI test runs, although it's hard to know whether it was effective. @uponthesun , any idea whether files in dashboard/public/assets
are shared between drone test runs via any caching mechanism? If so, I could add a a step to remove all existing assets before rake build
in ui_tests.sh
.
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.
Nothing is saved between runs currently 👍
# Do not fallback to assets pipeline if a precompiled asset is missed. | ||
config.assets.compile = false | ||
|
||
# Generate digests for assets URLs. | ||
config.assets.digest = 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.
these removed lines had no effect because they were "conditionally" setting these to configuration parameters to their default values. This means that we've actually already been using digested / "optimized" assets in drone ui tests.
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.
Looks like a great improvement to me, and I'm happy to review drone-related things for this, but it'd make sense if you wanted another reviewer who has more asset pipeline knowledge as well.
lib/rake/build.rake
Outdated
@@ -95,9 +95,14 @@ namespace :build do | |||
end | |||
end | |||
|
|||
# Skip asset precompile in development where `config.assets.digest = false`. | |||
# Skip asset precompile in development. | |||
# Also skip on CI services (e.g. Circle) where we will precompile assets later, right before UI tests. |
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.
Update comment?
next | ||
end | ||
|
||
system 'rm', '-rf', dashboard_dir('tmp', 'cache', 'assets') |
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.
Nothing is saved between runs currently 👍
config/test.yml.erb
Outdated
optimize_webpack_assets: <%=!ci_test%> | ||
optimize_rails_assets: <%=!ci_test%> |
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.
Also in this change, we set this to true in locals.yml for drone runs, right? So during a drone run this will evaluate to false here, but then will get overridden to true anyway? If so it'd be clearer to use !unit_test
instead for the condition (and update the comment also). Unless there's some other case covered by ci_test
...
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.
true for ui tests, but not unit tests. still, removing the double negative simplifies the logic a bit.
@islemaster would you mind providing a sanity check? |
Repeating things back to make sure I understand them, after this change we have three valid configurations: # (A) production-like
optimize_rails_assets: true
optimize_webpack_assets: true
# (B) local development default
optimize_rails_assets: false
optimize_webpack_assets: false
# (C) production-like JS but Rails local development mode
optimize_rails_assets: false
optimize_webpack_assets: true And one unsupported configuration: # (D) Broken because Rails expects webpack-provided digests but webpack isn't digesting.
optimize_rails_assets: true
optimize_webpack_assets: false Questions I still have:
|
Your understanding matches mine. To answer your questions:
|
I like the enum approach not because it decreases risk or complexity, but because it forces us to name the composite configurations, documenting their meaning. I see what you're saying about the effect on the code wherever we use these configurations though. I think an enum would reduce the complexity as soon as we pulled a third boolean into the mix. For instance, adding We might get just as much value out of early detection and messaging of invalid configurations though (as you've done here). |
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.
In any case, this is definitely an improvement. 🎉
Thanks for the thorough analysis, @islemaster . Let's keep enums on the table for any future cleanup, then. |
Description
This PR consolidates the following configuration parameters/logic into a single variable
CDO.optimize_rails_assets
:config.assets.compile
config.assets.digest
rake assets:precompile
This PR also eliminates some complexity from drone ui test config:
rake circle: recompile_assets
step, because assets are now precompiled duringrake build
CDO.override_pegasus
being set during asset compilationHaving done all that, we also have to also
CDO.optimize_webpack_assets
for drone UI testsbecause our servers do not work properly in the configuration where
optimize_webpack_assets
is false andoptimize_rail_assets
is true. This is because webpack relies on the assets it produces (in dashboard/public/blockly) being passed through the rails asset pipeline (to dashboard/public/assets) without rails adding its own digest, and our mechanism for doing this is to skip adding a rails digest only when a webpack hash is already present, as described here:code-dot-org/dashboard/lib/tasks/asset_sync.rake
Line 47 in 9aa96b0
I can't quite explain why the problem described in the previous paragraph was not causing all ui tests to fail in drone runs prior to this PR, but I do feel good about eliminating this poorly-understood configuration and making drone run more similarly to our test and production servers.
Alternative
Alternately, we could run drone ui tests without
optimize_webpack_assets
oroptimize_rails_assets
, to make drone runs more like local development. This scenario failed with unclear errors when I tried it earlier, but if we prefer to head in that direction I could investigate it as a next step.Links
CDO.optimize_webpack_assets
Testing story
No new tests because no new functionality has been added. I am relying on drone + DTT to catch any breakages.
Reviewer Checklist: