Skip to content

Commit 321c8a0

Browse files
committed
Merge #315: Add rust-toolchain.toml file
6f140ed ci: add overview documentation to ci workflows (thunderbiscuit) c6af44b chore: bump rust-toolchain.toml channel to 1.90.0 (stable) (thunderbiscuit) 3ffe0ff ci: remove cron-update-rust workflow (thunderbiscuit) 1589e8e ci: fix code coverage workflow (thunderbiscuit) 2d85143 ci: update actions/checkout to version 5 (thunderbiscuit) ab5a348 ci: leverage rust-toolchain.toml file in ci workflows (thunderbiscuit) aa6bea0 build: add rust-toolchain.toml file (thunderbiscuit) Pull request description: This addresses #314. It also incorporates the changes in #299. The rust-toolchain.toml file is used to help contributors build, format, and clippy check the codebase using the same version of the Rust compiler. It can easily be overriden, but if no other arguments are supplied to commands like `cargo run`, `cargo fmt`, and `cargo clippy`, they will pick the version defined in this file. In order to ensure the CI runs and the default versions devs build the library with (the one defined in `rust-toolchain.toml`) stay in sync, a few changes were made to the `cont_integration.yaml` workflow: 1. I removed the "prepare" job, which parsed the rust-version file in order to use it throughout the CI jobs. 2. I split the `Build & Test` job (and the 3-way matrix of (a) OS, (b) compilation features, (c) Rust version) into 2 different jobs. This is IMO easier for the eye to parse when looking at the workflow, and fully separate the testing of the MSRV and Stable into two separate jobs instead of a matrix of jobs with some extra of if/else stuff (for running the pinning script for example). The 2 jobs are now called `Build & Test MSRV` and `Build and Test Stable`. Note that this makes it easier to see and understand the workflow in the GitHub UI. 3. I picked a new "rust toolchain" action, [setup-rust-toolchain](https://github.com/actions-rust-lang/setup-rust-toolchain). It's the one recommended to me by both ChatGPT and Claude, and has a lot of stars and users (albeit a bit less than the dtolnay action, which its readme cites as its main inspiration). The reason for this is 2-fold: (a) it comes with caching out of the box, and (b) it respects the `toolchain.toml` file by default. [See their docs on this exact feature](https://github.com/actions-rust-lang/setup-rust-toolchain?tab=readme-ov-file#inputs). This makes our workflows easy to work with: in the first job, we explicitly set the toolchain version to our MSRV, in the second we let the action download the toolchain defined in rust-toolchain.toml. I also bumped the checkout action to its latest v5 version (last commit). close #314 close #299 ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `just p` before pushing ACKs for top commit: ValuedMammal: ACK 6f140ed oleonardolima: utACK 6f140ed Tree-SHA512: 3ddd396c9e85a0addc428438747c78b1e576246b7dce47ea1a8c8f724638f9d79e611be986f36600a28daa45af58603bc7e9b76f0e20264f8af231cbaf820251
2 parents e2cf34d + 6f140ed commit 321c8a0

File tree

8 files changed

+94
-124
lines changed

8 files changed

+94
-124
lines changed

.github/workflows/audit.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Audit
22

3+
# Performs a security audit of Rust dependencies using cargo-audit through the actions-rust-lang/audit action.
4+
# Runs nightly on schedule and when Cargo.toml, Cargo.lock, or audit.toml files are modified.
5+
# Helps identify known security vulnerabilities in the dependency tree.
6+
37
on:
48
push:
59
paths:
@@ -23,7 +27,8 @@ jobs:
2327
contents: read
2428
issues: write
2529
steps:
26-
- uses: actions/checkout@v4
30+
- name: Checkout
31+
uses: actions/checkout@v5
2732
with:
2833
persist-credentials: false
2934
- uses: actions-rust-lang/audit@v1

.github/workflows/code_coverage.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
on: [push, pull_request]
2-
31
name: Code Coverage
42

3+
# Generates code coverage reports using grcov and uploads results to Coveralls.
4+
# Runs on every push and pull request to track test coverage metrics.
5+
# Uploads coverage data to Coveralls for tracking and produces an HTML report artifact for download.
6+
7+
on: [push, pull_request]
8+
59
permissions: {}
610

711
jobs:
@@ -15,32 +19,34 @@ jobs:
1519

