contracts/lib/forge-std/CONTRIBUTING.md 11.4 K raw
1
## Contributing to Foundry
2
3
Thanks for your interest in improving Foundry!
4
5
There are multiple opportunities to contribute at any level. It doesn't matter if you are just getting started with Rust or are the most weathered expert, we can use your help.
6
7
This document will help you get started. **Do not let the document intimidate you**.
8
It should be considered as a guide to help you navigate the process.
9
10
The [dev Telegram][dev-tg] is available for any concerns you may have that are not covered in this guide.
11
12
### Code of Conduct
13
14
The Foundry project adheres to the [Rust Code of Conduct][rust-coc]. This code of conduct describes the _minimum_ behavior expected from all contributors.
15
16
Instances of violations of the Code of Conduct can be reported by contacting the team at [me@gakonst.com](mailto:me@gakonst.com).
17
18
### Ways to contribute
19
20
There are fundamentally four ways an individual can contribute:
21
22
1. **By opening an issue:** For example, if you believe that you have uncovered a bug
23
   in Foundry, creating a new issue in the issue tracker is the way to report it.
24
2. **By adding context:** Providing additional context to existing issues,
25
   such as screenshots and code snippets, which help resolve issues.
26
3. **By resolving issues:** Typically this is done in the form of either
27
   demonstrating that the issue reported is not a problem after all, or more often,
28
   by opening a pull request that fixes the underlying problem, in a concrete and
29
   reviewable manner.
