From 042f601b58d95f950beeeb0a392ce34db532b020 Mon Sep 17 00:00:00 2001 From: Kyrylo Baibula <64193423+Velnbur@users.noreply.github.com> Date: Mon, 28 Oct 2024 10:38:21 +0200 Subject: [PATCH] :woman_technologist: Add CI check if code is formatted (#25) # :mag: Objective Currently, we don't check if the code in the repo is formatted. ## :new: Added New CI job that does that. --- .github/workflows/rust.yaml | 12 ++++++++++++ bitcoin-testscripts/src/u32mul.rs | 9 +++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index e6183f4..5dcbb1d 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -33,6 +33,18 @@ jobs: - name: Build run: cargo build --verbose + fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.rust_min }} + components: rustfmt + - uses: Swatinem/rust-cache@v2 + - name: Format + run: cargo fmt --check + clippy: name: clippy runs-on: ubuntu-latest diff --git a/bitcoin-testscripts/src/u32mul.rs b/bitcoin-testscripts/src/u32mul.rs index d037949..2b5b03f 100644 --- a/bitcoin-testscripts/src/u32mul.rs +++ b/bitcoin-testscripts/src/u32mul.rs @@ -77,7 +77,11 @@ impl SplitableScript<{ INPUT_SIZE }, { OUTPUT_SIZE }> for U32MulScript { impl U32MulScript { /// Splits the script into shards with a given chunk size - pub fn split_with_chunk_size(input: Script, split_type: SplitType, chunk_size: usize) -> SplitResult { + pub fn split_with_chunk_size( + input: Script, + split_type: SplitType, + chunk_size: usize, + ) -> SplitResult { Self::split(input, split_type, chunk_size) } } @@ -134,7 +138,8 @@ mod tests { let IOPair { input, output } = U32MulScript::generate_valid_io_pair(); // Splitting the script into shards - let split_result = U32MulScript::split_with_chunk_size(input, SplitType::ByInstructions, SPLIT_SIZE); + let split_result = + U32MulScript::split_with_chunk_size(input, SplitType::ByInstructions, SPLIT_SIZE); for shard in split_result.shards.iter() { println!("Shard: {:?}", shard.len());