Skip to content

ci: lint Rust dependencies using cargo deny#7390

Merged
thomaseizinger merged 8 commits intomainfrom
chore/cargo-deny
Nov 22, 2024
Merged

ci: lint Rust dependencies using cargo deny#7390
thomaseizinger merged 8 commits intomainfrom
chore/cargo-deny

Conversation

@thomaseizinger
Copy link
Member

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-stackdriver dependency (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.

@vercel
Copy link

vercel bot commented Nov 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 22, 2024 0:03am

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",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all the licenses we currently depend on.

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",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all currently duplicated dependencies.

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"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

resolver = "2"

[workspace.package]
license = "Apache-2.0"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All our code is now explicitly licensed as Apache 2.0.

Copy link
Member

@jamilbk jamilbk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦀

@thomaseizinger thomaseizinger added this pull request to the merge queue Nov 22, 2024
Merged via the queue into main with commit 2c26fc9 Nov 22, 2024
@thomaseizinger thomaseizinger deleted the chore/cargo-deny branch November 22, 2024 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ban duplicates of opentelemetry dependency using cargo deny

2 participants