Skip to content
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

misc(build): create error-y LHR for the deploy #9283

Merged
merged 11 commits into from
Jun 29, 2019
Prev Previous commit
Next Next commit
add in audit warnings, too
  • Loading branch information
paulirish committed Jun 26, 2019
commit fbf2c9fff2d004821fdcbabb909b434954d67e37
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ class PerformanceCategoryRenderer extends CategoryRenderer {
element.appendChild(groupEl);
}

// TODO: Handle passed w/ warnings in a unique clump like non-perf categories do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is chicken nuggets an issue

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ayup #9288

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete then? it doesn't really have anything to do with this PR and is redundant with that PR


// Passed audits
const passedAudits = category.auditRefs
.filter(audit => (audit.group === 'load-opportunities' || audit.group === 'diagnostics') &&
Expand Down
31 changes: 28 additions & 3 deletions lighthouse-core/scripts/build-report-for-autodeployment.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,40 @@ async function generateErrorLHR() {
};
// @ts-ignore driver isn't mocked out completely
const artifacts = await GatherRunner.initializeBaseArtifacts(options);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One downside here is that ts-ignore is going to make this invisible to any breaking changes made to initializeBaseArtifacts, and since it's an internal method that could pretty easily happen

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about throwing a ts-ignore/cast on the driver object instead?

// Add in a global runWarning
artifacts.LighthouseRunWarnings.push(`Something went wrong with recording the trace over your
page load. Please run Lighthouse again. (NO_FCP)`);
Copy link
Member

@brendankenny brendankenny Jun 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about checking in error artifacts? If the pageLoadError-defaultPass trace and devtoolsLog are deleted, they should be quite small.

could just replace all of the above with

/** @type {LH.BaseArtifacts} */
const artifacts = {
  fetchTime: '2019-06-26T23:56:58.381Z',
  LighthouseRunWarnings: [
    `Something went wrong with recording the trace over your page load. Please run Lighthouse again. (NO_FCP)`, // eslint-disable-line max-len
  ],
  TestedAsMobileDevice: true,
  HostUserAgent: 'Mozilla/5.0 ErrorUserAgent Chrome/66',
  NetworkUserAgent: 'Mozilla/5.0 ErrorUserAgent Chrome/66',
  BenchmarkIndex: 1000,
  WebAppManifest: null,
  Stacks: [],
  settings: defaultSettings,
  URL: {
    requestedUrl: 'http://fakeurl.com',
    finalUrl: 'http://fakeurl.com',
  },
  Timing: [],
  PageLoadError: null,
  devtoolsLogs: {},
  traces: {},
};

and then continue as below. Only a little bit longer and the type assertion keeps everything in sync.


// Save artifacts to disk then run `lighthouse -G` with them
const TMP = `${DIST}/.tmp/`;
mkdirp(TMP);
fs.writeFileSync(`${TMP}/artifacts.json`, JSON.stringify(artifacts), 'utf-8');
const errorRunnerResult = await lighthouse(url, {auditMode: TMP});
const errorLhr = /** @type {LH.RunnerResult} */ (errorRunnerResult).lhr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need a cast?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because lighthouse can return RunnerResult | undefined (i think because of -G?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because lighthouse can return RunnerResult | undefined (i think because of -G?)

ah, oh right. I prefer the real undefined check over the cast personally, but not a big deal in this case

errorLhr.runWarnings = [
'Something went wrong with recording the trace over your page load. ' +
'Please run Lighthouse again. (NO_FCP)'

// Add audit warnings to font-display
errorLhr.audits['font-display'].warnings = [
'Lighthouse was unable to automatically check the font-display value for the following URL: https://secure-ds.serving-sys.com/resources/PROD/html5/105657/20190307/1074580285/43862346571980472/fonts/IBMPlexSans-Light-Latin1.woff.',
'Lighthouse was unable to automatically check the font-display value for the following URL: https://secure-ds.serving-sys.com/resources/PROD/html5/105657/20190307/1074580285/43862346571980472/fonts/IBMPlexSans-Bold-Latin1.woff.',
];
// perf/offscreen-images - set as passing but with a warning
Object.assign(errorLhr.audits['offscreen-images'], {
warnings: [
'Invalid image sizing information: https://cdn.cnn.com/cnn/.e1mo/img/4.0/vr/vr_new_asset.png',
],
errorMessage: undefined,
scoreDisplayMode: 'binary',
score: 1,
});
// pwa-apple-touch-icon - set as passing but with a warning
Object.assign(errorLhr.audits['apple-touch-icon'], {
warnings: [
'`apple-touch-icon-precomposed` is out of date; `apple-touch-icon` is preferred.',
],
errorMessage: undefined,
scoreDisplayMode: 'binary',
score: 1,
});

return errorLhr;
}