Repository navigation
feat(cli): a budget for each metric, and none that passes unchecked - #325
Merged
Merged
Conversation
--budget-fcp, --budget-ttfb and --budget-inp join --budget-lcp and --budget-cls, and the interaction workflow measures INP in a step that needs a click or a key press. cli/src/budgets.js reads the budgets, knows which snippets measure each metric, and gives each budget a verdict against the value, or the median with --runs. A budget of a metric the run does not measure exits with 2 before the page loads, naming what measures it; one whose metric was not measured exits with 1; a value that is not a number exits with 2, where it passed before. stderr names the failed budgets also with --json. The GitHub Action takes budget-fcp, budget-ttfb and budget-inp, and its budget-lcp and budget-cls default to auto, their values with core-web-vitals and no budget with the workflows that do not measure LCP or CLS.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The changelog of the CLI keeps the entries of both pull requests under Unreleased, and the page of the CLI keeps the wording of #324, not measured, with INP among the steps that need a click and the exception of a budget that needs their metric.
This was referenced Oct 25, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 1 of the budgets: a budget for each metric the CLI measures, and no budget that passes without being checked. The budgets in the reports and the JSON come in the next PR.
--budget-fcp,--budget-ttfband--budget-inp, next to--budget-lcpand--budget-cls.INPthat needs a click or a key press, likeinteractionsandinput-latency. No workflow ran the INP snippet before, so an INP budget only worked with--snippet INP.--budget-lcpwith--workflow audit, exits with2before the page loads, naming the workflow or snippet that measures it.1and says why.2.--budget-lcp abcwasNaN, and passed.--json, whose report goes to stdout.cli/src/budgets.jsholds the logic: which snippets measure each metric, the parsing, and the verdict of each budget against the value, or the median with--runs.bin.jsuses it for a page and for each combination of a matrix.budget-fcp,budget-ttfbandbudget-inp. Itsbudget-lcpandbudget-clsdefault toauto: 2500 and 0.1 withcore-web-vitals, and no budget with the other workflows, which do not measure LCP or CLS. An action withworkflow: auditand the defaults keeps passing instead of exiting with2; an empty value still disables a budget.cli/README.md,content/CLI.mdx(options, the inputs of the Action, the steps of the interaction workflow and a paragraph on what each budget needs) and the CLI changelog describe it.Test plan
cli/tests/unit/budgets.test.js(local): the five options, values that are not numbers, the snippets that measure each metric checked against their sources, the interaction workflow with INP, the metrics a run does not measure, equal to the budget passes, not measured with the reason of its snippet, the step before a follow-up, the median of the runs, the words of stderr.cli/tests/e2e/budgets.test.js(local, new): INP over budget with a slow click in the interaction workflow exits with1; without a click,not measuredand1;--budget-lcpwith--workflow auditand--budget-fcp fastexit with2without a request to the page; FCP and TTFB pass with a loose budget and fail with an impossible one, named on stderr with--json. They failed before the change.github-action.test.js(local): the new inputs reach the CLI, andautogives 2500 and 0.1 withcore-web-vitalsand nothing withaudit.interaction-workflow.test.jsandmcp-workflow.test.js(local):INPamong the steps that need input, skipped without a click and measured with one.check:emoji, CLI unit 339 of 339, CLI e2e 582 of 582,test:site44 of 44,test:ci22 of 22 (local).--workflow interaction --interact-script click.json --budget-inp 200: exit1,Budget violation: INP 304ms exceeds budget 200ms.1,INP was not measured (budget 200ms): The interactions have no click or type step; add one with --interact-script.--workflow audit --budget-lcp 2500: exit2,--budget-lcp needs a run that measures LCP, and the audit workflow does not. Use --workflow core-web-vitals or --snippet LCP.--runs 3 --budget-lcp 2500 --budget-cls 0.1on the default workflow: exit0.