30
31
**Anybody can participate in any stage of contribution**. We urge you to participate in the discussion
32
around bugs and participate in reviewing PRs.
33
34
### Contributions Related to Spelling and Grammar
35
36
At this time, we will not be accepting contributions that only fix spelling or grammatical errors in documentation, code or
37
elsewhere.
38
39
### Asking for help
40
41
If you have reviewed existing documentation and still have questions, or you are having problems, you can get help in the following ways:
42
43
-   **Asking in the support Telegram:** The [Foundry Support Telegram][support-tg] is a fast and easy way to ask questions.
44
-   **Opening a discussion:** This repository comes with a discussions board where you can also ask for help. Click the "Discussions" tab at the top.
45
46
As Foundry is still in heavy development, the documentation can be a bit scattered.
47
The [Foundry Book][foundry-book] is our current best-effort attempt at keeping up-to-date information.
48
49
### Submitting a bug report
50
51
When filing a new bug report in the issue tracker, you will be presented with a basic form to fill out.
52
53
If you believe that you have uncovered a bug, please fill out the form to the best of your ability. Do not worry if you cannot answer every detail; just fill in what you can. Contributors will ask follow-up questions if something is unclear.
54
55
The most important pieces of information we need in a bug report are:
56
57
-   The Foundry version you are on (and that it is up to date)
58
-   The platform you are on (Windows, macOS, an M1 Mac or Linux)
59
-   Code snippets if this is happening in relation to testing or building code
60
-   Concrete steps to reproduce the bug
61
62
In order to rule out the possibility of the bug being in your project, the code snippets should be as minimal
63
as possible. It is better if you can reproduce the bug with a small snippet as opposed to an entire project!
64
65
See [this guide][mcve] on how to create a minimal, complete, and verifiable example.
66
67
### Submitting a feature request
68
69
When adding a feature request in the issue tracker, you will be presented with a basic form to fill out.
70
71
Please include as detailed of an explanation as possible of the feature you would like, adding additional context if necessary.
72
73
If you have examples of other tools that have the feature you are requesting, please include them as well.
74
75
### Resolving an issue
76
77
Pull requests are the way concrete changes are made to the code, documentation, and dependencies of Foundry.
78
79
Even minor pull requests, such as those fixing wording, are greatly appreciated. Before making a large change, it is usually
80
a good idea to first open an issue describing the change to solicit feedback and guidance. This will increase
81
the likelihood of the PR getting merged.
82
83
Please make sure that the following commands pass if you have changed the code:
84
85
```sh
86
forge fmt --check
87
forge test -vvv
88
```
89
90
To make sure your changes are compatible with all compiler version targets, run the following commands:
91
92
```sh
93
forge build --skip test --use solc:0.6.2
94
forge build --skip test --use solc:0.6.12
95
forge build --skip test --use solc:0.7.0
96
forge build --skip test --use solc:0.7.6
97
forge build --skip test --use solc:0.8.0
98
```
99
100
The CI will also ensure that the code is formatted correctly and that the tests are passing across all compiler version targets.
101
102
#### Adding cheatcodes
103
104
Please follow the guide outlined in the [cheatcodes](https://github.com/foundry-rs/foundry/blob/master/docs/dev/cheatcodes.md#adding-a-new-cheatcode) documentation of Foundry.
105
106
When making modifications to the native cheatcodes or adding new ones, please make sure to run [`./scripts/vm.py`](./scripts/vm.py) to update the cheatcodes in the [`src/Vm.sol`](./src/Vm.sol) file.
107
108
By default the script will automatically generate the cheatcodes from the [`cheatcodes.json`](https://raw.githubusercontent.com/foundry-rs/foundry/master/crates/cheatcodes/assets/cheatcodes.json) file but alternatively you can provide a path to a JSON file containing the Vm interface, as generated by Foundry, with the `--from` flag.
109
110
```sh
111
./scripts/vm.py --from path/to/cheatcodes.json
112
```
113
114
It is possible that the resulting [`src/Vm.sol`](./src/Vm.sol) file will have some changes that are not directly related to your changes, this is not a problem.
115
116
#### Commits
117
118
It is a recommended best practice to keep your changes as logically grouped as possible within individual commits. There is no limit to the number of commits any single pull request may have, and many contributors find it easier to review changes that are split across multiple commits.
119
120
That said, if you have a number of commits that are "checkpoints" and don't represent a single logical change, please squash those together.
121
122
#### Opening the pull request
123
124
From within GitHub, opening a new pull request will present you with a template that should be filled out. Please try your best at filling out the details, but feel free to skip parts if you're not sure what to put.
125
126
#### Discuss and update
127
128
You will probably get feedback or requests for changes to your pull request.
129
This is a big part of the submission process, so don't be discouraged! Some contributors may sign off on the pull request right away, others may have more detailed comments or feedback.
130
This is a necessary part of the process in order to evaluate whether the changes are correct and necessary.
131
132
**Any community member can review a PR, so you might get conflicting feedback**.
133
Keep an eye out for comments from code owners to provide guidance on conflicting feedback.
134
135
#### Reviewing pull requests
136
137
**Any Foundry community member is welcome to review any pull request**.
138
139
All contributors who choose to review and provide feedback on pull requests have a responsibility to both the project and individual making the contribution. Reviews and feedback must be helpful, insightful, and geared towards improving the contribution as opposed to simply blocking it. If there are reasons why you feel the PR should not be merged, explain what those are. Do not expect to be able to block a PR from advancing simply because you say "no" without giving an explanation. Be open to having your mind changed. Be open to working _with_ the contributor to make the pull request better.
140
141
Reviews that are dismissive or disrespectful of the contributor or any other reviewers are strictly counter to the Code of Conduct.
142
143
When reviewing a pull request, the primary goals are for the codebase to improve and for the person submitting the request to succeed. **Even if a pull request is not merged, the submitter should come away from the experience feeling like their effort was not unappreciated**. Every PR from a new contributor is an opportunity to grow the community.
144
145
##### Review a bit at a time
146
147
Do not overwhelm new contributors.
148
149
It is tempting to micro-optimize and make everything about relative performance, perfect grammar, or exact style matches. Do not succumb to that temptation..
150
151
Focus first on the most significant aspects of the change:
152
153
1. Does this change make sense for Foundry?
154
2. Does this change make Foundry better, even if only incrementally?
155
3. Are there clear bugs or larger scale issues that need attending?
156
4. Are the commit messages readable and correct? If it contains a breaking change, is it clear enough?
157
158
Note that only **incremental** improvement is needed to land a PR. This means that the PR does not need to be perfect, only better than the status quo. Follow-up PRs may be opened to continue iterating.
159
160
When changes are necessary, _request_ them, do not _demand_ them, and **do not assume that the submitter already knows how to add a test or run a benchmark**.
161
162
Specific performance optimization techniques, coding styles and conventions change over time. The first impression you give to a new contributor never does.
163
164
Nits (requests for small changes that are not essential) are fine, but try to avoid stalling the pull request. Most nits can typically be fixed by the Foundry maintainers merging the pull request, but they can also be an opportunity for the contributor to learn a bit more about the project.
165
166
It is always good to clearly indicate nits when you comment, e.g.: `Nit: change foo() to bar(). But this is not blocking`.
167
168
If your comments were addressed but were not folded after new commits, or if they proved to be mistaken, please, [hide them][hiding-a-comment] with the appropriate reason to keep the conversation flow concise and relevant.
169
170
##### Be aware of the person behind the code
171
172
Be aware that _how_ you communicate requests and reviews in your feedback can have a significant impact on the success of the pull request. Yes, we may merge a particular change that makes Foundry better, but the individual might just not want to have anything to do with Foundry ever again. The goal is not just having good code.
173
174
##### Abandoned or stale pull requests
175
176
If a pull request appears to be abandoned or stalled, it is polite to first check with the contributor to see if they intend to continue the work before checking if they would mind if you took it over (especially if it just has nits left). When doing so, it is courteous to give the original contributor credit for the work they started, either by preserving their name and e-mail address in the commit log, or by using the `Author: ` or `Co-authored-by: ` metadata tag in the commits.
177
178
_Adapted from the [ethers-rs contributing guide](https://github.com/gakonst/ethers-rs/blob/master/CONTRIBUTING.md)_.
179
180
### Releasing
181
182
Releases are automatically done by the release workflow when a tag is pushed, however, these steps still need to be taken:
183
184
1. Ensure that the versions in the relevant `Cargo.toml` files are up-to-date.
185
2. Update documentation links
186
3. Perform a final audit for breaking changes.
187
188
[rust-coc]: https://github.com/rust-lang/rust/blob/master/CODE_OF_CONDUCT.md
189
[dev-tg]: https://t.me/foundry_rs
190
[foundry-book]: https://github.com/foundry-rs/foundry-book
191
[support-tg]: https://t.me/foundry_support
192
[mcve]: https://stackoverflow.com/help/mcve
193
[hiding-a-comment]: https://help.github.com/articles/managing-disruptive-comments/#hiding-a-comment