ci: lint Rust dependencies using cargo deny#7390
Merged
thomaseizinger merged 8 commits intomainfrom Nov 22, 2024
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
50560de to
3cd7bc4
Compare
thomaseizinger
commented
Nov 21, 2024
Comment on lines
+96
to
+107
| "MIT", | ||
| "Apache-2.0", | ||
| "Apache-2.0 WITH LLVM-exception", | ||
| "BSD-2-Clause", | ||
| "BSD-3-Clause", | ||
| "MPL-2.0", | ||
| "ISC", | ||
| "0BSD", | ||
| "Unicode-DFS-2016", | ||
| "BSL-1.0", | ||
| "Zlib", | ||
| "OpenSSL", |
Member
Author
There was a problem hiding this comment.
These are all the licenses we currently depend on.
thomaseizinger
commented
Nov 21, 2024
Comment on lines
+214
to
+269
| "base64", | ||
| "bitflags", | ||
| "cocoa", | ||
| "cocoa-foundation", | ||
| "core-foundation", | ||
| "core-graphics", | ||
| "core-graphics-types", | ||
| "derive_more", | ||
| "getrandom", | ||
| "hashbrown", | ||
| "heck", | ||
| "hermit-abi", | ||
| "indexmap", | ||
| "itertools", | ||
| "itoa", | ||
| "libloading", | ||
| "nix", | ||
| "nu-ansi-term", | ||
| "phf", | ||
| "phf_codegen", | ||
| "phf_generator", | ||
| "phf_macros", | ||
| "phf_shared", | ||
| "proc-macro-crate", | ||
| "quick-xml", | ||
| "rand", | ||
| "rand_chacha", | ||
| "rand_core", | ||
| "raw-window-handle", | ||
| "regex-automata", | ||
| "regex-syntax", | ||
| "rustls", | ||
| "syn", | ||
| "sync_wrapper", | ||
| "tauri-winrt-notification", | ||
| "toml", | ||
| "toml_edit", | ||
| "tower", | ||
| "trackable", | ||
| "wasi", | ||
| "windows", | ||
| "windows-core", | ||
| "windows-implement", | ||
| "windows-interface", | ||
| "windows-result", | ||
| "windows-sys", | ||
| "windows-targets", | ||
| "windows_aarch64_gnullvm", | ||
| "windows_aarch64_msvc", | ||
| "windows_i686_gnu", | ||
| "windows_i686_msvc", | ||
| "windows_x86_64_gnu", | ||
| "windows_x86_64_gnullvm", | ||
| "windows_x86_64_msvc", | ||
| "winnow", | ||
| "winreg", |
Member
Author
There was a problem hiding this comment.
These are all currently duplicated dependencies.
thomaseizinger
commented
Nov 21, 2024
| unknown-registry = "warn" | ||
| # Lint level for what to happen when a crate from a git repository that is not | ||
| # in the allow list is encountered | ||
| unknown-git = "allow" |
Member
Author
There was a problem hiding this comment.
This is also different from the default config, normally git dependencies are banned but we make quite liberal use of them so I opted to set it to allow.
thomaseizinger
commented
Nov 21, 2024
| resolver = "2" | ||
|
|
||
| [workspace.package] | ||
| license = "Apache-2.0" |
Member
Author
There was a problem hiding this comment.
All our code is now explicitly licensed as Apache 2.0.
3cd7bc4 to
ad5d241
Compare
0516920 to
b15db08
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
One of Rust's promises is "if it compiles, it works". However, there are certain situations in which this isn't true. In particular, when using dynamic typing patterns where trait objects are downcast to concrete types, having two versions of the same dependency can silently break things.
This happened in #7379 where I forgot to patch a certain Sentry dependency. A similar problem exists with our
tracing-stackdriverdependency (see #7241).Lastly, duplicate dependencies increase the compile-times of a project, so we should aim for having as few duplicate versions of a particular dependency as possible in our dependency graph.
This PR introduces
cargo deny, a linter for Rust dependencies. In addition to linting for duplicate dependencies, it also enforces that all dependencies are compatible with an allow-list of licenses and it warns when a dependency is referred to from multiple crates without introducing a workspace dependency. Thanks to existing tooling (https://github.com/mainmatter/cargo-autoinherit), transitioning all dependencies to workspace dependencies was quite easy.Resolves: #7241.