]>
Commit | Line | Data |
---|---|---|
d11a429d AK |
1 | # Contributing to Cargo |
2 | ||
3 | Thank you for your interest in contributing to Cargo! Good places to | |
4 | start are this document, [ARCHITECTURE.md](ARCHITECTURE.md), which | |
47faa0f1 | 5 | describes the high-level structure of Cargo and [E-easy] bugs on the |
d11a429d AK |
6 | issue tracker. |
7 | ||
47faa0f1 | 8 | If you have a general question about Cargo or it's internals, feel free to ask |
e657f238 | 9 | on [Discord]. |
d11a429d | 10 | |
47faa0f1 LL |
11 | ## Code of Conduct |
12 | ||
13 | All contributors are expected to follow our [Code of Conduct]. | |
14 | ||
15 | ## Bug reports | |
16 | ||
17 | We can't fix what we don't know about, so please report problems liberally. This | |
18 | includes problems with understanding the documentation, unhelpful error messages | |
19 | and unexpected behavior. | |
20 | ||
21 | **If you think that you have identified an issue with Cargo that might compromise | |
22 | its users' security, please do not open a public issue on GitHub. Instead, | |
23 | we ask you to refer to Rust's [security policy].** | |
24 | ||
139c7503 EH |
25 | Opening an issue is as easy as following [this link][new-issues] and filling out |
26 | the fields. Here's a template that you can use to file an issue, though it's not | |
506786d0 | 27 | necessary to use it exactly: |
47faa0f1 LL |
28 | |
29 | <short summary of the problem> | |
30 | ||
31 | I tried this: <minimal example that causes the problem> | |
32 | ||
33 | I expected to see this happen: <explanation> | |
34 | ||
35 | Instead, this happened: <explanation> | |
36 | ||
37 | I'm using <output of `cargo --version`> | |
38 | ||
39 | All three components are important: what you did, what you expected, what | |
40 | happened instead. Please use https://gist.github.com/ if your examples run long. | |
d11a429d | 41 | |
9bed341d AK |
42 | |
43 | ## Feature requests | |
44 | ||
45 | Cargo follows the general Rust model of evolution. All major features go through | |
d3f118d4 DW |
46 | an RFC process. Therefore, before opening a feature request issue create a |
47 | Pre-RFC thread on the [internals][irlo] forum to get preliminary feedback. | |
48 | Implementing a feature as a [custom subcommand][subcommands] is encouraged as it | |
49 | helps demonstrate the demand for the functionality and is a great way to deliver | |
50 | a working solution faster as it can iterate outside of cargo's release cadence. | |
9bed341d | 51 | |
47faa0f1 | 52 | ## Working on issues |
d11a429d | 53 | |
139c7503 | 54 | If you're looking for somewhere to start, check out the [E-easy][E-Easy] and |
506786d0 | 55 | [E-mentor][E-mentor] tags. |
d11a429d | 56 | |
e657f238 | 57 | Feel free to ask for guidelines on how to tackle a problem on [Discord] or open a |
47faa0f1 LL |
58 | [new issue][new-issues]. This is especially important if you want to add new |
59 | features to Cargo or make large changes to the already existing code-base. | |
60 | Cargo's core developers will do their best to provide help. | |
61 | ||
62 | If you start working on an already-filed issue, post a comment on this issue to | |
63 | let people know that somebody is working it. Feel free to ask for comments if | |
64 | you are unsure about the solution you would like to submit. | |
65 | ||
66 | While Cargo does make use of some Rust-features available only through the | |
67 | `nightly` toolchain, it must compile on stable Rust. Code added to Cargo | |
68 | is encouraged to make use of the latest stable features of the language and | |
69 | `stdlib`. | |
70 | ||
71 | We use the "fork and pull" model [described here][development-models], where | |
72 | contributors push changes to their personal fork and create pull requests to | |
73 | bring those changes into the source repository. This process is partly | |
74 | automated: Pull requests are made against Cargo's master-branch, tested and | |
75 | reviewed. Once a change is approved to be merged, a friendly bot merges the | |
76 | changes into an internal branch, runs the full test-suite on that branch | |
77 | and only then merges into master. This ensures that Cargo's master branch | |
78 | passes the test-suite at all times. | |
79 | ||
80 | Your basic steps to get going: | |
81 | ||
82 | * Fork Cargo and create a branch from master for the issue you are working on. | |
83 | * Please adhere to the code style that you see around the location you are | |
84 | working on. | |
85 | * [Commit as you go][githelp]. | |
86 | * Include tests that cover all non-trivial code. The existing tests | |
87 | in `test/` provide templates on how to test Cargo's behavior in a | |
e70a3763 TN |
88 | sandbox-environment. The internal module `crates/cargo-test-support` provides a vast amount |
89 | of helpers to minimize boilerplate. See [`crates/cargo-test-support/src/lib.rs`] for an | |
139c7503 | 90 | introduction to writing tests. |
bfcc6d65 EH |
91 | * Make sure `cargo test` passes. See [Running tests](#running-tests) below |
92 | for details on running tests. | |
87770aee | 93 | * All code changes are expected to comply with the formatting suggested by `rustfmt`. |
bfcc6d65 EH |
94 | You can use `rustup component add rustfmt` to install `rustfmt` and use |
95 | `cargo fmt` to automatically format your code. | |
47faa0f1 LL |
96 | * Push your commits to GitHub and create a pull request against Cargo's |
97 | `master` branch. | |
98 | ||
bfcc6d65 EH |
99 | ## Running tests |
100 | ||
101 | Most of the tests are found in the `testsuite` integration test. This can be | |
102 | run with a simple `cargo test`. | |
103 | ||
104 | Some tests only run on the nightly toolchain, and will be ignored on other | |
105 | channels. It is recommended that you run tests with both nightly and stable to | |
106 | ensure everything is working as expected. | |
107 | ||
108 | Some tests exercise cross compiling to a different target. This will require | |
109 | you to install the appropriate target. This typically is the 32-bit target of | |
110 | your host platform. For example, if your host is a 64-bit | |
111 | `x86_64-unknown-linux-gnu`, then you should install the 32-bit target with | |
112 | `rustup target add i686-unknown-linux-gnu`. If you don't have the alternate | |
113 | target installed, there should be an error message telling you what to do. You | |
114 | may also need to install additional tools for the target. For example, on Ubuntu | |
115 | you should install the `gcc-multilib` package. | |
116 | ||
117 | If you can't install an alternate target, you can set the | |
118 | `CFG_DISABLE_CROSS_TESTS=1` environment variable to disable these tests. | |
119 | Unfortunately 32-bit support on macOS is going away, so you may not be able to | |
120 | run these tests on macOS. The Windows cross tests only support the MSVC | |
121 | toolchain. | |
122 | ||
123 | Some of the nightly tests require the `rustc-dev` component installed. This | |
124 | component includes the compiler as a library. This may already be installed | |
125 | with your nightly toolchain, but it if isn't, run `rustup component add | |
126 | rustc-dev --toolchain=nightly`. | |
127 | ||
128 | There are several other packages in the repo for running specialized tests, | |
129 | and you will need to run these tests separately by changing into its directory | |
130 | and running `cargo test`: | |
131 | ||
132 | * [`crates/resolver-tests`] – This package runs tests on the dependency resolver. | |
133 | * [`crates/cargo-platform`] – This is a standalone `cfg()` expression parser. | |
134 | ||
135 | The `build-std` tests are disabled by default, but you can run them by setting | |
136 | the `CARGO_RUN_BUILD_STD_TESTS=1` environment variable and running `cargo test | |
137 | --test build-std`. This requires the nightly channel, and also requires the | |
138 | `rust-src` component installed with `rustup component add rust-src | |
139 | --toolchain=nightly`. | |
140 | ||
141 | [`crates/resolver-tests`]: crates/resolver-tests | |
142 | [`crates/cargo-platform`]: crates/cargo-platform | |
143 | ||
47faa0f1 LL |
144 | ## Pull requests |
145 | ||
146 | After the pull request is made, a friendly bot will automatically assign a | |
147 | reviewer; the review-process will make sure that the proposed changes are | |
148 | sound. Please give the assigned reviewer sufficient time, especially during | |
e657f238 | 149 | weekends. If you don't get a reply, you may poke the core developers on [Discord]. |
d11a429d | 150 | |
47faa0f1 LL |
151 | A merge of Cargo's master-branch and your changes is immediately queued |
152 | to be tested after the pull request is made. In case unforeseen | |
f7c91ba6 | 153 | problems are discovered during this step (e.g., a failure on a platform you |
47faa0f1 LL |
154 | originally did not develop on), you may ask for guidance. Push additional |
155 | commits to your branch to tackle these problems. | |
100877b4 | 156 | |
47faa0f1 LL |
157 | The reviewer might point out changes deemed necessary. Please add them as |
158 | extra commits; this ensures that the reviewer can see what has changed since | |
159 | the code was previously reviewed. Large or tricky changes may require several | |
160 | passes of review and changes. | |
d11a429d | 161 | |
47faa0f1 LL |
162 | Once the reviewer approves your pull request, a friendly bot picks it up |
163 | and [merges][mergequeue] it into Cargo's `master` branch. | |
d11a429d | 164 | |
47faa0f1 LL |
165 | ## Contributing to the documentation |
166 | ||
bfcc6d65 EH |
167 | See the [documentation README](src/doc/README.md) for details on building the |
168 | documentation. | |
d11a429d | 169 | |
3bfc2ca2 CNG |
170 | ## Issue Triage |
171 | ||
47faa0f1 | 172 | Sometimes an issue will stay open, even though the bug has been fixed. And |
3bfc2ca2 CNG |
173 | sometimes, the original bug may go stale because something has changed in the |
174 | meantime. | |
175 | ||
176 | It can be helpful to go through older bug reports and make sure that they are | |
177 | still valid. Load up an older issue, double check that it's still true, and | |
178 | leave a comment letting us know if it is or is not. The [least recently | |
179 | updated sort][lru] is good for finding issues like this. | |
180 | ||
47faa0f1 LL |
181 | Contributors with sufficient permissions on the Rust-repository can help by |
182 | adding labels to triage issues: | |
3bfc2ca2 CNG |
183 | |
184 | * Yellow, **A**-prefixed labels state which **area** of the project an issue | |
185 | relates to. | |
186 | ||
187 | * Magenta, **B**-prefixed labels identify bugs which are **blockers**. | |
188 | ||
189 | * Light purple, **C**-prefixed labels represent the **category** of an issue. | |
986d78d7 AK |
190 | In particular, **C-feature-request** marks *proposals* for new features. If |
191 | an issue is **C-feature-request**, but is not **Feature accepted** or **I-nominated**, | |
192 | then it was not thoroughly discussed, and might need some additional design | |
193 | or perhaps should be implemented as an external subcommand first. Ping | |
194 | @rust-lang/cargo if you want to send a PR for such issue. | |
3bfc2ca2 CNG |
195 | |
196 | * Dark purple, **Command**-prefixed labels mean the issue has to do with a | |
197 | specific cargo command. | |
198 | ||
199 | * Green, **E**-prefixed labels explain the level of **experience** or | |
a9977f3c AK |
200 | **effort** necessary to fix the issue. [**E-mentor**][E-mentor] issues also |
201 | have some instructions on how to get started. | |
3bfc2ca2 CNG |
202 | |
203 | * Red, **I**-prefixed labels indicate the **importance** of the issue. The | |
463f207a | 204 | **[I-nominated][]** label indicates that an issue has been nominated for |
3bfc2ca2 CNG |
205 | prioritizing at the next triage meeting. |
206 | ||
207 | * Purple gray, **O**-prefixed labels are the **operating system** or platform | |
208 | that this issue is specific to. | |
209 | ||
210 | * Orange, **P**-prefixed labels indicate a bug's **priority**. These labels | |
463f207a | 211 | are only assigned during triage meetings and replace the **[I-nominated][]** |
3bfc2ca2 CNG |
212 | label. |
213 | ||
0cfe6355 CNG |
214 | * The light orange **relnotes** label marks issues that should be documented in |
215 | the release notes of the next release. | |
216 | ||
bfcc6d65 | 217 | * Dark blue, **Z**-prefixed labels are for unstable, nightly features. |
3bfc2ca2 | 218 | |
47faa0f1 LL |
219 | [githelp]: https://dont-be-afraid-to-commit.readthedocs.io/en/latest/git/commandlinegit.html |
220 | [development-models]: https://help.github.com/articles/about-collaborative-development-models/ | |
221 | [gist]: https://gist.github.com/ | |
222 | [new-issues]: https://github.com/rust-lang/cargo/issues/new | |
223 | [mergequeue]: https://buildbot2.rust-lang.org/homu/queue/cargo | |
224 | [security policy]: https://www.rust-lang.org/security.html | |
3bfc2ca2 | 225 | [lru]: https://github.com/rust-lang/cargo/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-asc |
47faa0f1 | 226 | [E-easy]: https://github.com/rust-lang/cargo/labels/E-easy |
a9977f3c | 227 | [E-mentor]: https://github.com/rust-lang/cargo/labels/E-mentor |
463f207a | 228 | [I-nominated]: https://github.com/rust-lang/cargo/labels/I-nominated |
47faa0f1 | 229 | [Code of Conduct]: https://www.rust-lang.org/conduct.html |
e657f238 | 230 | [Discord]: https://discordapp.com/invite/rust-lang |
bfcc6d65 | 231 | [`crates/cargo-test-support/src/lib.rs`]: crates/cargo-test-support/src/lib.rs |
9bed341d AK |
232 | [irlo]: https://internals.rust-lang.org/ |
233 | [subcommands]: https://doc.rust-lang.org/cargo/reference/external-tools.html#custom-subcommands |