Skip to content

Commit

Permalink
core: remove budgets (#15950)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark authored Apr 17, 2024
1 parent c220a33 commit eafd9be
Show file tree
Hide file tree
Showing 105 changed files with 293 additions and 5,004 deletions.
7 changes: 1 addition & 6 deletions build/build-sample-reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function addPluginCategory(sampleLhr) {
}

/**
* Drops the LHR to only one, solo category (performance), and removes budgets.
* Drops the LHR to only one, solo category (performance).
* @param {LH.Result} sampleLhr
*/
function tweakLhrForPsi(sampleLhr) {
Expand All @@ -128,11 +128,6 @@ function tweakLhrForPsi(sampleLhr) {
clone.categories = {
'performance': clone.categories.performance,
};
// no budgets in PSI
delete clone.audits['performance-budget'];
clone.categories.performance.auditRefs = clone.categories.performance.auditRefs.filter(audit => {
return !audit.id.endsWith('-budget');
});
return clone;
}

Expand Down
7 changes: 0 additions & 7 deletions cli/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,6 @@ async function begin() {
config = (await import(`../core/config/${cliFlags.preset}-config.js`)).default;
}

if (cliFlags.budgetPath) {
cliFlags.budgetPath = path.resolve(process.cwd(), cliFlags.budgetPath);
/** @type {Array<LH.Budget>} */
const parsedBudget = JSON.parse(fs.readFileSync(cliFlags.budgetPath, 'utf8'));
cliFlags.budgets = parsedBudget;
}

// set logging preferences
cliFlags.logLevel = 'info';
if (cliFlags.verbose) {
Expand Down
6 changes: 1 addition & 5 deletions cli/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,6 @@ function getYargsParser(manualArgv) {
coerce: splitCommaSeparatedValues,
describe: 'Run everything except these audits',
},
'budget-path': {
type: 'string',
describe: 'The path to the budget.json file for LightWallet.',
},
'disable-full-page-screenshot': {
type: 'boolean',
describe: 'Disables collection of the full page screenshot, which can be quite large',
Expand All @@ -213,7 +209,7 @@ function getYargsParser(manualArgv) {
'save-assets', 'list-all-audits', 'list-locales', 'list-trace-categories', 'additional-trace-categories',
'config-path', 'preset', 'chrome-flags', 'port', 'hostname', 'form-factor', 'screenEmulation', 'emulatedUserAgent',
'max-wait-for-load', 'enable-error-reporting', 'gather-mode', 'audit-mode',
'only-audits', 'only-categories', 'skip-audits', 'budget-path', 'disable-full-page-screenshot', 'ignore-status-code',
'only-audits', 'only-categories', 'skip-audits', 'disable-full-page-screenshot', 'ignore-status-code',
], 'Configuration:')

// Output
Expand Down
4 changes: 0 additions & 4 deletions cli/test/cli/__snapshots__/cli-flags-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,6 @@ Object {
"_": Array [
"http://www.example.com",
],
"budget-path": "path/to/my/budget-from-config.json",
"budgetPath": "path/to/my/budget-from-config.json",
"budgets-path": "path/to/my/budget-from-command-line.json",
"budgetsPath": "path/to/my/budget-from-command-line.json",
"channel": "cli",
"chrome-flags": "--window-size 800,600",
"chrome-ignore-default-flags": false,
Expand Down
12 changes: 0 additions & 12 deletions cli/test/cli/bin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

import fs from 'fs';
import {pathToFileURL} from 'url';

import * as td from 'testdouble';
Expand Down Expand Up @@ -114,17 +113,6 @@ describe('CLI bin', function() {
});
});

describe('budget', () => {
it('should load the config from the path', async () => {
const budgetPath = `${LH_ROOT}/core/test/fixtures/simple-budget.json`;
cliFlags = {...cliFlags, budgetPath};
const budgetFile = JSON.parse(fs.readFileSync(budgetPath, 'utf-8'));
await bin.begin();

expect(getRunLighthouseArgs()[1].budgets).toEqual(budgetFile);
});
});

describe('logging', () => {
it('should have info by default', async () => {
await bin.begin();
Expand Down
13 changes: 0 additions & 13 deletions cli/test/cli/cli-flags-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,9 @@ describe('CLI flags', function() {
const flags = getFlags([
'http://www.example.com',
`--cli-flags-path="${LH_ROOT}/cli/test/fixtures/cli-flags-path.json"`,
'--budgets-path=path/to/my/budget-from-command-line.json', // this should override the config value
].join(' '));

expect(flags).toMatchObject({
budgetsPath: 'path/to/my/budget-from-command-line.json',
onlyCategories: ['performance', 'seo'],
chromeFlags: '--window-size 800,600',
extraHeaders: {'X-Men': 'wolverine'},
Expand All @@ -73,17 +71,6 @@ describe('CLI flags', function() {
snapshot(flags);
});

it('settings are accepted from a file path (inlined budgets)', () => {
const flags = getFlags([
'http://www.example.com',
// eslint-disable-next-line max-len
`--cli-flags-path="${LH_ROOT}/cli/test/fixtures/cli-flags-path-inline-budgets.json"`,
].join(' '));

expect(flags.budgets).toMatchObject([{'anything': 'works'}]);
snapshot(flags);
});

it('array values support csv when appropriate', () => {
const flags = getFlags([
'http://www.example.com',
Expand Down
3 changes: 0 additions & 3 deletions cli/test/fixtures/cli-flags-path-inline-budgets.json

This file was deleted.

1 change: 0 additions & 1 deletion cli/test/fixtures/cli-flags-path.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"budgetPath": "path/to/my/budget-from-config.json",
"onlyCategories": ["performance", "seo"],
"chromeFlags": "--window-size 800,600",
"extraHeaders": {"X-Men": "wolverine"},
Expand Down
Loading

0 comments on commit eafd9be

Please sign in to comment.