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

feat: upgrade to Lighthouse 10.1.0 #899

Merged
merged 13 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"https-proxy-agent": "^5.0.0",
"inquirer": "^6.3.1",
"isomorphic-fetch": "^3.0.0",
"lighthouse": "9.6.8",
"lighthouse": "10.1.0",
"lighthouse-logger": "1.2.0",
"open": "^7.1.0",
"tmp": "^0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/assert/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function runCommand(options) {
if (!areAssertionsSet && !budgetsFile) throw new Error('No assertions to use');
if (budgetsFile && areAssertionsSet) throw new Error('Cannot use both budgets AND assertions');
// If we have a budgets file, convert it to our assertions format.
if (budgetsFile) options = convertBudgetsToAssertions(readBudgets(budgetsFile));
if (budgetsFile) options = await convertBudgetsToAssertions(readBudgets(budgetsFile));

const lhrs = loadSavedLHRs().map(json => JSON.parse(json));
const uniqueUrls = new Set(lhrs.map(lhr => lhr.finalUrl));
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/collect/collect.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async function runOnUrl(url, options, context) {
...options,
settings,
});
saveLHR(lhr);
await saveLHR(lhr);
process.stdout.write('done.\n');

// PSI caches results for a minute. Ensure each run is unique by waiting 60s between runs.
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/collect/node-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const uuid = require('uuid');
const childProcess = require('child_process');
const {getSavedReportsDirectory} = require('@lhci/utils/src/saved-reports.js');

const LH_CLI_PATH = path.join(require.resolve('lighthouse'), '../../lighthouse-cli/index.js');
const LH_CLI_PATH = path.join(require.resolve('lighthouse'), '../../cli/index.js');

