From cc50cbf9ba67a1db9a2600dc43b2a88493966d87 Mon Sep 17 00:00:00 2001 From: shuimuliang Date: Tue, 17 Oct 2023 16:18:53 +0800 Subject: [PATCH] fix: ci, .gitignore and rust toolchain updates, lint fixes fix: according to the comments in pr7 ci: strict cargo test & cargo clippy ci: Lint for GitHub workflows build: specify rust target and toolchain for compilation fix: fix: cargo clippy warnings fix: cargo test warnings --- .github/workflows/rust.yaml | 4 ++-- .gitignore | 16 ++++++++++++++-- Cargo.lock | 4 ++-- rust-toolchain.toml | 5 +++++ src/backup.rs | 2 +- src/test/backup_and_restore.rs | 2 +- src/test/mod.rs | 2 +- 7 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 rust-toolchain.toml diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index 50b3d23..509c4f0 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -21,7 +21,7 @@ jobs: with: components: clippy - name: Lint - run: cargo clippy -- -D warnings + run: cargo clippy --all-targets --all-features -- -D warnings format: runs-on: ubuntu-latest @@ -45,4 +45,4 @@ jobs: submodules: true - uses: actions-rust-lang/setup-rust-toolchain@v1 - name: Tests - run: cargo test + run: cargo test --all-features diff --git a/.gitignore b/.gitignore index 0a5aebd..990e0ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -/target - # Test files /datacore /dataindex @@ -7,3 +5,17 @@ /dataldk1 /dataldk2 /tmp + +# will have compiled files and executables +/target + +# These are backup files generated by rustfmt +**/*.rs.bk + +# intellij files +.idea/ +.vscode/ + +# MaxOS files +.DS_Store +*.swp diff --git a/Cargo.lock b/Cargo.lock index f75678d..4ec99f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2444,9 +2444,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniscript" -version = "8.0.1" +version = "8.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fe8d0ee3580c650aadd33400cfe2a3004462dca6b921ca9e9cef4e654ebc404" +checksum = "e5f536c4b9b0868b37f4fb276758831fa93401f1fadc03447607f06ef4c72ee1" dependencies = [ "bitcoin 0.29.2", "serde", diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..f7b1400 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,5 @@ +[toolchain] +channel = "stable" +components = ["clippy", "rustfmt"] +targets = [] +profile = "minimal" diff --git a/src/backup.rs b/src/backup.rs index cfb8190..f3ef458 100644 --- a/src/backup.rs +++ b/src/backup.rs @@ -46,7 +46,7 @@ pub fn do_backup(wallet_dir: PathBuf, backup_path: &str, password: &str) -> Resu tracing::info!("starting backup..."); let backup_file = PathBuf::from(&backup_path); if backup_file.exists() { - return Err(APIError::InvalidBackupPath)?; + Err(APIError::InvalidBackupPath)?; } let tmp_base_path = _get_parent_path(&backup_file)?; let files = _get_backup_paths(&tmp_base_path)?; diff --git a/src/test/backup_and_restore.rs b/src/test/backup_and_restore.rs index ca2e22b..a06ca73 100644 --- a/src/test/backup_and_restore.rs +++ b/src/test/backup_and_restore.rs @@ -59,7 +59,7 @@ async fn backup_and_restore() { restore(node1_addr, &node1_backup_path, &node1_password).await; - let ignores = RegexSet::new(&[r"log*"]).unwrap(); + let ignores = RegexSet::new([r"log*"]).unwrap(); let cmp = dircmp::Comparison::new(ignores); let diff = cmp .compare(old_test_dir_node1_path, Path::new(&test_dir_node1)) diff --git a/src/test/mod.rs b/src/test/mod.rs index efac3c4..352a91d 100644 --- a/src/test/mod.rs +++ b/src/test/mod.rs @@ -114,7 +114,7 @@ fn get_ldk_sockets(peer_ports: &[u16]) -> Vec { async fn start_daemon(node_test_dir: &str, node_peer_port: u16) -> SocketAddr { let listener = TcpListener::bind("0.0.0.0:0".parse::().unwrap()).unwrap(); let node_address = listener.local_addr().unwrap(); - std::fs::create_dir_all(node_test_dir.clone()).unwrap(); + std::fs::create_dir_all(node_test_dir).unwrap(); let args = LdkUserInfo { storage_dir_path: node_test_dir.to_string(), ldk_peer_listening_port: node_peer_port,