Skip to content

ci: lint Rust dependencies using cargo deny - #7390

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

thomaseizinger merged 8 commits into
mainfrom
chore/cargo-deny

Conversation

@thomaseizinger

Copy link
Copy Markdown
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

vercel Bot commented Nov 21, 2024 •

Copy link
Copy Markdown

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 thread rust/deny.toml Outdated
Comment on lines 96 to 107

Copy link
Copy Markdown
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 thread rust/deny.toml Outdated
Comment on lines 214 to 269

Copy link
Copy Markdown
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.

Comment thread rust/deny.toml Outdated

Copy link
Copy Markdown
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.

Comment thread rust/Cargo.toml Outdated

Copy link
Copy Markdown
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.

@jamilbk jamilbk left a comment

Copy link
Copy Markdown
Member

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

This branch was successfully deployed

1 active deployment
Preview — b15db081 Deployed Nov 22, 2024 by vercel[bot]
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