ci: Improve and run clippy-wasm command
Lint more crates with it and enable more features. Also only allow web-time types.
This commit is contained in:
parent
7f562fe67e
commit
5ebe200bb6
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@ -181,6 +181,11 @@ jobs:
|
||||
cmd: clippy-all
|
||||
components: clippy
|
||||
|
||||
- name: Clippy WASM
|
||||
cmd: clippy-wasm
|
||||
targets: wasm32-unknown-unknown
|
||||
components: clippy
|
||||
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
@ -190,6 +195,7 @@ jobs:
|
||||
with:
|
||||
toolchain: ${{ env.NIGHTLY }}
|
||||
components: ${{ matrix.components }}
|
||||
targets: ${{ matrix.targets }}
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
|
25
.wasm/.clippy.toml
Normal file
25
.wasm/.clippy.toml
Normal file
@ -0,0 +1,25 @@
|
||||
avoid-breaking-exported-api = false
|
||||
disallowed-methods = [
|
||||
# https://github.com/serde-rs/json/issues/160
|
||||
"serde_json::from_reader",
|
||||
]
|
||||
disallowed-types = [
|
||||
"std::collections::HashMap",
|
||||
"std::collections::HashSet",
|
||||
{ path = "std::time::UNIX_EPOCH", reason = "Use web-time to return a UNIX_EPOCH that works under WASM" },
|
||||
{ path = "std::time::SystemTime", reason = "Use web-time to return a SystemTime that works under WASM" },
|
||||
{ path = "std::time::Instant", reason = "Use web-time to return an Instant that works under WASM" },
|
||||
]
|
||||
enforced-import-renames = [
|
||||
{ path = "serde_json::from_slice", rename = "from_json_slice" },
|
||||
{ path = "serde_json::from_str", rename = "from_json_str" },
|
||||
{ path = "serde_json::from_value", rename = "from_json_value" },
|
||||
{ path = "serde_json::to_value", rename = "to_json_value" },
|
||||
{ path = "serde_json::value::to_raw_value", rename = "to_raw_json_value" },
|
||||
{ path = "serde_json::value::RawValue", rename = "RawJsonValue" },
|
||||
{ path = "serde_json::Value", rename = "JsonValue" },
|
||||
]
|
||||
standard-macro-braces = [
|
||||
{ name = "quote", brace = "{" },
|
||||
{ name = "quote::quote", brace = "{" },
|
||||
]
|
@ -235,11 +235,8 @@ unstable-unspecified = [
|
||||
"ruma-push-gateway-api?/unstable-unspecified",
|
||||
]
|
||||
|
||||
# Private feature, only used in test / benchmarking code
|
||||
__ci = [
|
||||
"full",
|
||||
"compat-upload-signatures",
|
||||
"unstable-unspecified",
|
||||
# Private features, only used in test / benchmarking code
|
||||
__unstable-mscs = [
|
||||
"unstable-msc1767",
|
||||
"unstable-msc2409",
|
||||
"unstable-msc2448",
|
||||
@ -281,7 +278,13 @@ __ci = [
|
||||
"unstable-msc4108",
|
||||
"unstable-msc4121",
|
||||
"unstable-msc4125",
|
||||
"unstable-msc4140"
|
||||
"unstable-msc4140",
|
||||
]
|
||||
__ci = [
|
||||
"full",
|
||||
"compat-upload-signatures",
|
||||
"__unstable-mscs",
|
||||
"unstable-unspecified",
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
|
@ -60,7 +60,7 @@ pub enum CiCmd {
|
||||
NightlyAll,
|
||||
/// Lint default features with clippy (nightly)
|
||||
ClippyDefault,
|
||||
/// Lint ruma-common with clippy on a wasm target (nightly)
|
||||
/// Lint client features with clippy on a wasm target (nightly)
|
||||
ClippyWasm,
|
||||
/// Lint almost all features with clippy (nightly)
|
||||
ClippyAll,
|
||||
@ -289,17 +289,15 @@ impl CiTask {
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Lint ruma-common with clippy with the nightly version and wasm target.
|
||||
///
|
||||
/// ruma-common is currently the only crate with wasm-specific code. If that changes, this
|
||||
/// method should be updated.
|
||||
/// Lint ruma with clippy with the nightly version and wasm target.
|
||||
fn clippy_wasm(&self) -> Result<()> {
|
||||
cmd!(
|
||||
"
|
||||
rustup run {NIGHTLY} cargo clippy --target wasm32-unknown-unknown
|
||||
-p ruma-common --features api,js,rand
|
||||
rustup run {NIGHTLY} cargo clippy --target wasm32-unknown-unknown -p ruma --features
|
||||
__unstable-mscs,api,canonical-json,client-api,events,html-matrix,identity-service-api,js,markdown,rand,signatures,unstable-unspecified -- -D warnings
|
||||
"
|
||||
)
|
||||
.env("CLIPPY_CONF_DIR", ".wasm")
|
||||
.run()
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user