From f6b90f52b33b331fd898fea68ccf91a43c6bfacc Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Thu, 8 Aug 2024 17:43:25 +0200 Subject: [PATCH] Extend CI checks This patch adds clippy and rustfmt to the CI and fails the workflow if cargo doc shows a warning. --- .github/workflows/ci.yml | 13 +++++++++++-- src/driver.rs | 42 ---------------------------------------- src/tests.rs | 2 +- 3 files changed, 12 insertions(+), 45 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0752a2223..b7e76f4fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,11 +39,20 @@ jobs: - name: Build run: cargo build --release --verbose + - name: Run clippy + if: matrix.target == 'x86_64-unknown-linux-gnu' + run: cargo clippy --all-features --all-targets -- --deny warnings + + - name: Check code format + if: matrix.target == 'x86_64-unknown-linux-gnu' + run: cargo fmt -- --check + - name: Run tests if: matrix.target == 'x86_64-unknown-linux-gnu' run: > cargo test && cargo test --release - - name: Build Documentation - run: cargo doc --no-deps + - name: Check documentation + if: matrix.target == 'x86_64-unknown-linux-gnu' + run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps diff --git a/src/driver.rs b/src/driver.rs index 942860822..52c896c2c 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -2,7 +2,6 @@ #![allow(non_camel_case_types)] use generic_array::ArrayLength; -use littlefs2_sys as ll; use crate::io::Result; @@ -94,44 +93,3 @@ pub trait Storage { // /// Synchronize writes to the storage device. // fn sync(&mut self) -> Result; } - -// in the future, try to split the megatrait `Storage` into pieces -// like this? -mod future { - // content of "superblock" - pub trait DiskFormat { - // version, upper/lower half-word contain major/minor - // const DISK_FORMAT_VERSION: u32, - - // block_size, block_count - const BLOCK_SIZE: usize; - const BLOCK_COUNT: usize; - - // name_max, file_max, attr_max - type FILENAME_MAX_PLUS_ONE; - const FILEBYTES_MAX: usize = super::ll::LFS_FILE_MAX as _; - type ATTRBYTES_MAX; - } - - pub trait Driver { - const READ_SIZE: usize; - const WRITE_SIZE: usize; - - const BLOCK_SIZE: usize; - const BLOCK_COUNT: usize; - - // fn read(&self, offset: usize, buf: &mut [u8]) -> Result; - // fn write(&mut self, offset: usize, data: &[u8]) -> Result; - // fn erase(&mut self, offset: usize, len: usize) -> Result; - } - - pub trait MemoryUsage { - // TODO: this supposedly influences whether files are inlined or not. Clarify - type CACHE_SIZE; - type LOOKAHEADWORDS_SIZE; - } - - pub trait RuntimeParameters { - const BLOCK_CYCLES: isize = -1; - } -} diff --git a/src/tests.rs b/src/tests.rs index 8a63139af..781ab7bce 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -474,7 +474,7 @@ fn test_iter_dirs() { let mut storage = RamStorage::new(&mut backend); Filesystem::format(&mut storage).unwrap(); Filesystem::mount_and_then(&mut storage, |fs| { - fs.create_dir(path!("/tmp").into())?; + fs.create_dir(path!("/tmp"))?; // TODO: we might want "multi-open" fs.create_file_and_then(path!("/tmp/file.a"), |file| {