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
feedback
  • Loading branch information
paulirish committed Jun 28, 2019
commit 76920df20432d076697012f4d21ec879e4553c04
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ class PerformanceCategoryRenderer extends CategoryRenderer {
element.appendChild(groupEl);
}

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

// Passed audits
const passedAudits = category.auditRefs
.filter(audit => (audit.group === 'load-opportunities' || audit.group === 'diagnostics') &&
Expand Down
34 changes: 21 additions & 13 deletions lighthouse-core/scripts/build-report-for-autodeployment.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const mkdirp = require('mkdirp').sync;
const swapLocale = require('../lib/i18n/swap-locale.js');

const ReportGenerator = require('../../lighthouse-core/report/report-generator.js');
const GatherRunner = require('../gather/gather-runner.js');
const {defaultSettings} = require('../config/constants.js');
const lighthouse = require('../index.js');
const lhr = /** @type {LH.Result} */ (require('../../lighthouse-core/test/results/sample_v2.json'));
Expand Down Expand Up @@ -71,25 +70,34 @@ function addPluginCategory(lhr) {
* @return {Promise<LH.Result>}
*/
async function generateErrorLHR() {
/** @typedef {import('../gather/driver.js')} Driver */
const url = 'http://fakeurl.com';
const options = {
requestedUrl: url,
/** @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,
driver: /** @type {Driver} */ ( /** @type {unknown} */ ({
getBrowserVersion: () => ({userAgent: 'Mozilla/5.0 ErrorUserAgent Chrome/66'}),
})),
URL: {
requestedUrl: 'http://fakeurl.com',
finalUrl: 'http://fakeurl.com',
},
Timing: [],
PageLoadError: null,
devtoolsLogs: {},
traces: {},
};
const artifacts = await GatherRunner.initializeBaseArtifacts(options);
// 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)`);

// 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 errorRunnerResult = await lighthouse(artifacts.URL.requestedUrl, {auditMode: TMP});

if (!errorRunnerResult) throw new Error('Failed to run lighthouse on empty artifacts');
const errorLhr = errorRunnerResult.lhr;
Expand Down