Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark authored Jun 21, 2024
2 parents e490ef5 + 6914f5b commit f5012e3
Show file tree
Hide file tree
Showing 45 changed files with 78,305 additions and 193 deletions.
1 change: 0 additions & 1 deletion .lighthouserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module.exports = {
'unused-javascript': 'off',

label: 'off',
'content-width': 'off',
'color-contrast': 'off',
bypass: 'off',
'tap-targets': 'off',
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ _Optional_ The maximum number of requests to send to the PageSpeed Insights API
##### `psiCollectCron.sites[i].categories`
_Optional_ An array containing the categories to test for each url in this site. Defaults to `['performance', 'accessibility', 'best-practices', 'pwa', 'seo']` (all categories).
_Optional_ An array containing the categories to test for each url in this site. Defaults to `['performance', 'accessibility', 'best-practices', 'seo']` (all categories).
##### `psiCollectCron.sites[i].strategy`
Expand Down
2 changes: 1 addition & 1 deletion docs/recipes/docker-client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN apt-get update \
&& apt-get clean

# Install Lighthouse CI
RUN npm install -g @lhci/cli@0.13.0
RUN npm install -g @lhci/cli@0.14.0
RUN npm install -g lighthouse

# Install puppeteer
Expand Down
2 changes: 1 addition & 1 deletion docs/recipes/docker-server/kubernetes/lhci-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
spec:
containers:
- name: lhci-server
image: docker.io/patrickhulce/lhci-server:0.13.0
image: docker.io/patrickhulce/lhci-server:0.14.0
volumeMounts:
- mountPath: '/data'
name: lhci-data-volume
Expand Down
4 changes: 2 additions & 2 deletions docs/recipes/docker-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"start": "lhci server --config=./lighthouserc.json"
},
"dependencies": {
"@lhci/cli": "0.13.0",
"@lhci/server": "0.13.0",
"@lhci/cli": "0.14.0",
"@lhci/server": "0.14.0",
"mysql2": "^2.1.0",
"pg": "^8.2.1",
"pg-hstore": "^2.3.3",
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
"devDependencies": {
"@chialab/esbuild-plugin-html": "^0.17.3",
"@patrickhulce/scripts": "^0.4.0",
"@storybook/addon-actions": "^7.6.4",
"@storybook/addon-links": "^7.6.4",
"@storybook/addon-storyshots": "^7.6.4",
Expand Down Expand Up @@ -57,6 +58,7 @@
"@types/yargs": "^12.0.8",
"@types/yargs-parser": "^11.0.0",
"@typescript-eslint/parser": "^6.14.0",
"conventional-commits-parser": "^3.0.0",
"esbuild": "^0.19.9",
"eslint": "^8.8.0",
"eslint-config-google": "^0.14.0",
Expand All @@ -83,6 +85,7 @@
"puppeteer": "^21.6.1",
"puppeteer-core": "^21.6.1",
"rimraf": "^3.0.2",
"shelljs": "^0.8.5",
"sqlite3": "^5.1.2",
"storybook": "^7.6.4",
"ts-jest": "^29.1.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"compression": "^1.7.4",
"debug": "^4.3.1",
"express": "^4.17.1",
"https-proxy-agent": "^5.0.0",
"proxy-agent": "^6.4.0",
"inquirer": "^6.3.1",
"isomorphic-fetch": "^3.0.0",
"lighthouse": "11.4.0",
"lighthouse": "12.1.0",
"lighthouse-logger": "1.2.0",
"open": "^7.1.0",
"tmp": "^0.1.0",
Expand Down
6 changes: 5 additions & 1 deletion packages/cli/src/assert/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ function buildCommand(yargs) {
type: 'boolean',
description: 'Whether to include the results of passed assertions in the output.',
},
lhr: {
description:
'Path to LHRs (either a folder or a single file path). Not recursive. If not provided, .lighthouseci is used',
},
});
}

