Skip to content

Commit afb8f06

Browse files
committed
chore: update contributing guide to match librarian
1 parent f17a791 commit afb8f06

1 file changed

Lines changed: 329 additions & 29 deletions

File tree

CONTRIBUTING.md

Lines changed: 329 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,340 @@
1-
# How to become a contributor and submit your own code
1+
# How to Contribute
22

3-
**Table of contents**
3+
We'd love to accept your patches and contributions to this project. There are
4+
just a few small guidelines you need to follow.
45

5-
* [Contributor License Agreements](#contributor-license-agreements)
6-
* [Contributing a patch](#contributing-a-patch)
7-
* [Running the tests](#running-the-tests)
8-
* [Releasing the library](#releasing-the-library)
6+
## Contributor License Agreement
97

10-
## Contributor License Agreements
8+
Contributions to this project must be accompanied by a Contributor License
9+
Agreement. You (or your employer) retain the copyright to your contribution;
10+
this simply gives us permission to use and redistribute your contributions as
11+
part of the project. Head over to <https://cla.developers.google.com/> to see
12+
your current agreements on file or to sign a new one.
1113

12-
We'd love to accept your sample apps and patches! Before we can take them, we
13-
have to jump a couple of legal hurdles.
14+
You generally only need to submit a CLA once, so if you've already submitted one
15+
(even if it was for a different project), you probably don't need to do it
16+
again.
1417

15-
Please fill out either the individual or corporate Contributor License Agreement
16-
(CLA).
18+
## Code Reviews
1719

18-
* If you are an individual writing original source code and you're sure you
19-
own the intellectual property, then you'll need to sign an [individual CLA](https://developers.google.com/open-source/cla/individual).
20-
* If you work for a company that wants to allow you to contribute your work,
21-
then you'll need to sign a [corporate CLA](https://developers.google.com/open-source/cla/corporate).
20+
All submissions, including submissions by project members, require review. We
21+
use GitHub pull requests for this purpose. Submissions by non-Googlers require
22+
two reviewers. Consult
23+
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
24+
information on using pull requests.
2225

23-
Follow either of the two links above to access the appropriate CLA and
24-
instructions for how to sign and return it. Once we receive it, we'll be able to
25-
accept your pull requests.
2626

27-
## Contributing A Patch
27+
### Multi-Approvers Check
2828

29-
1. Submit an issue describing your proposed change to the repo in question.
30-
1. The repo owner will respond to your issue promptly.
31-
1. If your proposed change is accepted, and you haven't already done so, sign a
32-
Contributor License Agreement (see details above).
33-
1. Fork the desired repo, develop and test your code changes.
34-
1. Ensure that your code adheres to the existing style in the code to which
35-
you are contributing.
36-
1. Ensure that your code has an appropriate set of tests which all pass.
37-
1. Submit a pull request.
29+
Each pull request must be approved by two Googlers. This is enforced by an
30+
automated multi-approvers check. This check may not automatically re-run
31+
after the second approval is added. If it remains in a failed state, you
32+
can manually re-trigger it by:
33+
34+
1. Clicking "View details" on the failed workflow to bring you to the "Actions" page.
35+
2. Clicking "Re-run failed jobs".
36+
37+
For more information, see
38+
[Re-running failed jobs in a workflow](https://docs.github.com/en/actions/how-tos/managing-workflow-runs-and-deployments/managing-workflow-runs/re-running-workflows-and-jobs#re-running-failed-jobs-in-a-workflow).
39+
40+
## Community Guidelines
41+
42+
This project follows
43+
[Google's Open Source Community Guidelines](https://opensource.google/conduct/).
44+
45+
---
46+
47+
The section above follows the standard googleapis organization’s
48+
CONTRIBUTING.md template. The section below is specific to this
49+
project. It explains how we work, how we use GitHub, and what contributors can
50+
expect when engaging with this repository.
51+
52+
---
53+
54+
## Before contributing code
55+
56+
Before doing any significant work, open an issue to propose your idea and
57+
ensure alignment. You can either file a new issue, or comment on an existing one.
58+
59+
A pull request (PR) that does not go through this coordination process may be
60+
closed to avoid wasted effort.
61+
62+
## Checking the issue tracker
63+
64+
We use GitHub issues to track tasks, bugs, and discussions.
65+
66+
> _If it didn’t happen in a GitHub issue, it never happened._
67+
68+
Use the issue tracker as your source of truth.
69+
70+
## Filing a new issue
71+
72+
All changes, except trivial ones, should start with a GitHub issue.
73+
74+
This process gives everyone a chance to validate the design, helps prevent
75+
duplication of effort, and ensures that the idea fits inside the goals for the
76+
language and tools. It also checks that the design is sound before code is
77+
written; the code review tool is not the place for high-level discussions.
78+
79+
Always include a clear description in the body of the issue. The description
80+
should provide enough context for any team member to understand the problem or
81+
request without needing to contact you directly for clarification.
82+
83+
## Leaving a TODO
84+
85+
When adding a TODO to the codebase, always include a link to an issue, no
86+
matter how small the task.
87+
88+
Use the format:
89+
90+
```
91+
// TODO(https://github.com/googleapis/google-cloud-node/issues/<number>): explain what needs to be done
92+
```
93+
94+
This helps provide context for future readers and keeps the TODO relevant and
95+
actionable as the project evolves.
96+
97+
## Sending a pull request
98+
99+
All code changes must go through a pull request. First-time contributors should
100+
review
101+
[GitHub flow](https://docs.github.com/en/get-started/using-github/github-flow).
102+
103+
Before sending a pull request, it should include tests if there are logic
104+
changes, copyright headers in every file, and a commit message following the
105+
conventions in "Commit messages" section below.
106+
107+
A pull request can be opened from a branch within the repository or from a
108+
fork. External contributors are only able to open pull requests from forks,
109+
but team members with write access can choose to open a pull request from a
110+
repository branch.
111+
112+
### Pull request from a fork
113+
114+
If you open a pull request from a personal fork, you should allow repository
115+
maintainers to make edits to your fork by turning on
116+
"Allow edits from maintainers".
117+
118+
Please see [creating a pull request from a fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork)
119+
in the official GitHub documentation for details.
120+
121+
### Pull request from a branch
122+
123+
If you are a team member with write access, you can create a branch within the
124+
repository with your changes and open a pull request from it. After the pull
125+
request is merged, the branch will be automatically deleted.
126+
127+
You should not have any long-lived branches within the repository without an
128+
open pull request. Such non-protected branches that don't have an associated
129+
open pull request, will be periodically cleaned up.
130+
131+
### Pull requests with multiple commits
132+
133+
When opening a pull request, it can be helpful to structure the commits for review. If
134+
your pull request has multiple commits, note in the description whether reviewers should
135+
review them individually or just focus on the final result. (For example, if
136+
earlier commits are exploratory and only the end state matters, make that clear
137+
to avoid wasting reviewer time.)
138+
139+
### Keeping pull requests up to date with base branch
140+
141+
The repository is configured to not require branches to be up to date before merging.
142+
This means that you do not have to have the latest changes from the base branch
143+
integrated, unless GitHub detects merge conflicts.
144+
145+
To minimize the risk of the pull request getting out of date with the base branch, enable
146+
[auto-merge](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/automatically-merging-a-pull-request)
147+
so that the pull request submits as soon as it is approved and the checks pass.
148+
149+
## Commit messages
150+
151+
Commit messages follow the conventions below.
152+
153+
Here is an example:
154+
155+
```
156+
feat(storage): add new storage bucket feature
157+
158+
A new feature is added to storage.
159+
160+
Fixes #238
161+
```
162+
163+
### First line
164+
165+
The first line of the change description is a short one-line summary of the
166+
change, following the structure `<type>(<package>): <description>`:
167+
168+
#### type
169+
170+
A structural element defined by the conventions at
171+
https://www.conventionalcommits.org/en/v1.0.0/#summary.
172+
173+
Conventional commits are parsed by release tooling to
174+
generate release notes.
175+
176+
#### package
177+
178+
The name of the package affected by the change, and should be provided in
179+
parentheses before the colon. (For example, `storage` or `pubsub`).
180+
181+
#### description
182+
183+
A short one-line summary of the change, that it should be written so to complete
184+
the sentence "This change modifies the codebase to ..." That means it does not
185+
start with a capital letter, is not a complete sentence, and actually
186+
summarizes the result of the change. Note that the verb after the colon is
187+
lowercase, and there is no trailing period.
188+
189+
The first line should be kept as short as possible (many git viewing tools
190+
prefer under ~76 characters).
191+
192+
Follow the first line by a blank line.
193+
194+
### Main content
195+
196+
The rest of the commit message should provide context for the change and
197+
explain what it does. Write in complete sentences with correct punctuation.
198+
Don't use HTML, Markdown, or any other markup language.
199+
200+
### Referencing issues
201+
202+
The special notation "Fixes #12345" associates the change with issue 12345 in
203+
the issue tracker. When this change is eventually applied, the issue
204+
tracker will automatically mark the issue as fixed.
205+
206+
If the change is a partial step towards the resolution of the issue, write
207+
"For #12345" instead. This will leave a comment in the issue linking back
208+
to the pull request, but it will not close the issue when the change is
209+
applied.
210+
211+
Please don’t use alternate GitHub-supported aliases like Close or Resolves
212+
instead of Fixes.
213+
214+
## The review process
215+
216+
This section explains the review process in detail and how to approach reviews
217+
after a pull request has been sent for review.
218+
219+
### Getting a code review
220+
221+
Before creating a pull request, make sure that your commit message follows the
222+
suggested format. Otherwise, it can be common for the pull request to be sent
223+
back with that request without review.
224+
225+
After creating a pull request, request a specific reviewer if relevant, or leave it for
226+
the default group.
227+
228+
### Merging a pull request
229+
230+
Pull request titles and descriptions must follow the [commit messages](#commit-messages)
231+
conventions. This enables approvers to review the final commit message. Once the pull
232+
request has been approved and all checks have passed, click the
233+
[Squash and Merge](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/about-pull-request-merges#squash-and-merge-your-commits)
234+
button. The resulting commit message will be based on the pull request's title and
235+
description.
236+
237+
### Reverting a pull request
238+
239+
If a merged pull request needs to be undone, for reasons such as breaking the build, the
240+
standard process is to [revert it through the GitHub interface](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/reverting-a-pull-request).
241+
242+
To revert a pull request:
243+
1. Navigate to the merged pull request on GitHub.
244+
2. Click the **Revert** button. This action automatically creates a new branch and a pull request containing the revert commit.
245+
3. Edit the pull request title and description to comply with the [commit message guidelines](#commit-messages).
246+
4. The newly created revert pull request should be reviewed and merged following the same process as any other pull request.
247+
248+
Using the GitHub "Revert" button is the preferred method over manually creating a revert commit using `git revert`.
249+
250+
### Keeping the pull request dashboard clean
251+
252+
We aim to keep the pull requests page clean so that we
253+
can quickly notice and review incoming changes that require attention.
254+
255+
Given that goal, please do not open a pull request unless you are ready for a
256+
code review. Draft pull requests and ones without author activity for more than
257+
one business day may be closed (they can always be reopened later).
258+
259+
If you're still working on something, continue iterating on your branch without
260+
creating a pull request until it’s ready for review.
261+
262+
### Addressing code review comments
263+
264+
Creating additional commits to address reviewer feedback is generally preferred
265+
over amending and force-pushing. This makes it easier for reviewers to see what
266+
has changed since their last review.
267+
268+
Pull requests are always squashed and merged. Before merging, please review and
269+
edit the resulting commit message to ensure it clearly describes the change.
270+
271+
After pushing,
272+
[click the button](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/requesting-a-pull-request-review#requesting-reviews-from-collaborators-and-organization-members)
273+
to ask a reviewer to re-request your review.
274+
275+
## Expectations for the team
276+
277+
A lot of our communication will happen on GitHub issues. Team members are
278+
expected to configure their inboxes to receive GitHub notifications alerts for
279+
all issues and pull requests to ensure effective communication.
280+
281+
If a pull request becomes inactive or misaligned with current priorities, we
282+
may close it to respect contributor and reviewer time. If you’d like to revisit
283+
it, just comment and reopen the conversation.
284+
285+
If your pull request or issue is stuck, feel free to follow up over chat. We
286+
encourage it!
287+
288+
### Reviewing a pull request
289+
290+
When reviewing a pull request:
291+
292+
- Start by reading the PR description to understand the purpose and context. If
293+
the commit message doesn’t follow the
294+
[commit message guidelines](#commit-messages),
295+
request changes.
296+
- Use `Approve` or `Request changes` explicitly. Avoid leaving ambiguous
297+
feedback.
298+
- Focus on what is in scope. If unrelated issues arise, suggest filing a
299+
separate PR or issue.
300+
- If you’ve requested changes, approve the PR once the updates are
301+
satisfactory, even if the author forgot to click the re-request review.
302+
- If a review has stalled or the context has shifted, leave a comment to
303+
clarify expectations, or close the PR. Keeping the dashboard clean is encouraged.
304+
305+
### Addressing Urgent Issues
306+
307+
We categorize issues into two primary levels of urgency:
308+
309+
- **critical 🚨**: requires immediate fix, even outside business hours
310+
- **needs fix soon ❗**: high priority issue, can be fixed during business hours
311+
312+
When an issue is labeled `critical 🚨`, the priority is to stabilize the system
313+
enough to downgrade the severity to `needs fix soon ❗`.
314+
315+
### Maintaining a Healthy Main Branch
316+
317+
All pull requests require passing CI checks to be merged.
318+
319+
The main branch must always be stable, and tests should never fail at HEAD. A
320+
red build on the main branch is a critical issue that must be fixed immediately.
321+
322+
If tests become flaky or the main branch is not consistently green, the team's top priority
323+
should shift to restoring stability. All feature development should be
324+
deprioritized until green builds can be guaranteed.
325+
326+
When you see a red x next to a commit on main, file an issue on your GitHub
327+
issue tracker, and label it `critical 🚨`.
328+
329+
Create a PR to temporarily skip the test, and verify that you have a green
330+
checkmark next to the commit on your main branch. The issue can now be
331+
downgraded to `needs fix soon ❗`.
332+
333+
### Handling Dependency Updates
334+
335+
We only update dependencies for security vulnerabilities, bug fixes, or to add
336+
feature support. Security vulnerabilities are identified using Dependabot or `npm audit`. Dependency updates for bug fixes or new features must be associated
337+
with an issue in this repository.
38338

39339
## Running the tests
40340

@@ -52,4 +352,4 @@ accept your pull requests.
52352

53353
npm run fix
54354

55-
[setup]: https://cloud.google.com/nodejs/docs/setup
355+
[setup]: https://cloud.google.com/nodejs/docs/setup

0 commit comments

Comments
 (0)