class LighthouseRunner {
/** @param {string} output */
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/open/open.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async function runCommand(options) {

process.stdout.write(`Opening median report for ${lhr.finalUrl}...\n`);
const tmpFile = tmp.fileSync({postfix: '.html'});
fs.writeFileSync(tmpFile.name, getHTMLReportForLHR(lhr));
fs.writeFileSync(tmpFile.name, await getHTMLReportForLHR(lhr));
await open(tmpFile.name);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/upload/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ async function runTemporaryPublicStorageTarget(options) {
const response = await fetch(TEMPORARY_PUBLIC_STORAGE_URL, {
method: 'POST',
headers: {'content-type': 'text/html'},
body: getHTMLReportForLHR(lhr),
body: await getHTMLReportForLHR(lhr),
});

const {success, url} = await response.json();
Expand Down Expand Up @@ -569,7 +569,7 @@ async function runFilesystemTarget(options) {
}, /** @type {Record<string, number>} */ ({})),
};

fs.writeFileSync(entry.htmlPath, getHTMLReportForLHR(lhr));
fs.writeFileSync(entry.htmlPath, await getHTMLReportForLHR(lhr));
fs.writeFileSync(entry.jsonPath, JSON.stringify(lhr));
manifest.push(entry);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/test/assert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('Lighthouse CI assert CLI', () => {
it('should run the recommended preset', async () => {
const result = await run([`--preset=lighthouse:recommended`]);
expect(result.status).toEqual(1);
expect(result.failures.length).toMatchInlineSnapshot(`99`);
expect(result.failures.length).toMatchInlineSnapshot(`98`);
expect(result.warnings.length).toMatchInlineSnapshot(`17`);
expect(result.passes.length).toMatchInlineSnapshot(`0`);
expect(result.failures).toContain('deprecations failure');
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('Lighthouse CI assert CLI', () => {
const result = await run([`--preset=lighthouse:recommended`, '--include-passed-assertions']);
expect(result.status).toEqual(1);
expect(result.warnings.length).toMatchInlineSnapshot(`17`);
expect(result.failures.length).toMatchInlineSnapshot(`99`);
expect(result.failures.length).toMatchInlineSnapshot(`98`);
expect(result.passes.length).toMatchInlineSnapshot(`1`);
expect(result.passes).toContain('first-contentful-paint passing');
expect(result.failures).toContain('viewport failure');
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/test/autorun-github.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('Lighthouse CI autorun CLI with GitHub status check', () => {

X viewport failure for minScore assertion
Does not have a \`<meta name="viewport">\` tag with \`width\` or \`initial-scale\`
https://web.dev/viewport/
https://developer.chrome.com/docs/lighthouse/pwa/viewport/

expected: >=0.9
found: 0
Expand All @@ -114,7 +114,7 @@ describe('Lighthouse CI autorun CLI with GitHub status check', () => {

✅ viewport passing for minScore assertion
Has a \`<meta name="viewport">\` tag with \`width\` or \`initial-scale\`
https://web.dev/viewport/
https://developer.chrome.com/docs/lighthouse/pwa/viewport/

expected: >=0.9
found: 1
Expand Down Expand Up @@ -185,7 +185,7 @@ describe('Lighthouse CI autorun CLI with GitHub status check', () => {

X viewport failure for minScore assertion
Does not have a \`<meta name="viewport">\` tag with \`width\` or \`initial-scale\`
https://web.dev/viewport/
https://developer.chrome.com/docs/lighthouse/pwa/viewport/

expected: >=0.9
found: 0
Expand All @@ -195,7 +195,7 @@ describe('Lighthouse CI autorun CLI with GitHub status check', () => {

✅ viewport passing for minScore assertion
Has a \`<meta name="viewport">\` tag with \`width\` or \`initial-scale\`
https://web.dev/viewport/
https://developer.chrome.com/docs/lighthouse/pwa/viewport/

expected: >=0.9
found: 1
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/autorun-start-server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Lighthouse CI autorun CLI with startServerCommand', () => {

X viewport failure for minScore assertion
Does not have a \`<meta name="viewport">\` tag with \`width\` or \`initial-scale\`
https://web.dev/viewport/
https://developer.chrome.com/docs/lighthouse/pwa/viewport/

expected: >=0.9
found: 0
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ describe('Lighthouse CI CLI', () => {

X installable-manifest failure for minScore assertion
Web app manifest or service worker do not meet the installability requirements
https://web.dev/installable-manifest/
https://developer.chrome.com/docs/lighthouse/pwa/installable-manifest/

expected: >=0.9
found: 0
Expand Down Expand Up @@ -372,7 +372,7 @@ describe('Lighthouse CI CLI', () => {

X installable-manifest failure for minScore assertion
Web app manifest or service worker do not meet the installability requirements
https://web.dev/installable-manifest/
https://developer.chrome.com/docs/lighthouse/pwa/installable-manifest/

expected: >=0.9
found: 0
Expand Down Expand Up @@ -400,7 +400,7 @@ describe('Lighthouse CI CLI', () => {

X first-contentful-paint failure for maxNumericValue assertion
First Contentful Paint
https://web.dev/first-contentful-paint/
https://developer.chrome.com/docs/lighthouse/performance/first-contentful-paint/

expected: <=1
found: XXXX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import lhr800A_ from '../../../../../test/fixtures/lh-8-0-0-coursehero-a.json';
import lhr800B_ from '../../../../../test/fixtures/lh-8-0-0-coursehero-b.json';
import lhr930A_ from '../../../../../test/fixtures/lh-9-3-0-coursehero-a.json';
import lhr930B_ from '../../../../../test/fixtures/lh-9-3-0-coursehero-b.json';
import lhr1010A_ from '../../../../../test/fixtures/lh-10-1-0-coursehero-a.json';
import lhr1010B_ from '../../../../../test/fixtures/lh-10-1-0-coursehero-b.json';
import lhrSubitemsA_ from '../../../../../test/fixtures/lh-subitems-a.json';
import lhrSubitemsB_ from '../../../../../test/fixtures/lh-subitems-b.json';
import lhrPsi800A_ from '../../../../../test/fixtures/psi-8-0-0-dkdev-a.json';
Expand All @@ -46,6 +48,8 @@ const lhr800A = /** @type {any} */ (lhr800A_);
const lhr800B = /** @type {any} */ (lhr800B_);
const lhr930A = /** @type {any} */ (lhr930A_);
const lhr930B = /** @type {any} */ (lhr930B_);
const lhr1010A = /** @type {any} */ (lhr1010A_);
const lhr1010B = /** @type {any} */ (lhr1010B_);
const lhrSubitemsA = /** @type {any} */ (lhrSubitemsA_);
const lhrSubitemsB = /** @type {any} */ (lhrSubitemsB_);
const lhrPsi800A = /** @type {any} */ (lhrPsi800A_);
Expand All @@ -58,6 +62,7 @@ const auditPairs641 = createAuditPairs(lhr641A, lhr641B);
const auditPairs700 = createAuditPairs(lhr700A, lhr700B);
const auditPairs800 = createAuditPairs(lhr800A, lhr800B);
const auditPairs930 = createAuditPairs(lhr930A, lhr930B);
const auditPairs1010 = createAuditPairs(lhr1010A, lhr1010B);
const auditPairsPsi800 = createAuditPairs(lhrPsi800A, lhrPsi800B);
const auditPairsSubitems = createAuditPairs(lhrSubitemsA, lhrSubitemsB, {
filter: pair =>
Expand Down Expand Up @@ -133,6 +138,15 @@ export const Version930 = () => (
/>
);

export const Version1010 = () => (
<AuditDetailPane
selectedAuditId={auditPairs1010[1].audit.id || ''}
setSelectedAuditId={action('setSelectedAuditId')}
pairs={auditPairs1010}
baseLhr={lhr1010B}
/>
);

export const VersionPsi800 = () => (
<AuditDetailPane
selectedAuditId={auditPairsPsi800[1].audit.id || ''}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import lhr800A_ from '../../../../test/fixtures/lh-8-0-0-coursehero-a.json';
import lhr800B_ from '../../../../test/fixtures/lh-8-0-0-coursehero-b.json';
import lhr930A_ from '../../../../test/fixtures/lh-9-3-0-coursehero-a.json';
import lhr930B_ from '../../../../test/fixtures/lh-9-3-0-coursehero-b.json';
import lhr1010A_ from '../../../../test/fixtures/lh-10-1-0-coursehero-a.json';
import lhr1010B_ from '../../../../test/fixtures/lh-10-1-0-coursehero-b.json';
import lhrPsi800A_ from '../../../../test/fixtures/psi-8-0-0-dkdev-a.json';
import lhrPsi800B_ from '../../../../test/fixtures/psi-8-0-0-dkdev-b.json';

Expand All @@ -42,6 +44,8 @@ const lhr800A = /** @type {any} */ (lhr800A_);
const lhr800B = /** @type {any} */ (lhr800B_);
const lhr930A = /** @type {any} */ (lhr930A_);
const lhr930B = /** @type {any} */ (lhr930B_);
const lhr1010A = /** @type {any} */ (lhr1010A_);
const lhr1010B = /** @type {any} */ (lhr1010B_);
const lhrPsi800A = /** @type {any} */ (lhrPsi800A_);
const lhrPsi800B = /** @type {any} */ (lhrPsi800B_);

Expand Down Expand Up @@ -90,6 +94,12 @@ export const Version930 = () => (
</Wrapper>
);

export const Version1010 = () => (
<Wrapper>
<LhrComparison lhr={lhr1010A} baseLhr={lhr1010B} hookElements={{}} />
</Wrapper>
);

export const VersionPsi800 = () => (
<Wrapper>
<LhrComparison lhr={lhrPsi800A} baseLhr={lhrPsi800B} hookElements={{}} />
Expand Down
12 changes: 12 additions & 0 deletions packages/server/test/api/statistic-definitions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const baseLhr700_ = require('../fixtures/lh-7-0-0-coursehero-a.json');
const baseLhr800_ = require('../fixtures/lh-8-0-0-coursehero-a.json');
/** @type {any} */
const baselhr930_ = require('../fixtures/lh-9-3-0-coursehero-a.json');
/** @type {any} */
const baselhr1010_ = require('../fixtures/lh-10-1-0-coursehero-a.json');
const {definitions} = require('../../src/api/statistic-definitions.js');

describe('Statistic Definitions', () => {
Expand All @@ -38,6 +40,8 @@ describe('Statistic Definitions', () => {
const baseLhr800 = baseLhr800_;
/** @type {LH.Result} */
const baselhr930 = baselhr930_;
/** @type {LH.Result} */
const baselhr1010 = baselhr1010_;

describe('meta_lighthouse_version()', () => {
const run = definitions.meta_lighthouse_version;
Expand All @@ -50,6 +54,7 @@ describe('Statistic Definitions', () => {
expect(run([baseLhr700])).toEqual({value: 70000});
expect(run([baseLhr800])).toEqual({value: 80000});
expect(run([baselhr930])).toEqual({value: 90300});
expect(run([baselhr1010])).toEqual({value: 100100});
expect(run([{...baseLhr5, lighthouseVersion: '1.2.3-beta.0'}])).toEqual({value: 10203});
});

Expand All @@ -74,6 +79,7 @@ describe('Statistic Definitions', () => {
expect(run([high, baseLhr700, low]).value).toBeCloseTo(21206.92);
expect(run([high, baseLhr800, low]).value).toBeCloseTo(20822.103);
expect(run([high, baselhr930, low]).value).toBeCloseTo(20525.578);
expect(run([high, baselhr1010, low]).value).toBeCloseTo(21627.392);
});
});

Expand All @@ -92,6 +98,7 @@ describe('Statistic Definitions', () => {
expect(run([high, baseLhr700, low]).value).toBeCloseTo(0.18);
expect(run([high, baseLhr800, low]).value).toBeCloseTo(0.24);
expect(run([high, baselhr930, low]).value).toBeCloseTo(0.23);
expect(run([high, baselhr1010, low]).value).toBeCloseTo(0.21);
});
});

Expand All @@ -110,6 +117,7 @@ describe('Statistic Definitions', () => {
expect(run([high, baseLhr700, low]).value).toBeCloseTo(0.01);
expect(run([high, baseLhr800, low]).value).toBeCloseTo(0.01);
expect(run([high, baselhr930, low]).value).toBeCloseTo(0.01);
expect(run([high, baselhr1010, low]).value).toBeCloseTo(0.01);
});
});

Expand All @@ -128,6 +136,7 @@ describe('Statistic Definitions', () => {
expect(run([high, baseLhr700, low]).value).toBeCloseTo(0.99);
expect(run([high, baseLhr800, low]).value).toBeCloseTo(0.99);
expect(run([high, baselhr930, low]).value).toBeCloseTo(0.99);
expect(run([high, baselhr1010, low]).value).toBeCloseTo(0.99);
});
});

Expand All @@ -140,20 +149,23 @@ describe('Statistic Definitions', () => {
expect(definitions['auditgroup_a11y-aria_pass']([baseLhr700])).toEqual({value: 10});
expect(definitions['auditgroup_a11y-aria_pass']([baseLhr800])).toEqual({value: 6});
expect(definitions['auditgroup_a11y-aria_pass']([baselhr930])).toEqual({value: 8});
expect(definitions['auditgroup_a11y-aria_pass']([baselhr1010])).toEqual({value: 8});
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr5])).toEqual({value: 0});
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr6])).toEqual({value: 1});
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr62])).toEqual({value: 1});
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr641])).toEqual({value: 1});
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr700])).toEqual({value: 1});
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr800])).toEqual({value: 1});
expect(definitions['auditgroup_a11y-color-contrast_fail']([baselhr930])).toEqual({value: 1});
expect(definitions['auditgroup_a11y-color-contrast_fail']([baselhr1010])).toEqual({value: 1});
expect(definitions['auditgroup_a11y-aria_na']([baseLhr5])).toEqual({value: 0});
expect(definitions['auditgroup_a11y-aria_na']([baseLhr6])).toEqual({value: 2});
expect(definitions['auditgroup_a11y-aria_na']([baseLhr62])).toEqual({value: 2});
expect(definitions['auditgroup_a11y-aria_na']([baseLhr641])).toEqual({value: 2});
expect(definitions['auditgroup_a11y-aria_na']([baseLhr700])).toEqual({value: 7});
expect(definitions['auditgroup_a11y-aria_na']([baseLhr800])).toEqual({value: 11});
expect(definitions['auditgroup_a11y-aria_na']([baselhr930])).toEqual({value: 9});
expect(definitions['auditgroup_a11y-aria_na']([baselhr1010])).toEqual({value: 9});
});
});
});
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ describe('Project dashboard', () => {

expect(commits).toMatchInlineSnapshot(`
[
"1250build 16call_splitmasterMay 26 6:00 AM",
"1249build 15call_splitmasterMay 25 6:00 AM",
"1248build 14call_splitmasterMay 24 6:00 AM",
"1247build 13call_splitmasterMay 23 6:00 AM",
"1246build 12call_splitmasterMay 22 6:00 AM",
"1245build 11call_splitmasterMay 21 6:00 AM",
"1244build 10call_splitmasterMay 20 6:00 AM",
]
`);
});
Expand Down