1620
steps:
1721
- name: Checkout
18-
uses: actions/checkout@v4
22+
uses: actions/checkout@v5
1923
with:
2024
persist-credentials: false
2125
- name: Install lcov tools
2226
run: sudo apt-get install lcov -y
27+
# This action automatically reads and applies rust-toolchain.toml
2328
- name: Install Rust toolchain
24-
uses: dtolnay/rust-toolchain@v1
29+
uses: actions-rust-lang/setup-rust-toolchain@v1
2530
with:
26-
toolchain: stable
27-
components: llvm-tools-preview
28-
- name: Rust Cache
29-
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0
31+
components: llvm-tools-preview
32+
cache: true
3033
- name: Install grcov
3134
run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi
3235
- name: Test
3336
run: cargo test --all-features
3437
- name: Make coverage directory
3538
run: mkdir coverage
3639
- name: Run grcov
37-
run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --keep-only '**/wallet/**' --ignore '**/tests/**' --ignore '**/examples/**' -o ./coverage/lcov.info
40+
run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --keep-only 'src/**' --ignore 'tests/**' --ignore 'examples/**' -o ./coverage/lcov.info
3841
- name: Generate HTML coverage report
3942
run: genhtml -o coverage-report.html --ignore-errors unmapped ./coverage/lcov.info
4043
- name: Coveralls upload
41-
uses: coverallsapp/github-action@master
44+
# Action pinned at tag 2.3.6
45+
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b
4246
with:
4347
github-token: ${{ secrets.GITHUB_TOKEN }}
48+
file: ./coverage/lcov.info
49+
format: lcov
4450
- name: Upload artifact
4551
uses: actions/upload-artifact@v4
4652
with:
Lines changed: 60 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
on: [push, pull_request]
22

3+
# Main continuous integration workflow that runs build, test, and code quality checks.
4+
# Runs on every push and pull request, testing against both MSRV (1.85) and stable Rust.
5+
# Includes no_std and WASM compatibility checks, formatting validation, and clippy linting.
6+
37
name: CI
48

59
permissions: {}
@@ -8,133 +12,137 @@ env:
812
CARGO_TERM_COLOR: always
913

1014
jobs:
11-
prepare:
12-
runs-on: ubuntu-latest
13-
outputs:
14-
rust_version: ${{ steps.read_toolchain.outputs.rust_version }}
15+
build-test-msrv:
16+
name: Build & Test MSRV
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
matrix:
20+
os:
21+
- ubuntu-latest
22+
- ubuntu-24.04-arm
23+
features:
24+
- --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
25+
- --all-features
1526
steps:
16-
- name: "Checkout repo"
17-
uses: actions/checkout@v4
27+
- name: Checkout
28+
uses: actions/checkout@v5
1829
with:
1930
persist-credentials: false
20-
- name: "Read rust version"
21-
id: read_toolchain
22-
run: echo "rust_version=$(cat rust-version)" >> $GITHUB_OUTPUT
31+
# The 'toolchain' argument on this action overrides the Rust compiler version set in rust-toolchain.toml
32+
# in order to test our MSRV.
33+
- name: Install Rust toolchain
34+
uses: actions-rust-lang/setup-rust-toolchain@v1
35+
with:
36+
toolchain: 1.85 # MSRV
37+
cache: true
38+
- name: Pin dependencies for MSRV
39+
run: ./ci/pin-msrv.sh
40+
- name: Build + Test
41+
run: |
42+
cargo build --workspace --all-targets ${{ matrix.features }}
43+
cargo test --workspace ${{ matrix.features }}
2344
24-
build-test:
25-
needs: prepare
26-
name: Build & Test
45+
build-test-stable:
46+
name: Build & Test Rust Stable
2747
runs-on: ${{ matrix.os }}
2848
strategy:
2949
matrix:
3050
os:
3151
- ubuntu-latest
3252
- ubuntu-24.04-arm
33-
rust:
34-
- version: ${{ needs.prepare.outputs.rust_version }}
35-
- version: 1.85.0 # MSRV
3653
features:
3754
- --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
3855
- --all-features
3956
steps:
40-
- name: checkout
41-
uses: actions/checkout@v4
57+
- name: Checkout
58+
uses: actions/checkout@v5
4259
with:
4360
persist-credentials: false
61+
# This action will honor the Rust compiler version set in rust-toolchain.toml. We aim to keep it in sync with
62+
# Rust stable.
4463
- name: Install Rust toolchain
45-
uses: dtolnay/rust-toolchain@v1
64+
uses: actions-rust-lang/setup-rust-toolchain@v1
4665
with:
47-
toolchain: ${{ matrix.rust.version }}
48-
- name: Rust Cache
49-
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0
50-
- name: Pin dependencies for MSRV
51-
if: matrix.rust.version == '1.85.0'
52-
run: ./ci/pin-msrv.sh
66+
cache: true
5367
- name: Build + Test
54-
env:
55-
MATRIX_RUST_VERSION: ${{ matrix.rust.version }}
5668
run: |
5769
cargo build --workspace --all-targets ${{ matrix.features }}
5870
cargo test --workspace ${{ matrix.features }}
5971
6072
check-no-std:
61-
needs: prepare
6273
name: Check no_std
6374
runs-on: ubuntu-latest
6475
steps:
6576
- name: Checkout
66-
uses: actions/checkout@v4
77+
uses: actions/checkout@v5
6778
with:
6879
persist-credentials: false
80+
# This action automatically reads and applies rust-toolchain.toml
6981
- name: Install Rust toolchain
70-
uses: dtolnay/rust-toolchain@v1
82+
uses: actions-rust-lang/setup-rust-toolchain@v1
7183
with:
72-
toolchain: ${{ needs.prepare.outputs.rust_version }}
73-
# target: "thumbv6m-none-eabi"
74-
- name: Rust Cache
75-
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0
84+
cache: true
7685
- name: Check no-std
7786
# TODO "--target thumbv6m-none-eabi" should work but currently does not
7887
run: cargo check --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
7988

