diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ec1fb1f..019fba6 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -4,41 +4,33 @@ on: [push, pull_request] jobs: build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Install latest nightly - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - components: rustfmt, clippy, llvm-tools-preview - - - name: Install lcov - run: sudo apt-get install lcov - - - name: install grcov - run: cargo install grcov - - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Run grcov - env: - PROJECT_NAME: "havocompare" - RUSTFLAGS: "-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" - CARGO_INCREMENTAL: 0 - run: | - cargo +nightly build --verbose - cargo +nightly test --verbose - grcov . -s . --binary-path ./target/debug/ -t lcov --llvm --branch --ignore-not-existing --ignore="/*" --ignore="target/*" --ignore="tests/*" -o lcov.info - - - name: Push grcov results to Coveralls via GitHub Action - uses: coverallsapp/github-action@v2 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - file: "lcov.info" - + - uses: actions/checkout@v4 + - name: Install latest stable + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt, clippy, llvm-tools-preview + + - name: Install lcov + run: sudo apt-get install lcov + + - name: install grcov + run: cargo install grcov + + - name: Run grcov + env: + PROJECT_NAME: "havocompare" + RUSTFLAGS: "-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off" + CARGO_INCREMENTAL: 0 + run: | + cargo +stable build --verbose + cargo +stable test --verbose + grcov . -s . --binary-path ./target/debug/ -t lcov --llvm --branch --ignore-not-existing --ignore="/*" --ignore="target/*" --ignore="tests/*" -o lcov.info + + - name: Push grcov results to Coveralls via GitHub Action + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + file: "lcov.info" diff --git a/.gitignore b/.gitignore index 8ff0eb3..846f461 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ /target .idea Cargo.lock +.vscode/ +.zed/ +report/ +*.jpgdiff_image.png diff --git a/Cargo.toml b/Cargo.toml index 9c38cbb..afb12e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,8 +4,9 @@ description = "A flexible rule-based file and folder comparison tool and crate i repository = "https://github.com/VolumeGraphics/havocompare" homepage = "https://github.com/VolumeGraphics/havocompare" documentation = "https://docs.rs/havocompare" -version = "0.8.0" +version = "0.9.0-alpha.1" edition = "2021" +rust-version = "1.85" license = "MIT" authors = ["Volume Graphics GmbH"] exclude = ["tests/pdf", "tests/integ", "tests/html", "target", "tests/csv", ".github", "test_report"] diff --git a/README.md b/README.md index aac83a6..2f93956 100644 --- a/README.md +++ b/README.md @@ -326,6 +326,13 @@ rules: ## Changelog +### 0.9.0 + +- **Breaking**: Minimum supported Rust version (MSRV) is now 1.85 +- Internal/CI: + - Switch GitHub CI from `nightly` to `stable` Rust toolchain + - Fix clippy warnings for Rust 1.93+ + ### 0.8.0 - Report will always be generated even though compare is failing. diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..85f3606 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "stable" +components = ["rustfmt", "clippy"] +profile = "minimal" diff --git a/src/csv/mod.rs b/src/csv/mod.rs index 9a4485d..89d47d4 100644 --- a/src/csv/mod.rs +++ b/src/csv/mod.rs @@ -313,13 +313,13 @@ impl Table { Ok(Table { columns: cols }) } - pub(crate) fn rows(&self) -> RowIterator { + pub(crate) fn rows(&self) -> RowIterator<'_> { RowIterator { position: self.columns.iter().map(|c| c.rows.iter()).collect(), } } - pub(crate) fn rows_mut(&mut self) -> RowIteratorMut { + pub(crate) fn rows_mut(&mut self) -> RowIteratorMut<'_> { RowIteratorMut { position: self.columns.iter_mut().map(|c| c.rows.iter_mut()).collect(), } diff --git a/src/csv/tokenizer/mod.rs b/src/csv/tokenizer/mod.rs index ee8c1f4..5d8fbca 100644 --- a/src/csv/tokenizer/mod.rs +++ b/src/csv/tokenizer/mod.rs @@ -187,7 +187,7 @@ pub(crate) struct Parser { delimiters: Delimiters, } -fn tokenize(input: &str, field_sep: char) -> Result, Error> { +fn tokenize(input: &str, field_sep: char) -> Result>, Error> { let mut tokens = Vec::new(); let mut pos = 0; while let Some(remainder) = &input.get(pos..) { @@ -228,7 +228,7 @@ fn parse_literal( field_sep: char, remainder: &str, literal_type: LiteralTerminator, -) -> Result<(usize, Token, bool), Error> { +) -> Result<(usize, Token<'_>, bool), Error> { let terminator_len = literal_type.get_char().len_utf8(); let after_first_quote = &remainder[terminator_len..]; let quote_end = diff --git a/src/csv/value.rs b/src/csv/value.rs index e9be707..db70c21 100644 --- a/src/csv/value.rs +++ b/src/csv/value.rs @@ -88,10 +88,10 @@ impl Display for Value { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match &self { Value::Quantity(val) => { - write!(f, "{val}").unwrap(); + let _ = write!(f, "{val}"); } Value::String(val) => { - write!(f, "'{val}'").unwrap(); + let _ = write!(f, "'{val}'"); } } Ok(()) @@ -143,7 +143,7 @@ impl Value { } } - pub fn as_str(&self) -> Cow { + pub fn as_str(&self) -> Cow<'_, str> { match self { Value::String(str) => str.as_str().into(), Value::Quantity(quant) => quant.to_string().into(), diff --git a/src/lib.rs b/src/lib.rs index 103532a..44e6450 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -117,7 +117,7 @@ pub enum ComparisonMode { Directory(DirectoryConfig), } -fn get_file_name(path: &Path) -> Option> { +fn get_file_name(path: &Path) -> Option> { path.file_name().map(|f| f.to_string_lossy()) } diff --git a/src/report/mod.rs b/src/report/mod.rs index 697a347..5abca70 100644 --- a/src/report/mod.rs +++ b/src/report/mod.rs @@ -411,7 +411,7 @@ pub fn write_image_detail( ctx.insert("actual", &actual.as_ref().to_string_lossy()); ctx.insert("nominal", &nominal.as_ref().to_string_lossy()); - fn get_file_name(path: &Path) -> Result, Error> { + fn get_file_name(path: &Path) -> Result, Error> { path.file_name() .map(|f| f.to_string_lossy()) .ok_or_else(|| { @@ -612,11 +612,7 @@ pub fn write_error_detail( errors: &[&String], report_dir: impl AsRef, ) -> Option { - if let Ok(sub_folder) = create_error_detail(nominal, actual, errors, report_dir) { - Some(sub_folder) - } else { - None - } + create_error_detail(nominal, actual, errors, report_dir).ok() } pub(crate) fn create_reports(