Skip to content

Commit 72107f3

Browse files
committed
feat: upgrade to lighthouse 8.0
BREAKING CHANGE: upgrade to lighthouse v8.0.0
1 parent 4718436 commit 72107f3

21 files changed

+49238
-157
lines changed

.lighthouserc.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = {
1212
assertions: {
1313
'dom-size': ['error', {maxNumericValue: 3000}],
1414

15+
'csp-xss': 'off',
1516
'unsized-images': 'off',
1617
'uses-rel-preload': 'off',
1718
'uses-responsive-images': 'off',

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ When working on the server, you'll need to start parcel in watch mode. In one te
5050

5151
## Updating the Lighthouse Version
5252

53-
Updating the Lighthouse version used by LHCI involves more than a simple `package.json` update. When the Lighthouse version changes, it is usually a _breaking change_ for Lighthouse CI (see [version policy](./docs/version-policy.md)) and triggers many corresponding updates, including the following:
53+
Updating the Lighthouse version used by LHCI involves more than a simple `package.json` update. When the Lighthouse version changes, it is usually a _breaking change_ for Lighthouse CI (see [version policy](./docs/version-policy.md)) and triggers many corresponding updates, including the following ([Example PR](https://github.com/GoogleChrome/lighthouse-ci/pull/621)):
5454

5555
- Update the `package.json` version in @lhci/utils and @lhci/cli.
5656
- Run the new `lighthouse` version on a sufficiently complex URL (https://www.coursehero.com/ or https://www.theverge.com) and commit the LHR.

packages/cli/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"express": "^4.17.1",
2121
"inquirer": "^6.3.1",
2222
"isomorphic-fetch": "^3.0.0",
23-
"lighthouse": "7.3.0",
23+
"lighthouse": "8.0.0",
2424
"lighthouse-logger": "1.2.0",
2525
"open": "^7.1.0",
2626
"tmp": "^0.1.0",
@@ -29,4 +29,4 @@
2929
"yargs": "^15.4.1",
3030
"yargs-parser": "^13.1.2"
3131
}
32-
}
32+
}

packages/cli/test/assert.test.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ describe('Lighthouse CI assert CLI', () => {
5555
it('should run the recommended preset', async () => {
5656
const result = await run([`--preset=lighthouse:recommended`]);
5757
expect(result.status).toEqual(1);
58-
expect(result.failures.length).toMatchInlineSnapshot(`99`);
59-
expect(result.warnings.length).toMatchInlineSnapshot(`18`);
58+
expect(result.failures.length).toMatchInlineSnapshot(`100`);
59+
expect(result.warnings.length).toMatchInlineSnapshot(`17`);
6060
expect(result.passes.length).toMatchInlineSnapshot(`0`);
6161
expect(result.failures).toContain('deprecations failure');
6262
expect(result.failures).toContain('viewport failure');
@@ -65,8 +65,8 @@ describe('Lighthouse CI assert CLI', () => {
6565
it('should run the no-pwa preset', async () => {
6666
const result = await run([`--preset=lighthouse:no-pwa`]);
6767
expect(result.status).toEqual(1);
68-
expect(result.failures.length).toMatchInlineSnapshot(`91`);
69-
expect(result.warnings.length).toMatchInlineSnapshot(`17`);
68+
expect(result.failures.length).toMatchInlineSnapshot(`92`);
69+
expect(result.warnings.length).toMatchInlineSnapshot(`16`);
7070
expect(result.passes.length).toMatchInlineSnapshot(`0`);
7171
expect(result.failures).toContain('deprecations failure');
7272
expect(result.failures).not.toContain('viewport failure');
@@ -91,8 +91,8 @@ describe('Lighthouse CI assert CLI', () => {
9191
it('should return passing audits', async () => {
9292
const result = await run([`--preset=lighthouse:recommended`, '--include-passed-assertions']);
9393
expect(result.status).toEqual(1);
94-
expect(result.warnings.length).toMatchInlineSnapshot(`18`);
95-
expect(result.failures.length).toMatchInlineSnapshot(`99`);
94+
expect(result.warnings.length).toMatchInlineSnapshot(`17`);
95+
expect(result.failures.length).toMatchInlineSnapshot(`100`);
9696
expect(result.passes.length).toMatchInlineSnapshot(`1`);
9797
expect(result.passes).toContain('first-contentful-paint passing');
9898
expect(result.failures).toContain('viewport failure');

packages/server/src/ui/routes/build-view/audit-detail/audit-detail-pane.stories.jsx

+14
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import lhr641A_ from '../../../../../test/fixtures/lh-6-4-1-coursehero-a.json';
1818
import lhr641B_ from '../../../../../test/fixtures/lh-6-4-1-coursehero-b.json';
1919
import lhr700A_ from '../../../../../test/fixtures/lh-7-0-0-coursehero-a.json';
2020
import lhr700B_ from '../../../../../test/fixtures/lh-7-0-0-coursehero-b.json';
21+
import lhr800A_ from '../../../../../test/fixtures/lh-8-0-0-coursehero-a.json';
22+
import lhr800B_ from '../../../../../test/fixtures/lh-8-0-0-coursehero-b.json';
2123
import lhrSubitemsA_ from '../../../../../test/fixtures/lh-subitems-a.json';
2224
import lhrSubitemsB_ from '../../../../../test/fixtures/lh-subitems-b.json';
2325

@@ -37,6 +39,8 @@ const lhr641A = /** @type {any} */ (lhr641A_);
3739
const lhr641B = /** @type {any} */ (lhr641B_);
3840
const lhr700A = /** @type {any} */ (lhr700A_);
3941
const lhr700B = /** @type {any} */ (lhr700B_);
42+
const lhr800A = /** @type {any} */ (lhr800A_);
43+
const lhr800B = /** @type {any} */ (lhr800B_);
4044
const lhrSubitemsA = /** @type {any} */ (lhrSubitemsA_);
4145
const lhrSubitemsB = /** @type {any} */ (lhrSubitemsB_);
4246

@@ -45,6 +49,7 @@ const auditPairs6 = createAuditPairs(lhr6A, lhr6B);
4549
const auditPairs62 = createAuditPairs(lhr62A, lhr62B);
4650
const auditPairs641 = createAuditPairs(lhr641A, lhr641B);
4751
const auditPairs700 = createAuditPairs(lhr700A, lhr700B);
52+
const auditPairs800 = createAuditPairs(lhr800A, lhr800B);
4853
const auditPairsSubitems = createAuditPairs(lhrSubitemsA, lhrSubitemsB, {
4954
filter: pair =>
5055
[
@@ -101,6 +106,15 @@ export const Version700 = () => (
101106
/>
102107
);
103108

109+
export const Version800 = () => (
110+
<AuditDetailPane
111+
selectedAuditId={auditPairs800[1].audit.id || ''}
112+
setSelectedAuditId={action('setSelectedAuditId')}
113+
pairs={auditPairs800}
114+
baseLhr={lhr800B}
115+
/>
116+
);
117+
104118
export const VersionSubitems = () => (
105119
<AuditDetailPane
106120
selectedAuditId={auditPairsSubitems[1].audit.id || ''}

packages/server/src/ui/routes/build-view/lhr-comparison.stories.jsx

+10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import lhr641A_ from '../../../../test/fixtures/lh-6-4-1-coursehero-a.json';
1616
import lhr641B_ from '../../../../test/fixtures/lh-6-4-1-coursehero-b.json';
1717
import lhr700A_ from '../../../../test/fixtures/lh-7-0-0-coursehero-a.json';
1818
import lhr700B_ from '../../../../test/fixtures/lh-7-0-0-coursehero-b.json';
19+
import lhr800A_ from '../../../../test/fixtures/lh-8-0-0-coursehero-a.json';
20+
import lhr800B_ from '../../../../test/fixtures/lh-8-0-0-coursehero-b.json';
1921

2022
export default {
2123
title: 'Build View/LHR Comparison',
@@ -33,6 +35,8 @@ const lhr641A = /** @type {any} */ (lhr641A_);
3335
const lhr641B = /** @type {any} */ (lhr641B_);
3436
const lhr700A = /** @type {any} */ (lhr700A_);
3537
const lhr700B = /** @type {any} */ (lhr700B_);
38+
const lhr800A = /** @type {any} */ (lhr800A_);
39+
const lhr800B = /** @type {any} */ (lhr800B_);
3640

3741
/** @param {{children: LHCI.PreactNode}} props */
3842
const Wrapper = ({children}) => <div className="build-hash-selector">{children}</div>;
@@ -66,3 +70,9 @@ export const Version700 = () => (
6670
<LhrComparison lhr={lhr700A} baseLhr={lhr700B} hookElements={{}} />
6771
</Wrapper>
6872
);
73+
74+
export const Version800 = () => (
75+
<Wrapper>
76+
<LhrComparison lhr={lhr800A} baseLhr={lhr800B} hookElements={{}} />
77+
</Wrapper>
78+
);

packages/server/test/api/statistic-definitions.test.js

+12
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ const baseLhr62_ = require('../fixtures/lh-6-2-0-coursehero-a.json');
1717
const baseLhr641_ = require('../fixtures/lh-6-4-1-coursehero-a.json');
1818
/** @type {any} */
1919
const baseLhr700_ = require('../fixtures/lh-7-0-0-coursehero-a.json');
20+
/** @type {any} */
21+
const baseLhr800_ = require('../fixtures/lh-8-0-0-coursehero-a.json');
2022
const {definitions} = require('../../src/api/statistic-definitions.js');
2123

2224
describe('Statistic Definitions', () => {
@@ -30,6 +32,8 @@ describe('Statistic Definitions', () => {
3032
const baseLhr641 = baseLhr641_;
3133
/** @type {LH.Result} */
3234
const baseLhr700 = baseLhr700_;
35+
/** @type {LH.Result} */
36+
const baseLhr800 = baseLhr800_;
3337

3438
describe('meta_lighthouse_version()', () => {
3539
const run = definitions.meta_lighthouse_version;
@@ -40,6 +44,7 @@ describe('Statistic Definitions', () => {
4044
expect(run([baseLhr62])).toEqual({value: 60200});
4145
expect(run([baseLhr641])).toEqual({value: 60401});
4246
expect(run([baseLhr700])).toEqual({value: 70000});
47+
expect(run([baseLhr800])).toEqual({value: 80000});
4348
expect(run([{...baseLhr5, lighthouseVersion: '1.2.3-beta.0'}])).toEqual({value: 10203});
4449
});
4550

@@ -62,6 +67,7 @@ describe('Statistic Definitions', () => {
6267
expect(run([high, baseLhr62, low]).value).toBeCloseTo(19669.83);
6368
expect(run([high, baseLhr641, low]).value).toBeCloseTo(19945.48);
6469
expect(run([high, baseLhr700, low]).value).toBeCloseTo(21206.92);
70+
expect(run([high, baseLhr800, low]).value).toBeCloseTo(20822.103);
6571
});
6672
});
6773

@@ -78,6 +84,7 @@ describe('Statistic Definitions', () => {
7884
expect(run([high, baseLhr62, low]).value).toBeCloseTo(0.28);
7985
expect(run([high, baseLhr641, low]).value).toBeCloseTo(0.2);
8086
expect(run([high, baseLhr700, low]).value).toBeCloseTo(0.18);
87+
expect(run([high, baseLhr800, low]).value).toBeCloseTo(0.24);
8188
});
8289
});
8390

@@ -94,6 +101,7 @@ describe('Statistic Definitions', () => {
94101
expect(run([high, baseLhr62, low]).value).toBeCloseTo(0.01);
95102
expect(run([high, baseLhr641, low]).value).toBeCloseTo(0.01);
96103
expect(run([high, baseLhr700, low]).value).toBeCloseTo(0.01);
104+
expect(run([high, baseLhr800, low]).value).toBeCloseTo(0.01);
97105
});
98106
});
99107

@@ -110,6 +118,7 @@ describe('Statistic Definitions', () => {
110118
expect(run([high, baseLhr62, low]).value).toBeCloseTo(0.99);
111119
expect(run([high, baseLhr641, low]).value).toBeCloseTo(0.99);
112120
expect(run([high, baseLhr700, low]).value).toBeCloseTo(0.99);
121+
expect(run([high, baseLhr800, low]).value).toBeCloseTo(0.99);
113122
});
114123
});
115124

@@ -120,16 +129,19 @@ describe('Statistic Definitions', () => {
120129
expect(definitions['auditgroup_a11y-aria_pass']([baseLhr62])).toEqual({value: 10});
121130
expect(definitions['auditgroup_a11y-aria_pass']([baseLhr641])).toEqual({value: 10});
122131
expect(definitions['auditgroup_a11y-aria_pass']([baseLhr700])).toEqual({value: 10});
132+
expect(definitions['auditgroup_a11y-aria_pass']([baseLhr800])).toEqual({value: 6});
123133
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr5])).toEqual({value: 0});
124134
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr6])).toEqual({value: 1});
125135
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr62])).toEqual({value: 1});
126136
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr641])).toEqual({value: 1});
127137
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr700])).toEqual({value: 1});
138+
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr800])).toEqual({value: 1});
128139
expect(definitions['auditgroup_a11y-aria_na']([baseLhr5])).toEqual({value: 0});
129140
expect(definitions['auditgroup_a11y-aria_na']([baseLhr6])).toEqual({value: 2});
130141
expect(definitions['auditgroup_a11y-aria_na']([baseLhr62])).toEqual({value: 2});
131142
expect(definitions['auditgroup_a11y-aria_na']([baseLhr641])).toEqual({value: 2});
132143
expect(definitions['auditgroup_a11y-aria_na']([baseLhr700])).toEqual({value: 7});
144+
expect(definitions['auditgroup_a11y-aria_na']([baseLhr800])).toEqual({value: 11});
133145
});
134146
});
135147
});

