Skip to content

Commit 46e1ab7

Browse files
committed
Merge #235: CI: Update continous_integration and audit workflows
aba4b95 CI: Fix clippy issues (Vihiga Tyonum) cc3c8a2 ci: Update audit workflow and `bytes` dependency (Vihiga Tyonum) e39e59c ci: add prepush checks that mirrors ci workflow (Vihiga Tyonum) e849f8e chore: fix clippy warnings (Vihiga Tyonum) 8d20cf2 ci: update cont_integration workflow (Vihiga Tyonum) Pull request description: <!-- You can erase any parts of this template not applicable to your Pull Request. --> ### Description This PR updates the continuous integration workflow and fixes some Clippy issues. Also fixes #239 <!-- Describe the purpose of this PR, what's being adding and/or fixed --> ### Notes to the reviewers <!-- In this section you can include notes directed to the reviewers, like explaining why some parts of the PR were done in a specific way --> - update `actions/checkout` to v6 - add a separate job for Clippy - automate manual caching in the `build-test` job - replace `actions-r/toolchain` with `actions-rust- lang/setup-rust-toolchain` for toolchain setup -fix clippy warnings - add prepush command to Justfile - Add `tool-version` parameter in audit workflow that forces the `actions-rust-lang/audit` to use a version that supports CVSS 4.0 - update transitive dependency `bytes` to v1.11.1 ## Changelog notice <!-- Notice the release manager should include in the release tag message changelog --> <!-- See https://keepachangelog.com/en/1.0.0/ for examples --> ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk-cli/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing Top commit has no ACKs. Tree-SHA512: 24ac0771d7e14ea54137fa355b84328bbc0a36c3ab3602f9e07062fca348642e44c2cfca10103a78edf3564618db4111700ac89e0967464dd9a084966373a474
2 parents 368b8b4 + aba4b95 commit 46e1ab7

File tree

8 files changed

+79
-36
lines changed

8 files changed

+79
-36
lines changed

.github/workflows/audit.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ jobs:
1313
security_audit:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v6
1717
- uses: actions-rust-lang/audit@v1
1818
with:
1919
token: ${{ secrets.GITHUB_TOKEN }}
20+
tool-version: 0.22.1

.github/workflows/cont_integration.yml

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ on: [push, pull_request]
22

33
name: CI
44

5+
permissions:
6+
contents: read
7+
env:
8+
CARGO_TERM_COLOR: always
59
jobs:
610

