Skip to content

Commit

Permalink
Merge pull request #463 from CosmWasm/increase-clippy-testing
Browse files Browse the repository at this point in the history
Create separate libwasmvm_clippy CI job and test more recent clippy versions
  • Loading branch information
webmaster128 authored Oct 12, 2023
2 parents 738c647 + 4e90c05 commit b116c86
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
44 changes: 39 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
command: rustc --version; cargo --version; rustup --version
- run:
name: Add Rust components
command: rustup component add clippy rustfmt
command: rustup component add rustfmt
- restore_cache:
keys:
- cargocache-v3-libwasmvm_sanity-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}
Expand All @@ -39,10 +39,6 @@ jobs:
name: Check Rust formatting
working_directory: libwasmvm
command: cargo fmt -- --check
- run:
name: Run linter
working_directory: libwasmvm
command: cargo clippy --all-targets -- -D warnings
- run:
name: Run unit tests
working_directory: libwasmvm
Expand All @@ -68,6 +64,39 @@ jobs:
- libwasmvm/target/release/deps
key: cargocache-v3-libwasmvm_sanity-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}

libwasmvm_clippy:
parameters:
rust-version:
type: string
docker:
- image: rust:<< parameters.rust-version >>
steps:
- checkout
- run:
name: Version information
command: rustc --version && cargo --version
- restore_cache:
keys:
- v3-libwasmvm_clippy-rust:<< parameters.rust-version >>-{{ checksum "libwasmvm/Cargo.lock" }}
- v3-libwasmvm_clippy-rust:<< parameters.rust-version >>-
- run:
name: Add clippy component
command: rustup component add clippy
- run:
name: Run clippy
working_directory: libwasmvm
command: cargo clippy --all-targets -- -D warnings
- save_cache:
paths:
- ~/.cargo/registry
- libwasmvm/target/debug/.fingerprint
- libwasmvm/target/debug/build
- libwasmvm/target/debug/deps
- libwasmvm/target/release/.fingerprint
- libwasmvm/target/release/build
- libwasmvm/target/release/deps
key: v3-libwasmvm_clippy-rust:<< parameters.rust-version >>-{{ checksum "libwasmvm/Cargo.lock" }}

# This performs all the Rust debug builds on Windows. Similar to libwasmvm_sanity
# but avoids duplicating things that are not platform dependent.
libwasmvm_sanity_windows:
Expand Down Expand Up @@ -387,6 +416,11 @@ workflows:
- libwasmvm_sanity
# Temporarily disabled. This check is still running on main.
# - libwasmvm_sanity_windows
- libwasmvm_clippy:
matrix:
parameters:
# Run with MSRV and some modern stable Rust
rust-version: ["1.67.0", "1.73.0"]
- libwasmvm_audit
- format-go
- wasmvm_no_cgo
Expand Down
5 changes: 2 additions & 3 deletions libwasmvm/src/error/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,8 @@ mod tests {

#[test]
fn from_std_str_utf8error_works() {
let error: RustError = str::from_utf8(b"Hello \xF0\x90\x80World")
.unwrap_err()
.into();
let broken = b"Hello \xF0\x90\x80World";
let error: RustError = str::from_utf8(broken).unwrap_err().into();
match error {
RustError::InvalidUtf8 { msg, .. } => {
assert_eq!(msg, "invalid utf-8 sequence of 3 bytes from index 6")
Expand Down

0 comments on commit b116c86

Please sign in to comment.