Repository navigation
Description
Problem to solve
As projects grow, maintaining performance standards becomes increasingly challenging. One way to ensure code quality is by gating PRs based on criteria such as bundle size, changes, and/or newly added dependencies.
Exploration here is around 1) implementing a gate that triggers specific actions (ex: fail the check, or pass with warning) when a PR's bundle size exceeds and/or other predefined thresholds and 2) a gating system to prevent performance degradation by enforcing conditional bundle limits as set by org/repo owner/maintainer.
related discovery: #1420
Solution discovery
MVP draft for bundle gate feature
-
gating item
- users can select entire bundle
-
gating criteria
- default and/or user-defined thresholds: the system to use a default percentage threshold for bundle size increases, such as 5% (auto) - users also have the option to specify their own thresholds, either as a percentage or an absolute value in MB, to suit their specific needs. (notes: confirmed in scope)
- GH check behavior: IF auto or input is exceeded, check is passed with warning - user may update to opt-in to fail
-
configuration
- by YAML, the gating configurations will be managed through a YAML file, allowing users to integrate settings directly with their existing CI/CD pipeline configurations
- in-app could show display if/not YAML is configured (to further market the configuration)
PR comment designs
View current + updated copy – the copy aims to be descriptive helping user understand why the message is shown, while not being prescriptive about next steps:
questions, considerations, and later iterations
more open questions and considerations
- default behavior: should the default behavior be to fail the gate when thresholds are exceeded, or should it pass with a warning unless configured otherwise?
- we can use
neutral? - is this configurable or default to one or the other?
- we can use
issues for later:
-
type-specific thresholds, if this is a gating item then info-display in PR comment needs updating;
-
out of box could be type: js, css, images and/or 1st loading (removing lazy loading)
- further discovery around this: DISCOVERY: file filtering for more accurate analysis #1562
-
handling new vs. existing assets: do we want the system to differentiate between increases due to new assets versus changes to existing ones
ideation
What is the criteria and/or configuration options for gate?
- Bundle size threshold: a specific size limit (e.g., X MB) for the bundle that, when exceeded, triggers a gate.
- Percentage increase: a gate triggers if the bundle size increases by more than a set percentage compared to the base branch or the last commit.
- Critical dependency addition: introduction of a new dependency known for large size or performance impact triggers the gate.
- dependency gate?
- Large file inclusion: including any single file exceeding a specified size (e.g., Y MB) in the bundle triggers the gate.
- Number of changes: exceeding a certain number of file changes in the bundle might indicate significant changes requiring additional review.
What are the gate outcomes and/or configuration options for gate?
ideation
- Fail the check: strict enforcement of bundle size criteria, blocking merges that exceed size limits.
- Pass with warning: issues a warning for review without blocking the merge, suitable for expected but notable size increases.
- Request for manual review: flags the PR for manual review under specific conditions, highlighting concerns in PR comments.
- Conditional pass/fail: logic to allow more flexibility based on additional criteria like feature importance or user experience impact.
Another consideration is: should the system display suggestions about actions to take if gate fails and/or there are warnings? or maybe that could be input by customer?
copy examples from the concepts designs in gate is activated:
Please consider reducing the size or removing assets to meet the required standards
OR
Please reach out to insert name for further review
Summary of Considerations for Initial Iteration:
configuration criteria:
- by percentage increase: allow setting a percentage increase threshold for the bundle size or 3G/high-speed download time change
- total bundle size gate: enable configuring a maximum allowable total bundle size
- by change sizes: set thresholds for acceptable change sizes within the bundle
- per bundle: allow different configurations for each bundle within a project
gate outcomes:
- gate behavior: configurable to pass, fail, or be neutral
- system guidance copy to user: generic and/or TBD for later
- otherwise, configuration by codecov.yaml? and global yam
- further about configuring in package as alternative?
### Next Steps
- [ ] https://github.com/codecov/engineering-team/issues/2004
- [ ] https://github.com/codecov/engineering-team/issues/2086
- [ ] https://github.com/codecov/engineering-team/issues/2087
- [x] Match PR comment to status (from designs)
- [x] Add above-threshold-warning in the bundles table
Activity
codecovdesign commentedon Apr 2, 2024
feedback review notes, post review WIP:
configuration criteria:
gate outcomes:
codecov.yaml[-]DISCOVERY: gate configuration option for PR based on bundle size and/or changes[/-][+]DISCOVERY/ISSUE: gate configuration option for PR based on bundle size and/or changes[/+]codecovdesign commentedon Apr 29, 2024
MVP review:
gating item: user may select bundle + specific section asset
gating criteria: increased bundle by
<user entry threshold (ex: )>, some ideation:configuration: configuring in the YAML OR the package
codecovdesign commentedon May 13, 2024
MVP draft for bundle gate feature
gating item
gating criteria
configuration
PR comment designs
View current + updated copy – the copy aims to be descriptive helping user understand why the message is shown, while not being prescriptive about next steps:
view designs
questions, considerations, and later iterations
more open questions and considerations
neutral?issues for later:
type-specific thresholds, if this is a gating item then info-display in PR comment needs updating;
out of box could be type: js, css, images and/or 1st loading (removing lazy loading)
handling new vs. existing assets: do we want the system to differentiate between increases due to new assets versus changes to existing ones
rohan-at-sentry commentedon May 13, 2024
My thoughts on open questions
This can be later
nicholas-codecov commentedon May 28, 2024
Just noting some stuff down after chatting with @giovanni-guidini
client, andserverto the bundle name. Users will also probably care differently between a server bundle and a client bundle. So we will need to be quite clear of this to users and make sure they know this information.[-]DISCOVERY/ISSUE: gate configuration option for PR based on bundle size and/or changes[/-][+][Bundle Analysis] DISCOVERY/ISSUE: gate configuration option for PR based on bundle size and/or changes[/+][-][Bundle Analysis] DISCOVERY/ISSUE: gate configuration option for PR based on bundle size and/or changes[/-][+][Bundle Analysis] FEATURE: gate configuration option for PR based on bundle size and/or changes[/+]giovanni-guidini commentedon Jul 22, 2024
TODO: 1st PR message confirming config is OK
Link to UI where user can see bundle details.
Maybe we can add a tag to the URL and trigger a quick tour of the UI?
TODO: Handle missing comparison
If the commit is not part of a PR we can still emit commit checks if there's a parent commit to compare against.
That's a good condition to add. "some bundle must have been uploaded before sending notifications"
feat: customize comment based on status
feat: add percentage change for bundles
feat: add percentage change for bundles (#353)