711
build-test:
@@ -17,30 +21,41 @@ jobs:
1721
- --all-features
1822
steps:
1923
- name: Checkout
20-
uses: actions/checkout@v4
21-
- name: Generate cache key
22-
run: echo "${{ matrix.rust }} ${{ matrix.features }}" | tee .cache_key
23-
- name: Cache
24-
uses: actions/cache@v4
25-
with:
26-
path: |
27-
~/.cargo/registry
28-
~/.cargo/git
29-
target
30-
key: ${{ runner.os }}-cargo-${{ hashFiles('.cache_key') }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
24+
uses: actions/checkout@v6
3125
- name: Setup Rust Toolchain
32-
uses: actions-rs/toolchain@v1
26+
uses: actions-rust-lang/setup-rust-toolchain@v1
3327
with:
3428
toolchain: ${{ matrix.rust }}
3529
profile: minimal
3630
override: true
3731
components: rustfmt, clippy
32+
cache: true
3833
- name: Build
3934
run: cargo build ${{ matrix.features }}
40-
- name: Clippy
41-
run: cargo clippy -- -D warnings
4235
- name: Test
4336
run: cargo test ${{ matrix.features }}
37+
clippy:
38+
name: Clippy (${{ matrix.features }})
39+
runs-on: ubuntu-latest
40+
strategy:
41+
matrix:
42+
features:
43+
- --no-default-features
44+
- --all-features
45+
steps:
46+
- name: Checkout
47+
uses: actions/checkout@v6
48+
49+
- name: Install Rust toolchain
50+
uses: actions-rust-lang/setup-rust-toolchain@v1
51+
with:
52+
toolchain: stable
53+
profile: minimal
54+
override: true
55+
components: clippy
56+
cache: true
57+
- name: Run Clippy
58+
run: cargo clippy ${{ matrix.features }} --all-targets -- -D warnings
4459

4560
# TODO: fix or remove this
4661
# wasm-build:
@@ -82,13 +97,14 @@ jobs:
8297
runs-on: ubuntu-latest
8398
steps:
8499
- name: Checkout
85-
uses: actions/checkout@v4
100+
uses: actions/checkout@v6
86101
- name: Setup Rust Toolchain
87-
uses: actions-rs/toolchain@v1
102+
uses: actions-rust-lang/setup-rust-toolchain@v1
88103
with:
89104
toolchain: stable
90105
profile: minimal
91106
override: true
92107
components: rustfmt, clippy
108+
cache: true
93109
- name: Check fmt
94110
run: cargo fmt --all -- --check

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Justfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ build: fmt
2525
test:
2626
cargo test --all-features --tests
2727

28+
# checks before pushing
29+
pre-push:
30+
cargo test --features default
31+
cargo test --no-default-features
32+
cargo test --all-features
33+
cargo clippy --no-default-features --all-targets -- -D warnings
34+
cargo clippy --all-features --all-targets -- -D warnings
35+
cargo fmt --all -- --check
36+
2837
# clean the project target directory
2938
clean:
3039
cargo clean

src/error.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ pub enum BDKCliError {
5959

6060
#[cfg(feature = "sqlite")]
6161
#[error("Rusqlite error: {0}")]
62-
RusqliteError(#[from] bdk_wallet::rusqlite::Error),
62+
RusqliteError(Box<bdk_wallet::rusqlite::Error>),
6363

6464
#[cfg(feature = "redb")]
6565
#[error("Redb StoreError: {0}")]
66-
RedbStoreError(#[from] bdk_redb::error::StoreError),
66+
RedbStoreError(Box<bdk_redb::error::StoreError>),
6767

6868
#[cfg(feature = "redb")]
6969
#[error("Redb dabtabase error: {0}")]
70-
RedbDatabaseError(#[from] bdk_redb::redb::DatabaseError),
70+
RedbDatabaseError(Box<bdk_redb::redb::DatabaseError>),
7171

7272
#[error("Serde json error: {0}")]
7373
SerdeJson(#[from] serde_json::Error),
@@ -147,3 +147,24 @@ impl From<ExtractTxError> for BDKCliError {
147147
BDKCliError::PsbtExtractTxError(Box::new(value))
148148
}
149149
}
150+
151+
#[cfg(feature = "redb")]
152+
impl From<bdk_redb::error::StoreError> for BDKCliError {
153+
fn from(err: bdk_redb::error::StoreError) -> Self {
154+
BDKCliError::RedbStoreError(Box::new(err))
155+
}
156+
}
157+
158+
#[cfg(feature = "redb")]
159+
impl From<bdk_redb::redb::DatabaseError> for BDKCliError {
160+
fn from(err: bdk_redb::redb::DatabaseError) -> Self {
161+
BDKCliError::RedbDatabaseError(Box::new(err))
162+
}
163+
}
164+
165+
#[cfg(feature = "sqlite")]
166+
impl From<bdk_wallet::rusqlite::Error> for BDKCliError {
167+
fn from(err: bdk_wallet::rusqlite::Error) -> Self {
168+
BDKCliError::RusqliteError(Box::new(err))
169+
}
170+
}

src/handlers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,7 @@ pub fn handle_wallets_subcommand(datadir: &Path, pretty: bool) -> Result<String,
11561156
.wallets
11571157
.iter()
11581158
.map(|(name, wallet_config)| {
1159+
#[allow(unused_mut)]
11591160
let mut wallet_json = json!({
11601161
"name": name,
11611162
"network": wallet_config.network,

src/payjoin/mod.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<'a> PayjoinManager<'a> {
7575
let persister = payjoin::persist::NoopSessionPersister::<ReceiverSessionEvent>::default();
7676

7777
let checked_max_fee_rate = max_fee_rate
78-
.map(|rate| FeeRate::from_sat_per_kwu(rate))
78+
.map(FeeRate::from_sat_per_kwu)
7979
.unwrap_or(FeeRate::BROADCAST_MIN);
8080

8181
let receiver = payjoin::receive::v2::ReceiverBuilder::new(
@@ -275,7 +275,7 @@ impl<'a> PayjoinManager<'a> {
275275
.await
276276
}
277277
ReceiveSession::HasReplyableError(error) => self.handle_error(error, persister).await,
278-
ReceiveSession::Closed(_) => return Err(Error::Generic("Session closed".to_string())),
278+
ReceiveSession::Closed(_) => Err(Error::Generic("Session closed".to_string())),
279279
}
280280
}
281281

@@ -305,8 +305,7 @@ impl<'a> PayjoinManager<'a> {
305305
}
306306
Err(e) => {
307307
return Err(Error::Generic(format!(
308-
"Error occurred when polling for Payjoin proposal from the directory: {}",
309-
e.to_string()
308+
"Error occurred when polling for Payjoin proposal from the directory: {e}"
310309
)));
311310
}
312311
}
@@ -609,16 +608,12 @@ impl<'a> PayjoinManager<'a> {
609608
return Err(ImplementationError::from("Cannot find the transaction in the mempool or the blockchain"));
610609
};
611610

612-
let is_seen = match tx_details.chain_position {
613-
bdk_wallet::chain::ChainPosition::Confirmed { .. } => true,
614-
bdk_wallet::chain::ChainPosition::Unconfirmed { first_seen: Some(_), .. } => true,
615-
_ => false
616-
};
611+
let is_seen = matches!(tx_details.chain_position, bdk_wallet::chain::ChainPosition::Confirmed { .. } | bdk_wallet::chain::ChainPosition::Unconfirmed { first_seen: Some(_), .. });
617612

618613
if is_seen {
619614
return Ok(Some(tx_details.tx.as_ref().clone()));
620615
}
621-
return Err(ImplementationError::from("Cannot find the transaction in the mempool or the blockchain"));
616+
Err(ImplementationError::from("Cannot find the transaction in the mempool or the blockchain"))
622617
},
623618
|outpoint| {
624619
let utxo = self.wallet.get_utxo(outpoint);

src/utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub(crate) enum BlockchainClient {
158158
},
159159

160160
#[cfg(feature = "cbf")]
161-
KyotoClient { client: KyotoClientHandle },
161+
KyotoClient { client: Box<KyotoClientHandle> },
162162
}
163163

164164
/// Handle for the Kyoto client after the node has been started.
@@ -195,7 +195,7 @@ pub(crate) fn new_blockchain_client(
195195
}
196196
#[cfg(feature = "esplora")]
197197
ClientType::Esplora => {
198-
let client = bdk_esplora::esplora_client::Builder::new(&url).build_async()?;
198+
let client = bdk_esplora::esplora_client::Builder::new(url).build_async()?;
199199
BlockchainClient::Esplora {
200200
client: Box::new(client),
201201
parallel_requests: wallet_opts.parallel_requests,
@@ -245,10 +245,10 @@ pub(crate) fn new_blockchain_client(
245245
);
246246

247247
BlockchainClient::KyotoClient {
248-
client: KyotoClientHandle {
248+
client: Box::new(KyotoClientHandle {
249249
requester,
250250
update_subscriber: tokio::sync::Mutex::new(update_subscriber),
251-
},
251+
}),
252252
}
253253
}
254254
};

0 commit comments

Comments
 (0)