Expand All @@ -53,7 +57,7 @@ async function runCommand(options) {
// If we have a budgets file, convert it to our assertions format.
if (budgetsFile) options = await convertBudgetsToAssertions(readBudgets(budgetsFile));

const lhrs = loadSavedLHRs().map(json => JSON.parse(json));
const lhrs = loadSavedLHRs(options.lhr).map(json => JSON.parse(json));
const uniqueUrls = new Set(lhrs.map(lhr => lhr.finalUrl));
const allResults = getAllAssertionResults(options, lhrs);
const groupedResults = _.groupBy(allResults, result => result.url);
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/collect/fallback-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ class FallbackServer {
.filter(fileOrDir => fileOrDir.isDirectory())
.map(dir => dir.name);

const htmlFiles = files.filter(file => file.endsWith('.html')).map(file => ({file, depth: 0}));
const htmlFiles = files
.filter(file => file.endsWith('.html') || file.endsWith('.htm'))
.map(file => ({file, depth: 0}));

if (depth === 0) return htmlFiles;

Expand Down
11 changes: 7 additions & 4 deletions packages/cli/src/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@
'use strict';

const fetch = require('isomorphic-fetch');
const {HttpsProxyAgent} = require('https-proxy-agent');
const {ProxyAgent} = require('proxy-agent');

/** @type import('isomorphic-fetch') */
module.exports = (url, options) => {
/** @type {Parameters<import('isomorphic-fetch')>[1] & { agent?: import('https-proxy-agent').HttpsProxyAgent }} */
/** @type {Parameters<import('isomorphic-fetch')>[1] & { agent?: import('proxy-agent').ProxyAgent }} */
const instanceOptions = {
...options,
};

if (!instanceOptions.agent && process.env.HTTP_PROXY) {
instanceOptions.agent = new HttpsProxyAgent(process.env.HTTP_PROXY);
if (
!instanceOptions.agent &&
(process.env.HTTP_PROXY || process.env.HTTPS_PROXY || process.env.NO_PROXY)
) {
instanceOptions.agent = new ProxyAgent();
}

return fetch(url, instanceOptions);
Expand Down
13 changes: 6 additions & 7 deletions packages/cli/test/assert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ describe('Lighthouse CI assert CLI', () => {
if (!fs.existsSync(lighthouseciDir)) fs.mkdirSync(lighthouseciDir, {recursive: true});
const fakeLhrPath = path.join(lighthouseciDir, 'lhr-12345.json');
const fakeLhr = {categories: {}, audits: {}};
fakeLhr.categories.pwa = {score: 0};
fakeLhr.audits['performance-budget'] = {score: 0};
for (const key of Object.keys(fullPreset.assertions)) {
fakeLhr.audits[key] = {score: passingAuditIds.includes(key) ? 1 : 0, details: {items: [{}]}};
Expand All @@ -55,8 +54,8 @@ 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(`115`);
expect(result.warnings.length).toMatchInlineSnapshot(`17`);
expect(result.failures.length).toMatchInlineSnapshot(`108`);
expect(result.warnings.length).toMatchInlineSnapshot(`16`);
expect(result.passes.length).toMatchInlineSnapshot(`0`);
expect(result.failures).toContain('deprecations failure');
expect(result.failures).toContain('viewport failure');
Expand All @@ -65,8 +64,8 @@ describe('Lighthouse CI assert CLI', () => {
it('should run the no-pwa preset', async () => {
const result = await run([`--preset=lighthouse:no-pwa`]);
expect(result.status).toEqual(1);
expect(result.failures.length).toMatchInlineSnapshot(`109`);
expect(result.warnings.length).toMatchInlineSnapshot(`16`);
expect(result.failures.length).toMatchInlineSnapshot(`107`);
expect(result.warnings.length).toMatchInlineSnapshot(`15`);
expect(result.passes.length).toMatchInlineSnapshot(`0`);
expect(result.failures).toContain('deprecations failure');
expect(result.failures).not.toContain('viewport failure');
Expand All @@ -91,8 +90,8 @@ describe('Lighthouse CI assert CLI', () => {
it('should return passing audits', async () => {
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(`115`);
expect(result.warnings.length).toMatchInlineSnapshot(`16`);
expect(result.failures.length).toMatchInlineSnapshot(`108`);
expect(result.passes.length).toMatchInlineSnapshot(`1`);
expect(result.passes).toContain('first-contentful-paint passing');
expect(result.failures).toContain('viewport failure');
Expand Down
38 changes: 19 additions & 19 deletions packages/cli/test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ describe('Lighthouse CI CLI', () => {
it('should assert failures', async () => {
const {stdout, stderr, status} = await runCLI([
'assert',
`--assertions.installable-manifest=error`,
`--assertions.prioritize-lcp-image=error`,
]);

expect(stdout).toMatchInlineSnapshot(`""`);
Expand All @@ -327,9 +327,9 @@ describe('Lighthouse CI CLI', () => {
1 result(s) for http://localhost:XXXX/app/ :
[31mX[0m [1minstallable-manifest[0m failure for [1mminScore[0m assertion
Web app manifest or service worker do not meet the installability requirements
https://developer.chrome.com/docs/lighthouse/pwa/installable-manifest/
[31mX[0m [1mprioritize-lcp-image[0m failure for [1mminScore[0m assertion
Preload Largest Contentful Paint image
https://web.dev/articles/optimize-lcp#optimize_when_the_resource_is_discovered
expected: >=0.9
found: 0
Expand All @@ -356,13 +356,13 @@ describe('Lighthouse CI CLI', () => {
1 result(s) for http://localhost:XXXX/app/ :
[31mX[0m [1mperformance-budget[0m.script.size failure for [1mmaxNumericValue[0m assertion
Performance budget
https://developers.google.com/web/tools/lighthouse/audits/budgets
[31mX[0m [1mprioritize-lcp-image[0m failure for [1mminScore[0m assertion
Preload Largest Contentful Paint image
https://web.dev/articles/optimize-lcp#optimize_when_the_resource_is_discovered
expected: <=[32mXXXX[0m
found: [31mXXXX[0m
[2mall values: XXXX[0m
expected: >=[32m1[0m
found: [31m0[0m
[2mall values: 0, 0[0m
Assertion failed. Exiting with status code 1.
"
Expand All @@ -379,9 +379,9 @@ describe('Lighthouse CI CLI', () => {
1 result(s) for http://localhost:XXXX/app/ :
[31mX[0m [1minstallable-manifest[0m failure for [1mminScore[0m assertion
Web app manifest or service worker do not meet the installability requirements
https://developer.chrome.com/docs/lighthouse/pwa/installable-manifest/
[31mX[0m [1mprioritize-lcp-image[0m failure for [1mminScore[0m assertion
Preload Largest Contentful Paint image
https://web.dev/articles/optimize-lcp#optimize_when_the_resource_is_discovered
expected: >=0.9
found: 0
Expand Down Expand Up @@ -416,13 +416,13 @@ describe('Lighthouse CI CLI', () => {
all values: XXXX, XXXX
[31mX[0m [1mperformance-budget[0m.script.size failure for [1mmaxNumericValue[0m assertion
Performance budget
https://developers.google.com/web/tools/lighthouse/audits/budgets
[31mX[0m [1mprioritize-lcp-image[0m failure for [1mminScore[0m assertion
Preload Largest Contentful Paint image
https://web.dev/articles/optimize-lcp#optimize_when_the_resource_is_discovered
expected: <=[32mXXXX[0m
found: [31mXXXX[0m
[2mall values: XXXX[0m
expected: >=[32m1[0m
found: [31m0[0m
[2mall values: 0, 0[0m
Assertion failed. Exiting with status code 1.
"
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/fixtures/lighthouserc-matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"matchingUrlPattern": "app",
"assertions": {
"installable-manifest": "error"
"prioritize-lcp-image": "error"
}
},
{
Expand Down
1 change: 0 additions & 1 deletion packages/cli/test/fixtures/lighthouserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module.exports = {
ci: {
assert: {
assertions: {
'categories.pwa': 'off',
'speed-index': ['error', {minScore: 0.8}],
interactive: ['error', {minScore: 0.8}],
'performance-budget': ['error', {minScore: 1}],
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/test/fixtures/lighthouserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
"ci": {
"assert": {
"assertions": {
"categories.pwa": "off",
"speed-index": ["error", {"minScore": 0.8}],
"interactive": ["error", {"minScore": 0.8}],
"performance-budget": ["error", {"minScore": 1}]
"prioritize-lcp-image": ["error", {"minScore": 1}]
}
},
"collect": {
Expand Down
7 changes: 3 additions & 4 deletions packages/cli/test/upload-url-hash.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe('Lighthouse CI upload filesystem reports with url hash', () => {

const writeLhr = () => {
const fakeLhr = {finalUrl: 'foo.com', categories: {}, audits: {}};
fakeLhr.categories.pwa = {score: 0};
fakeLhr.categories.performance = {score: 0};
fakeLhr.audits['performance-budget'] = {score: 0};
for (const key of Object.keys(fullPreset.assertions)) {
Expand Down Expand Up @@ -95,21 +94,21 @@ describe('Lighthouse CI upload filesystem reports with url hash', () => {
isRepresentativeRun: true,
htmlPath: path.join(outputDir, 'www_example_com-_-_page1-2022_10_25_22_34_01.report.html'),
jsonPath: path.join(outputDir, 'www_example_com-_-_page1-2022_10_25_22_34_01.report.json'),
summary: {performance: 0.5, pwa: 0},
summary: {performance: 0.5},
},
{
url: 'https://www.example.com/#/page2',
isRepresentativeRun: true,
htmlPath: path.join(outputDir, 'www_example_com-_-_page2-2022_10_25_22_34_02.report.html'),
jsonPath: path.join(outputDir, 'www_example_com-_-_page2-2022_10_25_22_34_02.report.json'),
summary: {performance: 0.5, pwa: 0},
summary: {performance: 0.5},
},
{
url: 'https://www.example.com/#/page3',
isRepresentativeRun: true,
htmlPath: path.join(outputDir, 'www_example_com-_-_page3-2022_10_25_22_34_03.report.html'),
jsonPath: path.join(outputDir, 'www_example_com-_-_page3-2022_10_25_22_34_03.report.json'),
summary: {performance: 0.5, pwa: 0},
summary: {performance: 0.5},
},
]);
}, 15000);
Expand Down
7 changes: 3 additions & 4 deletions packages/cli/test/upload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ describe('Lighthouse CI upload CLI', () => {

const writeLhr = () => {
const fakeLhr = {finalUrl: 'foo.com', categories: {}, audits: {}};
fakeLhr.categories.pwa = {score: 0};
fakeLhr.categories.performance = {score: 0};
fakeLhr.audits['performance-budget'] = {score: 0};
for (const key of Object.keys(fullPreset.assertions)) {
Expand Down Expand Up @@ -205,21 +204,21 @@ describe('Lighthouse CI upload CLI', () => {
isRepresentativeRun: false,
htmlPath: path.join(outputDir, 'www_example_com-_page-2020_05_22_22_12_01.report.html'),
jsonPath: path.join(outputDir, 'www_example_com-_page-2020_05_22_22_12_01.report.json'),
summary: {performance: 0, pwa: 0},
summary: {performance: 0},
},
{
url: 'https://www.example.com/page',
isRepresentativeRun: false,
htmlPath: path.join(outputDir, 'www_example_com-_page-2020_05_22_22_12_02.report.html'),
jsonPath: path.join(outputDir, 'www_example_com-_page-2020_05_22_22_12_02.report.json'),
summary: {performance: 0, pwa: 0},
summary: {performance: 0},
},
{
url: 'https://www.example.com/page',
isRepresentativeRun: true,
htmlPath: path.join(outputDir, 'www_example_com-_page-2020_05_22_22_12_03.report.html'),
jsonPath: path.join(outputDir, 'www_example_com-_page-2020_05_22_22_12_03.report.json'),
summary: {performance: 0.5, pwa: 0},
summary: {performance: 0.5},
},
]);
}, 15000);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* @license Copyright 2024 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
'use strict';

const Sequelize = require('sequelize');

/* eslint-disable new-cap */

module.exports = {
/**
* @param {{queryInterface: import('sequelize').QueryInterface, options: LHCI.ServerCommand.StorageOptions}} _
*/
up: async ({queryInterface}) => {
await queryInterface.changeColumn('projects', 'name', {
type: Sequelize.STRING(256),
});
},
/**
* @param {{queryInterface: import('sequelize').QueryInterface, options: LHCI.ServerCommand.StorageOptions}} _
*/
down: async ({queryInterface}) => {
await queryInterface.changeColumn('projects', 'name', {
type: Sequelize.STRING(40),
});
},
};
2 changes: 1 addition & 1 deletion packages/server/src/api/storage/sql/project-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Sequelize = require('sequelize');
/** @type {LHCI.ServerCommand.TableDefinition<LHCI.ServerCommand.Project>} */
const attributes = {
id: {type: Sequelize.UUID(), primaryKey: true},
name: {type: Sequelize.STRING(40)},
name: {type: Sequelize.STRING(256)},
slug: {type: Sequelize.STRING(40)},
externalUrl: {type: Sequelize.STRING(256)},
token: {type: Sequelize.UUID()},
Expand Down
Loading

0 comments on commit f5012e3

Please sign in to comment.