Skip to content

Commit 3459847

Browse files
authored
Document new process for releasing breaking changes (#7187)
## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> In a future PR, we will convert all peer dependencies to dependencies. When this happens, contributors need to follow a new process for ensuring that breaking changes do not cause problems for other developers or users. This PR adds the necessary documentation. ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> Closes https://consensyssoftware.atlassian.net/browse/WPC-132. ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - [x] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Introduces a breaking-changes process guide and updates contributor docs, reviewing guide, and PR template checklist to reference and align with it. > > - **Documentation**: > - **New guide**: Add `docs/breaking-changes.md` detailing what constitutes a breaking change and the process to document, audit dependents, and prepare upgrade PRs. > - **Contributor Guide** (`docs/contributing.md`): > - Add TOC entry and link to breaking-changes guide. > - Highlight special handling for breaking changes in the release process. > - **Reviewing Release PRs** (`docs/reviewing-release-prs.md`): > - Replace inlined definition with concise definition and link to `breaking-changes.md` for examples. > - **PR Template** (`.github/pull_request_template.md`): > - Update checklist items to separate changelog updates from acknowledging/handling breaking changes with draft PRs. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c0a30da. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent c85107f commit 3459847

File tree

4 files changed

+91
-20
lines changed

4 files changed

+91
-20
lines changed

.github/pull_request_template.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ For example:
2727

2828
- [ ] I've updated the test suite for new or updated code as appropriate
2929
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
30-
- [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary
31-
- [ ] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
30+
- [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs)
31+
- [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

docs/breaking-changes.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Preparing & Releasing Breaking Changes
2+
3+
When developing packages, it is always important to be intentional about the impact that changes have on projects which use those packages. However, special consideration must be given to breaking changes.
4+
5+
This guide provides best practices for documenting, preparing, releasing, and adapting to breaking changes within `core` and in other projects.
6+
7+
## What is a breaking change?
8+
9+
A change to a package is "breaking" if upgrading a project to a version containing the change would require modifications to source code or configuration in order to avoid user- or developer-facing problems (an inability to use or build the project, a loss of functionality, etc.).
10+
11+
There are many kinds of breaking changes. Here are some examples:
12+
13+
- Removals
14+
- Removing a method from a class
15+
- Removing an export from a package (including a type export)
16+
- Functional changes that require code changes or change expectations
17+
- Changing the number of required arguments for a function or method
18+
- Throwing a new error in a function or method
19+
- Changing a function or method so that it no longer fires an event
20+
- Breaking changes to types
21+
- Adding external actions or events to a messenger type
22+
- Narrowing the type of an argument in a function or method
23+
- Changing the number of required properties in an object type
24+
- Narrowing the type of a property in an object type
25+
- Changing the number of type parameters for a type
26+
- Making any other change listed [here](https://www.semver-ts.org/formal-spec/2-breaking-changes.html)
27+
- Bumping the minimum supported Node.js version of a package
28+
- Upgrading a dependency referenced in published code to a version that causes any of the above
29+
30+
## Introducing breaking changes safely
31+
32+
Before merging a PR that introduces breaking changes, it is important to ensure that they are accounted for among projects.
33+
34+
### 1. Document breaking changes
35+
36+
To inform other maintainers now and in the future, make sure that breaking changes are documented in the changelog:
37+
38+
1. Be explicit in your changelog entries about which classes, functions, types, etc. are affected.
39+
2. Prefix entries with `**BREAKING:**`.
40+
3. If relevant, provide details on how consuming code can adapt to the changes safely.
41+
4. Move entries for breaking changes above all other kinds of changes within the same section.
42+
43+
For example:
44+
45+
```markdown
46+
### Changed
47+
48+
- **BREAKING:** Add a required `source` argument to `getTransactions` ([#1111](https://github.com/MetaMask/core/pull/1111))
49+
- **BREAKING:** Rename `Prices` to `PricesResponse` ([#2222](https://github.com/MetaMask/core/pull/2222))
50+
- **BREAKING:** `destroy` is now async ([#3333](https://github.com/MetaMask/core/pull/3333))
51+
- Widen the type of `getNetworkClientId` to return `string` ([#4444](https://github.com/MetaMask/core/pull/4444))
52+
53+
### Removed
54+
55+
- **BREAKING:** Remove `fetchGasPrices` from `GasPricesController` ([#5555](https://github.com/MetaMask/core/pull/5555))
56+
- Please use `GasPriceService` instead.
57+
```
58+
59+
### 2. Audit dependents
60+
61+
When you release your changes, which codebases will be affected?
62+
63+
Using the changelog as a guide, locate all of the places across MetaMask that use the affected classes, functions, types, etc.:
64+
65+
- To find dependents of your package within `core`, look in the package's `package.json`, or simply search across the repo.
66+
- To find dependents of your package across MetaMask, do a search on GitHub for import statements or, better, usages of the affected symbols.
67+
68+
### 3. Prepare upgrade PRs for dependents
69+
70+
Finally, how will dependent projects need to adapt to your breaking changes?
71+
72+
For dependent packages located in `core`, you may get type errors immediately that you will have to fix in the same PR that introduces the breaking changes. Otherwise, create new PRs to migrate existing code.
73+
74+
For other projects that live outside of `core`, you can use the following process to verify the effects:
75+
76+
1. Create a [preview build](./contributing.md#testing-changes-to-packages-with-preview-builds) for your package.
77+
2. Open draft PRs in the dependent projects.
78+
3. In each draft PR, upgrade your package to the preview build.
79+
4. Test the project, particularly the functionality that makes use of your package.
80+
5. If you see compile-time or runtime errors, make changes to the project as necessary.
81+
6. If you discover new breaking changes in your package that you haven't yet listed in the changelog, go back and [document them](#1-document-breaking-changes).
82+
7. Once you've done this for all projects, check off the "I've followed the process for releasing breaking changes" item in the checklist at the bottom of your PR.
83+
84+
This process serves as a check to help you understand the full impact of your changes. It will also save you time after you make a new release, because you can reuse the draft PRs later to complete upgrades.

docs/contributing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [Creating pull requests](#creating-pull-requests)
1212
- [Testing changes to packages in another project](#testing-changes-to-packages-in-another-project)
1313
- [Releasing changes](#releasing-changes)
14+
- [Preparing and releasing breaking changes](./breaking-changes.md)
1415
- [Performing operations across the monorepo](#performing-operations-across-the-monorepo)
1516
- [Adding new packages to the monorepo](#adding-new-packages-to-the-monorepo)
1617

@@ -201,6 +202,7 @@ Have changes that you need to release? There are a few things to understand:
201202
- The responsibility of maintenance is not the only thing shared among multiple teams at MetaMask; releases are as well. That means **if you work on a team that has codeownership over a package, you are free to create a new release without needing the Wallet Framework team to do so.**
202203
- Unlike clients, releases are not issued on a schedule; **anyone may create a release at any time**. Because of this, you may wish to review the Pull Requests tab on GitHub and ensure that no one else has a release candidate already in progress. If not, then you are free to start the process.
203204
- The release process is a work in progress. Further improvements to simplify the process are planned, but in the meantime, if you encounter any issues, please reach out to the Wallet Framework team.
205+
- Breaking changes take special consideration. [Read the guide](./breaking-changes.md) on how to prepare and handle them effectively.
204206
205207
Now for the process itself, you have two options: using our interactive UI (recommended for most users) or manual specification.
206208

docs/reviewing-release-prs.md

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,9 @@ With that in mind, there are three ways changes can be categorized:
9090

9191
### Breaking changes
9292

93-
A change is "breaking" if it is included in a version of a package, which, after a consumer upgrades to it and makes no further changes, causes one of the following:
94-
95-
- An error at runtime
96-
- An error at compile time (e.g., a TypeScript type error)
97-
- An error at install time (e.g., the consumer's package manager reports a Node version incompatibility)
98-
- A surprising difference in behavior
99-
100-
Given this, there are many ways a change could be regarded as breaking:
101-
102-
- Changing a function or method to throw an error
103-
- Adding a required argument to a function or method
104-
- Adding a required property to a TypeScript type
105-
- Narrowing the type of a property in a TypeScript type
106-
- Narrowing the type of an argument in a function
107-
- Adding or removing a parameter to a TypeScript type
108-
- Upgrading a runtime dependency to a version which causes any of the above
109-
- Removing an export from the package
110-
- Bumping the minimum supported Node.js version
93+
A change is "breaking" if upgrading a project to a version containing the change would require modifications to source code or configuration in order to avoid user- or developer-facing problems (an inability to use or build the project, a loss of functionality, etc.).
94+
95+
There are many kinds of breaking changes. You can find a list of examples [here](./breaking-changes.md#what-is-a-breaking-change).
11196

11297
### Additions
11398

0 commit comments

Comments
 (0)