8089
check-wasm:
81-
needs: prepare
8290
name: Check WASM
8391
runs-on: ubuntu-latest
8492
env:
8593
CC: clang-14
8694
CFLAGS: -I/usr/include
8795
steps:
8896
- name: Checkout
89-
uses: actions/checkout@v4
97+
uses: actions/checkout@v5
9098
with:
9199
persist-credentials: false
92100
# Install a recent version of clang that supports wasm32
93101
- run: wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - || exit 1
94102
- run: sudo apt-get update || exit 1
95103
- run: sudo apt-get install -y libclang-common-14-dev clang-14 libc6-dev-i386 || exit 1
104+
# This action automatically reads and applies rust-toolchain.toml
96105
- name: Install Rust toolchain
97-
uses: dtolnay/rust-toolchain@v1
106+
uses: actions-rust-lang/setup-rust-toolchain@v1
98107
with:
99-
toolchain: ${{ needs.prepare.outputs.rust_version }}
100-
targets: "wasm32-unknown-unknown"
101-
- name: Rust Cache
102-
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0
108+
cache: true
109+
target: wasm32-unknown-unknown
103110
- name: Check WASM
104-
run: cargo check --target wasm32-unknown-unknown --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
111+
run: |
112+
rustup target add wasm32-unknown-unknown
113+
cargo check --target wasm32-unknown-unknown --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
105114
106115
fmt:
107116
name: Rust fmt
108117
runs-on: ubuntu-latest
109118
steps:
110119
- name: Checkout
111-
uses: actions/checkout@v4
120+
uses: actions/checkout@v5
112121
with:
113122
persist-credentials: false
123+
# This action automatically reads and applies rust-toolchain.toml
114124
- name: Install Rust toolchain
115-
uses: dtolnay/rust-toolchain@v1
125+
uses: actions-rust-lang/setup-rust-toolchain@v1
116126
with:
117-
toolchain: nightly
118-
components: rustfmt
127+
cache: true
119128
- name: Check fmt
120129
run: cargo fmt --all --check
121130

122131
clippy_check:
123-
needs: prepare
124132
name: Rust clippy
125133
runs-on: ubuntu-latest
126134
permissions:
127135
checks: write
128136
steps:
129-
- uses: actions/checkout@v4
137+
- name: Checkout
138+
uses: actions/checkout@v5
130139
with:
131140
persist-credentials: false
132-
- uses: dtolnay/rust-toolchain@v1
141+
# This action automatically reads and applies rust-toolchain.toml
142+
- name: Install Rust toolchain
143+
uses: actions-rust-lang/setup-rust-toolchain@v1
133144
with:
134-
toolchain: ${{ needs.prepare.outputs.rust_version }}
135-
components: clippy
136-
- name: Rust Cache
137-
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0
145+
cache: true
138146
- name: Clippy
139147
run: cargo clippy --all-features --all-targets -- -D warnings
140148

.github/workflows/cron-update-rust.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

.github/workflows/zizmor.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
name: Zizmor Actions Analysis
22

3+
# Analyzes GitHub Actions workflows for security vulnerabilities using zizmor.
4+
# Runs on pushes to master and all pull requests to detect potential security issues
5+
# in workflow configurations. Results are uploaded to GitHub's security dashboard.
6+
# The .github/zizmor.yml file configures the rules this action will check against.
7+
38
on:
49
push:
510
branches: ["master"]
@@ -12,8 +17,8 @@ jobs:
1217
permissions:
1318
security-events: write
1419
steps:
15-
- name: Checkout repository
16-
uses: actions/checkout@v4
20+
- name: Checkout
21+
uses: actions/checkout@v5
1722
with:
1823
persist-credentials: false
1924

.github/zizmor.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ rules:
44
config:
55
policies:
66
# Allow pin by ref/tag
7-
dtolnay/rust-toolchain: ref-pin
7+
actions-rust-lang/setup-rust-toolchain: ref-pin
8+
actions/*: ref-pin

rust-toolchain.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "1.90.0"
3+
components = ["clippy", "rustfmt"]

rust-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)