feat(ci): run clippy on wasm target#2184
Conversation
|
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
|
I'm not sure we actually want to do this. It's natural to have parameters that become unused or other kinds of lints that trigger on a secondary platform, and handling this would pollute the code a lot more that it would help imho. For instance if we allow maybe_unused on stuff that isn't used only by wasm, it's error prone for native if every it really becomes unused, and forcing it be used by all platforms can be detrimental or require heavy refactor |
|
I still have to clean it up a bit but I'll soon push the lint fixes, it's not that bad actually and some of it gets fixed by your PRs For me the motivation is that we don't run tests for wasm so we should at least ensure it's lint free to try to catch bugs early. |
📚 Documentation Check Results📦
|
Clippy Allow Annotation ReportComparing clippy allow annotations between branches:
Summary by Rule
Annotation Counts by File
Annotation Stats by Crate
About This ReportThis report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality. |
🔒 Cargo Deny Results📦
|
| RUSTUP_TOOLCHAIN: ${{ steps.install-toolchain.outputs.version }} | ||
| run: | | ||
| # List of crates that are meant to be compilable for wasm. | ||
| WASM_ALLOWLIST="build_common cc_utils datadog-ffe datadog-ffe-test-suite datadog-ipc-macros datadog-sidecar-macros libdd-capabilities libdd-common libdd-data-pipeline libdd-ddsketch libdd-dogstatsd-client libdd-log libdd-otel-thread-ctx libdd-otel-thread-ctx-ffi libdd-profiling-protobuf libdd-remote-config libdd-sampling libdd-shared-runtime libdd-tinybytes libdd-trace-normalization libdd-trace-obfuscation libdd-trace-protobuf libdd-trace-stats libdd-trace-utils sidecar_mockgen" |
There was a problem hiding this comment.
How will we keep this in sync?
There was a problem hiding this comment.
Not sure honestly, the other idea I had instead of a fixed list would be to add a metadata field to each relevant crate's Cargo.toml to indicate if it should be compiling on wasm but that would add more complexity and I'm not even sure it solve the syncing problem, it just moves it to a per-crate toggle.
I'm open to suggestion if you have a better alternative in mind
| #[cfg(not(target_arch = "wasm32"))] | ||
| pub(crate) type WorkerRegistry = std::sync::Arc<Mutex<Vec<WorkerEntry>>>; | ||
| #[cfg(target_arch = "wasm32")] | ||
| pub(crate) type WorkerRegistry = std::rc::Rc<Mutex<Vec<WorkerEntry>>>; |
There was a problem hiding this comment.
Why do we need the mutex if single-threaded?
| // single-threaded and its workers are `!Send`, so `Rc` is both correct and avoids the | ||
| // `arc_with_non_send_sync` lint. | ||
| #[cfg(not(target_arch = "wasm32"))] | ||
| pub(crate) type WorkerRegistry = std::sync::Arc<Mutex<Vec<WorkerEntry>>>; |
There was a problem hiding this comment.
Will this pattern recur? Should this be a generic type?
What does this PR do?
A brief description of the change being made with this pull request.
Motivation
We don't run tests for wasm so we should at least ensure it's lint free to try to catch bugs early
Additional Notes
Anything else we should know when reviewing?
How to test the change?
Describe here in detail how the change can be validated.