Skip to content

Commit ed39a3e

Browse files
committed
add integration tests workflow
1 parent 8c70671 commit ed39a3e

File tree

3 files changed

+192
-2
lines changed

3 files changed

+192
-2
lines changed
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
on: [push, pull_request]
2+
3+
name: CI
4+
5+
jobs:
6+
# formatting
7+
fmt:
8+
name: Rust fmt
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
- name: Install Rust
15+
uses: dtolnay/rust-toolchain@stable
16+
with:
17+
components: rustfmt
18+
19+
- name: Check fmt
20+
run: cargo fmt --all -- --check
21+
22+
# Clippy lints
23+
clippy:
24+
name: Clippy (${{ matrix.rust }}, ${{ matrix.features }})
25+
runs-on: ubuntu-latest
26+
strategy:
27+
matrix:
28+
rust: [stable, beta]
29+
features:
30+
- --features default
31+
- --no-default-features
32+
- --all-features
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Install Rust ${{ matrix.rust }}
37+
uses: dtolnay/rust-toolchain@master
38+
with:
39+
toolchain: ${{ matrix.rust }}
40+
components: clippy
41+
42+
- name: Generate cache key
43+
run: echo "${{ matrix.rust }} ${{ matrix.features }}" | tee .cache_key
44+
45+
- name: Cache cargo registry
46+
uses: actions/cache@v4
47+
with:
48+
path: ~/.cargo/registry
49+
key: ${{ runner.os }}-${{ matrix.rust }}-cargo-registry-${{ hashFiles('.cache_key') }}-${{ hashFiles('**/Cargo.lock') }}
50+
51+
- name: Cache cargo index
52+
uses: actions/cache@v4
53+
with:
54+
path: ~/.cargo/git
55+
key: ${{ runner.os }}-${{ matrix.rust }}-cargo-index-${{ hashFiles('.cache_key') }}-${{ hashFiles('**/Cargo.lock') }}
56+
57+
- name: Cache cargo build
58+
uses: actions/cache@v4
59+
with:
60+
path: target
61+
key: ${{ runner.os }}-${{ matrix.rust }}-cargo-build-${{ hashFiles('.cache_key') }}-${{ hashFiles('**/Cargo.lock') }}
62+
63+
- name: Run Clippy
64+
run: cargo clippy ${{ matrix.features }} --all-targets -- -D warnings
65+
66+
# Build and test
67+
test:
68+
name: Test (${{ matrix.os }}, ${{ matrix.rust }}, ${{ matrix.features }})
69+
strategy:
70+
fail-fast: false
71+
matrix:
72+
os: [ubuntu-latest, windows-latest, macos-latest]
73+
rust: [stable, beta, nightly]
74+
features:
75+
- --features default
76+
- --no-default-features
77+
- --all-features
78+
exclude:
79+
- os: windows-latest
80+
rust: beta
81+
- os: windows-latest
82+
features: --no-default-features
83+
- os: macos-latest
84+
rust: beta
85+
- os: macos-latest
86+
features: --no-default-features
87+
- os: windows-latest
88+
rust: nightly
89+
features: --no-default-features
90+
- os: macos-latest
91+
rust: nightly
92+
features: --no-default-features
93+
runs-on: ${{ matrix.os }}
94+
steps:
95+
- uses: actions/checkout@v4
96+
97+
- name: Install Rust ${{ matrix.rust }}
98+
uses: dtolnay/rust-toolchain@master
99+
with:
100+
toolchain: ${{ matrix.rust }}
101+
102+
- name: Generate cache key
103+
shell: bash
104+
run: echo "${{ matrix.rust }} ${{ matrix.features }}" | tee .cache_key
105+
106+
- name: Cache cargo registry
107+
uses: actions/cache@v4
108+
with:
109+
path: ~/.cargo/registry
110+
key: ${{ runner.os }}-${{ matrix.rust }}-cargo-registry-${{ hashFiles('.cache_key') }}-${{ hashFiles('**/Cargo.lock') }}
111+
112+
- name: Cache cargo index
113+
uses: actions/cache@v4
114+
with:
115+
path: ~/.cargo/git
116+
key: ${{ runner.os }}-${{ matrix.rust }}-cargo-index-${{ hashFiles('.cache_key') }}-${{ hashFiles('**/Cargo.lock') }}
117+
118+
- name: Cache cargo build
119+
uses: actions/cache@v4
120+
with:
121+
path: target
122+
key: ${{ runner.os }}-${{ matrix.rust }}-cargo-build-${{ hashFiles('.cache_key') }}-${{ hashFiles('**/Cargo.lock') }}
123+
124+
- name: Build
125+
run: cargo build ${{ matrix.features }} --verbose
126+
127+
- name: Run unit tests
128+
run: cargo test ${{ matrix.features }} --lib --verbose
129+
130+
- name: Run doc tests
131+
run: cargo test ${{ matrix.features }} --doc --verbose
132+
continue-on-error: ${{ matrix.rust == 'nightly' }}
133+
134+
135+
# Integration tests (requires Bitcoin node)
136+
integration-test:
137+
name: Integration Tests (${{ matrix.features }})
138+
runs-on: ubuntu-latest
139+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
140+
strategy:
141+
matrix:
142+
features:
143+
- --features default
144+
- --all-features
145+
steps:
146+
- uses: actions/checkout@v4
147+
148+
- name: Install Rust
149+
uses: dtolnay/rust-toolchain@stable
150+
151+
- name: Install Bitcoin Core 27.0
152+
run: |
153+
wget https://bitcoincore.org/bin/bitcoin-core-30.0/bitcoin-30.0-x86_64-linux-gnu.tar.gz
154+
tar xzf bitcoin-30.0-x86_64-linux-gnu.tar.gz
155+
sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-30.0/bin/*
156+
157+
- name: Start Bitcoin Core (regtest)
158+
run: |
159+
mkdir -p ~/.bitcoin
160+
bitcoind -regtest -daemon -rpcuser=test -rpcpassword=test -rpcport=18443
161+
sleep 5
162+
163+
- name: Run integration tests
164+
run: cargo test ${{ matrix.features }} --test integration -- --ignored --test-threads=1
165+
env:
166+
BITCOIN_RPC_URL: http://localhost:18443
167+
BITCOIN_RPC_USER: bitcoin
168+
BITCOIN_RPC_PASS: bitcoin
169+
170+
- name: Stop Bitcoin Core
171+
if: always()
172+
run: bitcoin-cli -regtest -rpcuser=bitcoin -rpcpassword=bitcoin stop || true
173+
174+
# MSRV
175+
msrv:
176+
name: MSRV
177+
runs-on: ubuntu-latest
178+
steps:
179+
- uses: actions/checkout@v4
180+
181+
- name: Install Rust 1.70.0
182+
uses: dtolnay/rust-toolchain@master
183+
with:
184+
toolchain: 1.70.0
185+
186+
- name: Check MSRV
187+
run: cargo check --all-features

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
[package]
2-
name = "bdk-rpc-client"
2+
name = "bdk_rpc_client"
33
version = "0.1.0"
44
edition = "2024"
55

66
[dependencies]
77
corepc-types = { version = "0.10.1", features = ["default"]}
88
jsonrpc = { version = "0.18.0", features = ["simple_http", "simple_tcp", "minreq_http", "simple_uds", "proxy"] }
99

10+
[features]
11+
default = [ "v30" ]
12+
v30 = [ ]

0 commit comments

Comments
 (0)