-
Notifications
You must be signed in to change notification settings - Fork 714
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
feat: add basic lighthouse functionality #825
Conversation
agent/js/src/wd_server.js
Outdated
this.lighthouseFile_ = path.join(this.runTempDir_, 'lighthouse.html'); | ||
this.app_.timeout(1000, 'Waiting for Chrome to be available...'); | ||
process_utils.scheduleExec(this.app_, | ||
'lighthouse', |
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.
Probably up to Pat, but should we put the lighthouse install instructions in a readme?
Presumably it's npm install -g GoogleChrome/lighthouse
+ confirm npm globals are in your PATH?
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 the most helpful instructions I actually found were over in the google sites page rather than any README so I figured we'd add it there, but even better to find a place here if there's one I missed!
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.
How big is it and is it feasible to include directly? Worst case I'll add logic to the agent at startup to look for it and try to install if it isn't there (and automatically update if it is) but if we can eliminate the need for manually installing then all of the existing agents will pick up lighthouse support automatically.
Also, does running it as "lighthouse" work on Windows as well or does Node need to explicitly be referenced? Just checking since the Node agent runs across all platforms.
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.
IMO the maintenance burden of keeping it as a submodule or checking in the result of npm install here is more trouble than letting npm install -g
handle it and adding an auto-update check, but it's a bit safer so I'm open to either.
I'm not on Windows anywhere with node, so I can't verify it, but we've recently had a contributor making sure our build runs on appveyor which I believe removed our *nix specific hashbangs and such. If your path is setup correctly it should, but I can validate on my machine at home tonight.
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.
PHP! It's been a while my friend.
agent/js/src/wd_server.js
Outdated
'--output-path', this.lighthouseFile_, | ||
this.task_.url, | ||
], undefined, this.timeout_).then(function () { | ||
var devtoolsLogFile = path.join(this.runTempDir_, 'lighthouse-0.devtoolslog.json'); |
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.
is this indentation intentional?
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 line yes :) though the above should be indented 2 more spaces. it's used elsewhere like this, will fix
www/lighthouse.php
Outdated
|
||
// Cache for a year | ||
header('Last-Modified: ' . gmdate('r')); | ||
header('Expires: '.gmdate('r', time() + 31536000)); |
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.
space around .
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.
IIRC Expires
is old and everyone supports Cache-Control
now. Do we need it?
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 WPT code is old so it's just left over :-) It's fine to remove it but it also doesn't hurt since cache-control takes precedence.
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'll remove
Does our snazy LH animation come into the mix anywhere, or is that just for PR description fun? |
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 blockers so I'm happy to merge. My vote is to merge it as it is and iterate on the result UI and agent install bits. LMK if that sounds good and I'll pull it in.
agent/js/src/wd_server.js
Outdated
this.lighthouseFile_ = path.join(this.runTempDir_, 'lighthouse.html'); | ||
this.app_.timeout(1000, 'Waiting for Chrome to be available...'); | ||
process_utils.scheduleExec(this.app_, | ||
'lighthouse', |
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.
How big is it and is it feasible to include directly? Worst case I'll add logic to the agent at startup to look for it and try to install if it isn't there (and automatically update if it is) but if we can eliminate the need for manually installing then all of the existing agents will pick up lighthouse support automatically.
Also, does running it as "lighthouse" work on Windows as well or does Node need to explicitly be referenced? Just checking since the Node agent runs across all platforms.
www/lighthouse.php
Outdated
|
||
// Cache for a year | ||
header('Last-Modified: ' . gmdate('r')); | ||
header('Expires: '.gmdate('r', time() + 31536000)); |
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 WPT code is old so it's just left over :-) It's fine to remove it but it also doesn't hurt since cache-control takes precedence.
// create a friendlier (unique) name for the fi | ||
$fileUrl = GetFileUrl($url); | ||
if ( $test['testinfo']['lighthouse'] && $fvMedian ) | ||
{ | ||
echo "<a href=\"/lighthouse.php?test=$id&run=$fvMedian\">Lighthouse report</a><br>"; |
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 works for now but I'd really like to give it much more prominent treatment. The grades section in the header is a perfect place since the grades won't be calculated in the lighthouse case. If the score can be pulled out of the HTML then the UI can have a large:
Lighthouse Score: 85/100 (click for full report)
And maybe also the logo ;-)
+1 on iterating on the UI and figuring out more prominent bits as we go.
Including the logo will help users know this is the same tool they've used
elsewhere.
…On Thu, Mar 2, 2017, 6:29 AM Patrick Meenan ***@***.***> wrote:
***@***.**** approved this pull request.
No blockers so I'm happy to merge. My vote is to merge it as it is and
iterate on the result UI and agent install bits. LMK if that sounds good
and I'll pull it in.
------------------------------
In agent/js/src/wd_server.js
<#825 (comment)>
:
> * a directory.
* @Private
*/
WebDriverServer.prototype.runLighthouse_ = function() {
- // TODO(phulce): actually run lighthouse
- this.onPageLoad_(new Error('Lighthouse not yet implemented!'));
+ this.lighthouseFile_ = path.join(this.runTempDir_, 'lighthouse.html');
+ this.app_.timeout(1000, 'Waiting for Chrome to be available...');
+ process_utils.scheduleExec(this.app_,
+ 'lighthouse',
How big is it and is it feasible to include directly? Worst case I'll add
logic to the agent at startup to look for it and try to install if it isn't
there (and automatically update if it is) but if we can eliminate the need
for manually installing then all of the existing agents will pick up
lighthouse support automatically.
Also, does running it as "lighthouse" work on Windows as well or does Node
need to explicitly be referenced? Just checking since the Node agent runs
across all platforms.
------------------------------
In www/lighthouse.php
<#825 (comment)>
:
> @@ -0,0 +1,26 @@
+<?php
+if(array_key_exists("HTTP_IF_MODIFIED_SINCE",$_SERVER) && strlen(trim($_SERVER['HTTP_IF_MODIFIED_SINCE']))) {
+ header("HTTP/1.0 304 Not Modified");
+} else {
+ include 'common.inc';
+ $ok = false;
+ if (isset($testPath) && is_dir($testPath)) {
+ $file = "${run}_lighthouse.html.gz";
+ $filePath = "$testPath/$file";
+ if (is_file($filePath)) {
+ $ok = true;
+
+ // Cache for a year
+ header('Last-Modified: ' . gmdate('r'));
+ header('Expires: '.gmdate('r', time() + 31536000));
The WPT code is old so it's just left over :-) It's fine to remove it but
it also doesn't hurt since cache-control takes precedence.
------------------------------
In www/result.inc
<#825 (comment)>
:
> // create a friendlier (unique) name for the fi
$fileUrl = GetFileUrl($url);
+ if ( $test['testinfo']['lighthouse'] && $fvMedian )
+ {
+ echo "<a href=\"/lighthouse.php?test=$id&run=$fvMedian\">Lighthouse report</a><br>";
This works for now but I'd really like to give it much more prominent
treatment. The grades section in the header is a perfect place since the
grades won't be calculated in the lighthouse case. If the score can be
pulled out of the HTML then the UI can have a large:
Lighthouse Score: 85/100 (click for full report)
And maybe also the logo ;-)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#825 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOigCsQZ8XrvVJoh8Bq5XwWwmEJaVKEks5rhtJGgaJpZM4MQbjA>
.
|
Just fun, but it will! That GIF was from my local custom LH-WPT launch page ;) I also vote to iterate on the UI, adding the score, etc. |
Woot! cc @igrigorik |
\o/ ... woot! Pat: when might we see this live on webpagetest.org? :) |
Probably next week. I want to do some testing first and then since I have ~60 mobile agents I really want to teach the agent code to install and update lighthouse automatically so I don't have to manually configure all of them. |
There go my hopes for an easy install :( Apparently the Node version on the Pi's is 4.x (which is what is in the repo for jessie) so I need to go through and upgrade them all to 7.x anyway. Starting on the testing now and I still plan to have it up and running next week. |
cc: @paulirish @ebidel @brendankenny
The Lighthouse
The Run
The Report (video is available on mobile)