packages/server/test/e2e/project-dashboard-mixed-v5-v6.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ describe('Project dashboard', () => {
2828

2929
expect(commits).toMatchInlineSnapshot(`
3030
Array [
31+
"1246build 12call_splitmasterMay 22 6:00 AM",
32+
"1245build 11call_splitmasterMay 21 6:00 AM",
3133
"1244build 10call_splitmasterMay 20 6:00 AM",
3234
"1243build 9call_splitmasterMay 19 6:00 AM",
3335
"1242build 8call_splitmasterMay 18 6:00 AM",
34-
"1241build 7call_splitmasterMay 17 6:00 AM",
35-
"1240build 6call_splitmasterMay 16 6:00 AM",
3636
]
3737
`);
3838
});

packages/server/test/fixtures/lh-8-0-0-coursehero-a.json

+24,538
Large diffs are not rendered by default.

packages/server/test/fixtures/lh-8-0-0-coursehero-b.json

+24,593
Large diffs are not rendered by default.

packages/server/test/test-utils.js

+4
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ function createActualTestDataset() {
9292
{...baseBuild, id: '7', hash: '1242', commitMessage: 'build 8', runAt: runAt(8)},
9393
{...baseBuild, id: '8', hash: '1243', commitMessage: 'build 9', runAt: runAt(9)},
9494
{...baseBuild, id: '9', hash: '1244', commitMessage: 'build 10', runAt: runAt(10)},
95+
{...baseBuild, id: '10', hash: '1245', commitMessage: 'build 11', runAt: runAt(11)},
96+
{...baseBuild, id: '11', hash: '1246', commitMessage: 'build 12', runAt: runAt(12)},
9597
],
9698
runs: [
9799
{...baseRun, id: '0', buildId: '0', url, lhr: lhr('lh-5-6-0-verge-a.json')},
@@ -104,6 +106,8 @@ function createActualTestDataset() {
104106
{...baseRun, id: '7', buildId: '7', url, lhr: lhr('lh-6-4-1-coursehero-b.json')},
105107
{...baseRun, id: '8', buildId: '8', url, lhr: lhr('lh-7-0-0-coursehero-a.json')},
106108
{...baseRun, id: '9', buildId: '9', url, lhr: lhr('lh-7-0-0-coursehero-b.json')},
109+
{...baseRun, id: '10', buildId: '10', url, lhr: lhr('lh-8-0-0-coursehero-a.json')},
110+
{...baseRun, id: '11', buildId: '11', url, lhr: lhr('lh-8-0-0-coursehero-b.json')},
107111
],
108112
};
109113
}

