Skip to content

Commit

Permalink
ci: add clippy and fmt check to renamed rust.yaml workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
notmandatory committed Jan 7, 2025
1 parent 94c3997 commit 7331361
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 28 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Rust examples checks
on: [push, pull_request, workflow_dispatch]

jobs:
build_examples:
name: Build Rust examples
runs-on: ubuntu-latest
defaults:
run:
working-directory: examples/rust/
steps:
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/[email protected]
- name: "Build all examples"
run: cargo build

fmt_check:
name: Rust fmt check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
components: rustfmt
- name: Check fmt
run: cargo fmt --all -- --config format_code_in_doc_comments=true --check

clippy_check:
name: Rust clippy check
runs-on: ubuntu-latest
permissions:
checks: write
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
override: true
- name: Rust Cache
uses: Swatinem/[email protected]
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Clippy Results
args: --all-features --all-targets -- -D warnings
23 changes: 0 additions & 23 deletions .github/workflows/tests.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion examples/rust/descriptors/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use bdk_wallet::bitcoin::Network;
use bdk_wallet::template::{Bip86, DescriptorTemplate};
use bdk_wallet::KeychainKind;

fn main() -> () {
fn main() {
// --8<-- [start:main]
let mut seed: [u8; 32] = [0u8; 32];
rand::thread_rng().fill_bytes(&mut seed);
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/quickstart/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use bdk_wallet::Wallet;
const STOP_GAP: usize = 50;
const PARALLEL_REQUESTS: usize = 1;

fn main() -> () {
fn main() {
// --8<-- [start:descriptors]
let descriptor: &str = "tr([12071a7c/86'/1'/0']tpubDCaLkqfh67Qr7ZuRrUNrCYQ54sMjHfsJ4yQSGb3aBr1yqt3yXpamRBUwnGSnyNnxQYu7rqeBiPfw3mjBcFNX4ky2vhjj9bDrGstkfUbLB9T/0/*)#z3x5097m";
let change_descriptor: &str = "tr([12071a7c/86'/1'/0']tpubDCaLkqfh67Qr7ZuRrUNrCYQ54sMjHfsJ4yQSGb3aBr1yqt3yXpamRBUwnGSnyNnxQYu7rqeBiPfw3mjBcFNX4ky2vhjj9bDrGstkfUbLB9T/1/*)#n9r4jswr";
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/seed-phrase/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bdk_wallet::KeychainKind;
const RECOVERY_PHRASE: &str = "[your 12 word seed phrase here ...]";
// const RECOVERY_PHRASE: &str = "holiday marble tide globe license stumble rescue antenna monitor sea half sauce"; // example

fn main() -> () {
fn main() {
let mnemonic = Mnemonic::parse(RECOVERY_PHRASE).expect("Invalid seed! Be sure to replace the value of RECOVERY_PHRASE with your own 12 word seed phrase.");
let seed = mnemonic.to_seed("");
let xprv: Xpriv =
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/syncing/electrum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const BATCH_SIZE: usize = 5;
const EXTERNAL_DESCRIPTOR: &str = "tr(tprv8ZgxMBicQKsPdrjwWCyXqqJ4YqcyG4DmKtjjsRt29v1PtD3r3PuFJAjWytzcvSTKnZAGAkPSmnrdnuHWxCAwy3i1iPhrtKAfXRH7dVCNGp6/86'/1'/0'/0/*)#g9xn7wf9";
const INTERNAL_DESCRIPTOR: &str = "tr(tprv8ZgxMBicQKsPdrjwWCyXqqJ4YqcyG4DmKtjjsRt29v1PtD3r3PuFJAjWytzcvSTKnZAGAkPSmnrdnuHWxCAwy3i1iPhrtKAfXRH7dVCNGp6/86'/1'/0'/1/*)#e3rjrmea";

fn main() -> () {
fn main() {
let mut wallet: Wallet = Wallet::create(EXTERNAL_DESCRIPTOR, INTERNAL_DESCRIPTOR)
.network(Network::Signet)
.create_wallet_no_persist()
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/syncing/rpc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const COOKIE_FILE_PATH: &str = "<path_to_your_regtest_bitcoin_core_data_dir>/.co
const EXTERNAL_DESCRIPTOR: &str = "tr(tprv8ZgxMBicQKsPdrjwWCyXqqJ4YqcyG4DmKtjjsRt29v1PtD3r3PuFJAjWytzcvSTKnZAGAkPSmnrdnuHWxCAwy3i1iPhrtKAfXRH7dVCNGp6/86'/1'/0'/0/*)#g9xn7wf9";
const INTERNAL_DESCRIPTOR: &str = "tr(tprv8ZgxMBicQKsPdrjwWCyXqqJ4YqcyG4DmKtjjsRt29v1PtD3r3PuFJAjWytzcvSTKnZAGAkPSmnrdnuHWxCAwy3i1iPhrtKAfXRH7dVCNGp6/86'/1'/0'/1/*)#e3rjrmea";

fn main() -> () {
fn main() {
let mut wallet: Wallet = Wallet::create(EXTERNAL_DESCRIPTOR, INTERNAL_DESCRIPTOR)
.network(Network::Regtest)
.create_wallet_no_persist()
Expand Down

0 comments on commit 7331361

Please sign in to comment.