From 075510d6e452522bef113568a895233ffc229410 Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Mon, 25 Jul 2022 12:52:23 -0700 Subject: [PATCH 1/3] Add github workflows for audit, test and fmt --- .github/workflows/audit.yml | 19 ++++++++ .github/workflows/cont_integration.yml | 61 ++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 .github/workflows/audit.yml create mode 100644 .github/workflows/cont_integration.yml diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml new file mode 100644 index 0000000..6143cca --- /dev/null +++ b/.github/workflows/audit.yml @@ -0,0 +1,19 @@ +name: Audit + +on: + push: + paths: + - '**/Cargo.toml' + - '**/Cargo.lock' + schedule: + - cron: '0 0 * * 0' # Once per week + +jobs: + + security_audit: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/audit-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/cont_integration.yml b/.github/workflows/cont_integration.yml new file mode 100644 index 0000000..40c5e97 --- /dev/null +++ b/.github/workflows/cont_integration.yml @@ -0,0 +1,61 @@ +on: [push, pull_request] + +name: CI + +jobs: + + build-test: + name: Build and test + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - version: 1.60.0 # STABLE + clippy: true + - version: 1.56.1 # MSRV + steps: + - name: checkout + uses: actions/checkout@v2 + - name: Generate cache key + run: echo "${{ matrix.rust.version }} ${{ matrix.features }}" | tee .cache_key + - name: cache + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('.cache_key') }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} + - name: Set default toolchain + run: rustup default ${{ matrix.rust.version }} + - name: Set profile + run: rustup set profile minimal + - name: Add clippy + if: ${{ matrix.rust.clippy }} + run: rustup component add clippy + - name: Update toolchain + run: rustup update + - name: Build + run: cargo build + - name: Clippy + if: ${{ matrix.rust.clippy }} + run: cargo clippy --all-targets -- -D warnings + - name: Test + run: cargo test + + fmt: + name: Rust fmt + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set default toolchain + run: rustup default nightly + - name: Set profile + run: rustup set profile minimal + - name: Add rustfmt + run: rustup component add rustfmt + - name: Update toolchain + run: rustup update + - name: Check fmt + run: cargo fmt --all -- --config format_code_in_doc_comments=true --check From 49da6fcbaeaf3f3b437a3f2f58823c5aeba3ef14 Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Mon, 25 Jul 2022 13:02:41 -0700 Subject: [PATCH 2/3] Fix clippy warnings --- src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index dffc8b8..9dcd829 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -490,7 +490,7 @@ impl TxBuilder { } } if !&self.data.is_empty() { - tx_builder.add_data(&self.data.as_slice()); + tx_builder.add_data(self.data.as_slice()); } tx_builder @@ -597,7 +597,7 @@ mod test { .drain_wallet() .drain_to(drain_to_address.clone()); //dbg!(&tx_builder); - assert_eq!(tx_builder.drain_wallet, true); + assert!(tx_builder.drain_wallet); assert_eq!(tx_builder.drain_to, Some(drain_to_address)); let psbt = tx_builder.finish(&test_wallet).unwrap(); @@ -616,7 +616,7 @@ mod test { .get(0) .unwrap() .value; - assert_eq!(input_value, 50_000 as u64); + assert_eq!(input_value, 50_000_u64); // confirm one output to correct address with all sats - fee assert_eq!(psbt.outputs.len(), 1); @@ -636,6 +636,6 @@ mod test { Address::from_str("tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt").unwrap() ); let output_value = psbt.unsigned_tx.output.get(0).cloned().unwrap().value; - assert_eq!(output_value, 49_890 as u64); // input - fee + assert_eq!(output_value, 49_890_u64); // input - fee } } From 46850ed4710a18bc2db785d6816b6acddcfced5f Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Mon, 25 Jul 2022 13:06:27 -0700 Subject: [PATCH 3/3] Add github issue templates and PR template --- .github/ISSUE_TEMPLATE/bug_report.md | 26 ++++++++ .github/ISSUE_TEMPLATE/summer_project.md | 77 ++++++++++++++++++++++++ .github/pull_request_template.md | 30 +++++++++ 3 files changed, 133 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/summer_project.md create mode 100644 .github/pull_request_template.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..0708e29 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,26 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: 'bug' +assignees: '' + +--- + +**Describe the bug** + + +**To Reproduce** + + +**Expected behavior** + + +**Build environment** + - BDK tag/commit: + - OS+version: + - Rust/Cargo version: + - Rust/Cargo target: + +**Additional context** + diff --git a/.github/ISSUE_TEMPLATE/summer_project.md b/.github/ISSUE_TEMPLATE/summer_project.md new file mode 100644 index 0000000..a693283 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/summer_project.md @@ -0,0 +1,77 @@ +--- +name: Summer of Bitcoin Project +about: Template to suggest a new https://www.summerofbitcoin.org/ project. +title: '' +labels: 'summer-of-bitcoin' +assignees: '' + +--- + + + +**Description** + + +**Expected Outcomes** + + +**Resources** + + + + + + +**Skills Required** + + + + + + + +**Mentor(s)** + + +**Difficulty** + + +**Competency Test (optional)** + + + + + + + diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..3dbc5fd --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,30 @@ + + +### Description + + + +### Notes to the reviewers + + + +### Checklists + +#### All Submissions: + +* [ ] I've signed all my commits +* [ ] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) +* [ ] I ran `cargo fmt` and `cargo clippy` before committing + +#### New Features: + +* [ ] I've added tests for the new feature +* [ ] I've added docs for the new feature +* [ ] I've updated `CHANGELOG.md` + +#### Bugfixes: + +* [ ] This pull request breaks the existing API +* [ ] I've added tests to reproduce the issue which are now passing +* [ ] I'm linking the issue being fixed by this PR