packages/utils/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"debug": "^4.3.1",
1414
"isomorphic-fetch": "^3.0.0",
1515
"js-yaml": "^3.13.1",
16-
"lighthouse": "7.3.0",
16+
"lighthouse": "8.0.0",
1717
"tree-kill": "^1.2.1"
1818
}
19-
}
19+
}

packages/utils/src/audit-diff-finder.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ function createAuditDiff(diff) {
249249
* @param {string} auditId
250250
* @param {DetailItemEntry} baseEntry
251251
* @param {DetailItemEntry} compareEntry
252-
* @param {Array<{key: string}>} headings
252+
* @param {Array<{key: string | null}>} headings
253253
* @return {Array<LHCI.AuditDiff>}
254254
*/
255255
function findAuditDetailItemKeyDiffs(auditId, baseEntry, compareEntry, headings) {
@@ -466,7 +466,7 @@ function sortZippedBaseAndCompareItems(diffs, zippedItems) {
466466
* @param {string} auditId
467467
* @param {Array<Record<string, any>>} baseItems
468468
* @param {Array<Record<string, any>>} compareItems
469-
* @param {Array<{key: string}>} headings
469+
* @param {Array<{key: string | null}>} headings
470470
* @return {Array<LHCI.AuditDiff>}
471471
*/
472472
function findAuditDetailItemsDiffs(auditId, baseItems, compareItems, headings) {

packages/utils/src/presets/all.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ module.exports = {
1010
// Not useful or invisible diagnostic audits (off)
1111
'full-page-screenshot': ['off', {}],
1212
'critical-request-chains': ['off', {}],
13-
'estimated-input-latency': ['off', {}],
1413
'final-screenshot': ['off', {}],
1514
'js-libraries': ['off', {}],
1615
'largest-contentful-paint-element': ['off', {}],
@@ -21,6 +20,7 @@ module.exports = {
2120
'network-server-latency': ['off', {}],
2221
'resource-summary': ['off', {}],
2322
'screenshot-thumbnails': ['off', {}],
23+
'script-treemap-data': ['off', {}],
2424
'third-party-summary': ['off', {}],
2525
'total-blocking-time': ['off', {}],
2626
'user-timings': ['off', {}],
@@ -50,6 +50,7 @@ module.exports = {
5050
'color-contrast': ['error', {}],
5151
'content-width': ['error', {}],
5252
'crawlable-anchors': ['error', {}],
53+
'csp-xss': ['error', {}],
5354
'cumulative-layout-shift': ['error', {}],
5455
'definition-list': ['error', {}],
5556
'document-title': ['error', {}],
@@ -61,7 +62,6 @@ module.exports = {
6162
'errors-in-console': ['error', {}],
6263
'external-anchors-use-rel-noopener': ['error', {}],
6364
'first-contentful-paint': ['error', {}],
64-
'first-cpu-idle': ['error', {}],
6565
'first-meaningful-paint': ['error', {}],
6666
'font-display': ['error', {}],
6767
'font-size': ['error', {}],
@@ -91,6 +91,7 @@ module.exports = {
9191
'meta-description': ['error', {}],
9292
'meta-refresh': ['error', {}],
9393
'meta-viewport': ['error', {}],
94+
'modern-image-formats': ['error', {}],
9495
'no-document-write': ['error', {}],
9596
'no-unload-listeners': ['error', {}],
9697
'no-vulnerable-libraries': ['error', {}],
@@ -129,7 +130,6 @@ module.exports = {
129130
'uses-rel-preload': ['error', {}],
130131
'uses-responsive-images': ['error', {}],
131132
'uses-text-compression': ['error', {}],
132-
'uses-webp-images': ['error', {}],
133133
'valid-lang': ['error', {}],
134134
'valid-source-maps': ['error', {}],
135135
'video-caption': ['error', {}],

packages/utils/src/presets/recommended.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = {
1414
'bootup-time': ['warn', {}],
1515
'cumulative-layout-shift': ['warn', {}],
1616
'first-contentful-paint': ['warn', {}],
17-
'first-cpu-idle': ['warn', {}],
1817
'first-meaningful-paint': ['warn', {}],
1918
'largest-contentful-paint': ['warn', {}],
2019
'mainthread-work-breakdown': ['warn', {}],
@@ -42,9 +41,9 @@ module.exports = {
4241

4342
'dom-size': ['warn', {}],
4443
'is-on-https': ['warn', {}], // passes on localhost, so OK to leave on
44+
'modern-image-formats': ['warn', {maxLength: 0}],
4545
'render-blocking-resources': ['warn', {maxLength: 0}],
4646
'server-response-time': ['warn', {}],
4747
'uses-long-cache-ttl': ['warn', {maxLength: 0}],
48-
'uses-webp-images': ['warn', {maxLength: 0}],
4948
},
5049
};

packages/utils/test/presets.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const PRESETS_DIR = path.join(__dirname, '../src/presets');
1515

1616
describe('presets', () => {
1717
let auditsInLighthouse = [];
18-
18+
//
1919
beforeAll(() => {
2020
const audits = defaultConfig.audits
2121
.map(p => [

0 commit comments

Comments
 (0)