-
Notifications
You must be signed in to change notification settings - Fork 9.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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core(fr): add base fraggle rock snapshot runner #11748
Conversation
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.
quick pass but this LGTM
@@ -227,6 +232,7 @@ if (require.main === module) { | |||
console.log(`offline: listening on http://localhost:${offlinePort}`); |
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.
one day we should split this off into a smoke-static-server-entry.js
or something ..
@@ -41,12 +44,13 @@ declare global { | |||
path: string; | |||
options?: {}; | |||
} | { | |||
implementation: typeof Gatherer; | |||
implementation: ClassOf<Gatherer.GathererInstance>; |
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.
What does changing this do? typeof Gatherer
already is a ClassOf<Gatherer.GathererInstance>
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.
see #11748 (comment)
type PhaseResult_ = void|LH.GathererArtifacts[keyof LH.GathererArtifacts] | ||
export type PhaseResult = PhaseResult_ | Promise<PhaseResult_> | ||
|
||
export interface GathererInstance { |
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.
same here. The js class is the base class and the interface. Duplicating it here doesn't seem to do more with the type and adds to maintenance/distancing types from jsdocs, 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.
Decoupling the implementation and the interface is the goal here to distinguish the new from the old and differentiate which gatherers support which models of execution in a relatively trivial and lightweight way.
Is there a counter proposal in there I'm missing for how incremental transition for gatherers will be supported? I'm happy to move the docs to the interface if that's what you're asking.
options?: {}; | ||
} | { | ||
instance: InstanceType<typeof Gatherer>; |
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 working around an old bug and should be able to just be instance: Gatherer
, fwiw
const puppeteer = require('puppeteer'); | ||
const StaticServer = require('../../../lighthouse-cli/test/fixtures/static-server.js').Server; | ||
|
||
jest.setTimeout(90 * 1000); |
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.
90_000
y'all, step into the future :)
@@ -0,0 +1,84 @@ | |||
/** |
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.
if this ends up expanding to a bunch of new smoke tests, are you thinking about moving them somewhere else/called somehow else instead of in the midst of all the (mostly) unit 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.
called somehow else, yes definitely 👍
moved somewhere else, no wasn't planning on it.
artifacts[artifactName] = artifact; | ||
} | ||
|
||
return /** @type {LH.Artifacts} */ ({...baseArtifacts, ...artifacts}); // Cast to drop Partial<> |
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 assume you're already thinking about how these types are mostly useless (sometimes worse than useless) in a world where we can't usually assume they're all actually there...
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.
Important to note this section was just copied from our existing gathering so it's not a degradation :)
I have not invested significant time on ideating how to improve the types here, no. I don't really consider the pre-existing temporary lie of LH.Artifacts
at the runner level to be high on the list of type migrations that need to be done to get FR off the ground. Do you think this type flaw we have today is much more important in the FR world to warrant addressing soon?
Co-authored-by: Brendan Kenny <bckenny@gmail.com>
* @param {LH.Gatherer.GathererInstance} gatherer | ||
* @return {gatherer is LH.Gatherer.FRGathererInstance} | ||
*/ | ||
function isFRGatherer(gatherer) { |
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.
Are all FR gatherers going to support snapshot mode?
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.
No, not all, see full compat table for which ones, but the next step after #11759 is the TODO that's here about using gatherer.meta to annotate whether a gatherer supports it or not.
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.
The name isFRGatherer
makes it sound like this will detect FR gatherers, but it's used to detect snapshot support on L60. WDYT of renaming this to something like isFRSnapshotGatherer
?
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.
The name isFRGatherer makes it sound like this will detect FR gatherers
Excellent, that's exactly what it's supposed to be doing :) purely a type guard on whether a gatherer instance supports the FR gatherer properties.
but it's used to detect snapshot support on L60
I consider this function not detecting snapshot support at all which is why the TODO is there. Any suggestion for alternative wording there to make it clearer? Snapshot detection support is 2-3 PRs away from being fixed and won't affect any results in the meantime.
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 this issue has more to do with me misunderstanding the comment on L59 than the comment's wording. It's fine to leave as is :)
Summary
Builds on the work of #11623 #11633 #11685 #11742 to add the base fraggle rock runner for snapshot mode. A very basic form of snapshot mode is now runnable with this PR. See the end-to-end puppeteer tests for the example.
Related Issues/PRs
See #11622 and #11313 for the larger context.