-
Notifications
You must be signed in to change notification settings - Fork 2.6k
docs(contrib): Describe how to add a new package #12878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# New Packages | ||
|
||
This chapter sketches out how to add a new package to the cargo workspace. | ||
|
||
## Steps | ||
|
||
Choose the relevant parent directory | ||
- `credential/` for credential-process related packages | ||
- `benches/` for benchmarking of cargo itself | ||
- `crates/` for everything else | ||
|
||
Run `cargo new <name>` | ||
- `<name>`: | ||
- We tend to use `-` over `_` | ||
- For internal APIs, to avoid collisions with third-party subcommands, we can use the `cargo-util-` prefix | ||
- For xtasks, we use the `xtask-` prefix | ||
- `package.rust-version` | ||
- Internal packages tend to have a policy of "latest" with a [`# MSRV:1` comment](#msrv-policy) | ||
- Ecosystem packages tend to have a policy of "N-2" with a [`# MSRV:3` comment](#msrv-policy) | ||
- If the right choice is inherited from the workspace, feel free to keep it that way | ||
- If running without [cargo new automatically adding to workspace](https://github.com/rust-lang/cargo/pull/12779), add it as a workspace member if not already captured by a glob | ||
|
||
If its an xtask, | ||
- Add it to `.cargo/config.toml`s `[alias]` table | ||
- Mark `package.publish = false` | ||
|
||
If needed to be published with `cargo`, | ||
add the package to `publish.py` in the repo root, | ||
in dependency order. | ||
|
||
Note: by adding the package to the workspace, you automatically get | ||
- CI running `cargo test` | ||
- CI verifying MSRV | ||
- CI checking for `cargo doc` warnings | ||
|
||
## MSRV Policy | ||
|
||
Our MSRV policies are | ||
- Internal packages: support latest version | ||
- Ecosystem packages: support latest 3 versions | ||
|
||
We proactively update the MSRV | ||
- So contributors don't shy away from using newer features, either assuming they | ||
can't ask or feeling like they have to have a justification when asking | ||
- To avoid a de facto MSRV developing from staying on a version for a long | ||
period of time, leaving users unhappy when their expectations aren't met | ||
|
||
To proactively update the MSRV, we use [RenovateBot](https://docs.renovatebot.com/) | ||
with the configuration file in `.github/renovatebot.json5`. | ||
To know what MSRV policy to use, | ||
it looks for comments of the form `# MSRV:N`, | ||
where `N` is the number of supported rust versions. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.