Skip to content

Commit 2301e80

Browse files
author
Jose Storopoli
committed
ci: move to Nix
You can switch flawlessly from Rust stable, MSRV, and nightly using either: - `nix develop .`: Rust MRSV - `nix develop .#msrv`: Rust MRSV - `nix develop .#stable`: Rust latest stable - `nix develop .#nightly`: Rust Nightly Also you don't need to worry about installing binaries from `bitcoind` or `electrs` crates, since we fetch these from `nixpkgs` (with pinned versions) and add them to your local environment. Additionally, all the extra dependencies that you need for WASM are handled as well. Finally, no need to set ENV vars: they are also set all by default to you. If you are committing typos, or failing to adhere to our guidelines in [CONTRIBUTING.md](CONTRIBUTING.md); we won't let you commit or push. This is handled by Nix's automated `pre-commit` hooks which gives helpful error messages. Please check the [Nix.md](Nix.md) file to learn more about Nix and what we are aiming to do with the Nix integration into BDK.
1 parent 785371e commit 2301e80

32 files changed

Lines changed: 6504 additions & 182 deletions
File renamed without changes.

.github/workflows/audit.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@ name: Audit
33
on:
44
push:
55
paths:
6-
- '**/Cargo.toml'
7-
- '**/Cargo.lock'
6+
- "**/Cargo.toml"
7+
- "**/Cargo.lock"
88
schedule:
9-
- cron: '0 0 * * 0' # Once per week
9+
- cron: "0 0 * * 0" # Once per week
1010

1111
jobs:
12-
1312
security_audit:
14-
runs-on: ubuntu-20.04
13+
runs-on: ubuntu-latest
1514
steps:
16-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1716
- uses: actions-rs/audit-check@v1
1817
with:
19-
token: ${{ secrets.GITHUB_TOKEN }}
18+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/code_coverage.yml

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,18 @@ jobs:
66
Codecov:
77
name: Code Coverage
88
runs-on: ubuntu-latest
9-
env:
10-
RUSTFLAGS: "-Cinstrument-coverage"
11-
RUSTDOCFLAGS: "-Cinstrument-coverage"
12-
LLVM_PROFILE_FILE: "./target/coverage/%p-%m.profraw"
13-
149
steps:
15-
- name: Checkout
16-
uses: actions/checkout@v2
17-
- name: Install lcov tools
18-
run: sudo apt-get install lcov -y
19-
- name: Install Rust toolchain
20-
uses: actions-rs/toolchain@v1
21-
with:
22-
toolchain: stable
23-
override: true
24-
profile: minimal
25-
components: llvm-tools-preview
10+
- name: checkout
11+
uses: actions/checkout@v4
12+
- name: Install Nix
13+
uses: DeterminateSystems/nix-installer-action@v11
14+
- name: Nix Cache
15+
uses: DeterminateSystems/magic-nix-cache-action@v6
2616
- name: Rust Cache
27-
uses: Swatinem/rust-cache@v2.2.1
17+
uses: Swatinem/rust-cache@v2
18+
# Code Coverage
2819
- name: Install grcov
29-
run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi
20+
run: nix develop -L ".#coverage" --command cargo install grcov
3021
# TODO: re-enable the hwi tests
3122
- name: Build simulator image
3223
run: docker build -t hwi/ledger_emulator ./ci -f ci/Dockerfile.ledger
@@ -35,23 +26,23 @@ jobs:
3526
- name: Install Python
3627
uses: actions/setup-python@v4
3728
with:
38-
python-version: '3.9'
29+
python-version: "3.9"
3930
- name: Install python dependencies
4031
run: pip install hwi==2.1.1 protobuf==3.20.1
4132
- name: Test
42-
run: cargo test --all-features
33+
run: nix develop ".#coverage" -L --command cargo test --all-features
4334
- name: Make coverage directory
4435
run: mkdir coverage
4536
- name: Run grcov
46-
run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --keep-only '**/crates/**' --ignore '**/tests/**' --ignore '**/examples/**' -o ./coverage/lcov.info
37+
run: nix develop ".#coverage" -L --command grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --keep-only '**/crates/**' --ignore '**/tests/**' --ignore '**/examples/**' -o ./coverage/lcov.info
4738
- name: Generate HTML coverage report
48-
run: genhtml -o coverage-report.html --ignore-errors source ./coverage/lcov.info
39+
run: nix develop ".#coverage" -L --command genhtml -o coverage-report.html --ignore-errors source ./coverage/lcov.info
4940
- name: Coveralls upload
5041
uses: coverallsapp/github-action@master
5142
with:
5243
github-token: ${{ secrets.GITHUB_TOKEN }}
5344
- name: Upload artifact
54-
uses: actions/upload-artifact@v2
45+
uses: actions/upload-artifact@v3
5546
with:
5647
name: coverage-report
5748
path: coverage-report.html

.github/workflows/cont_integration.yml

Lines changed: 92 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -3,130 +3,122 @@ on: [push, pull_request]
33
name: CI
44

55
jobs:
6+
self-care:
7+
name: Flake self-check
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Check Nix flake inputs
12+
uses: DeterminateSystems/flake-checker-action@v7
13+
with:
14+
fail-mode: true
15+
16+
pre-commit-checks:
17+
name: "Pre-commit checks: cargo fmt, typos, pgp-signed and conventional commits"
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: checkout
21+
uses: actions/checkout@v4
22+
- name: Install Nix
23+
uses: DeterminateSystems/nix-installer-action@v11
24+
- name: Nix Cache
25+
uses: DeterminateSystems/magic-nix-cache-action@v6
26+
- name: Rust Cache
27+
uses: Swatinem/rust-cache@v2
28+
- name: Pre-commit checks
29+
run: nix develop -L .#stable --command pre-commit run --all-files
30+
31+
clippy:
32+
name: "Stable build, clippy and test"
33+
runs-on: ubuntu-latest
34+
strategy:
35+
matrix:
36+
features:
37+
- --no-default-features
38+
- --all-features
39+
steps:
40+
- name: checkout
41+
uses: actions/checkout@v4
42+
- name: Install Nix
43+
uses: DeterminateSystems/nix-installer-action@v11
44+
- name: Nix Cache
45+
uses: DeterminateSystems/magic-nix-cache-action@v6
46+
- name: Rust Cache
47+
uses: Swatinem/rust-cache@v2
48+
- name: Build
49+
run: nix develop -L .#stable --command cargo build ${{ matrix.features }}
50+
- name: Clippy
51+
run: nix develop -L .#stable --command cargo clippy ${{ matrix.features }} -- -D warnings
52+
- name: Test
53+
run: nix develop -L .#stable --command cargo test ${{ matrix.features }}
654

755
build-test:
8-
name: Build and test
56+
name: "MSRV build and test"
957
runs-on: ubuntu-latest
1058
strategy:
1159
matrix:
12-
rust:
13-
- version: stable
14-
clippy: true
15-
- version: 1.63.0 # MSRV
1660
features:
1761
- --no-default-features
1862
- --all-features
1963
steps:
2064
- name: checkout
21-
uses: actions/checkout@v2
22-
- name: Install Rust toolchain
23-
uses: actions-rs/toolchain@v1
24-
with:
25-
toolchain: ${{ matrix.rust.version }}
26-
override: true
27-
profile: minimal
65+
uses: actions/checkout@v4
66+
- name: Install Nix
67+
uses: DeterminateSystems/nix-installer-action@v11
68+
- name: Nix Cache
69+
uses: DeterminateSystems/magic-nix-cache-action@v6
2870
- name: Rust Cache
29-
uses: Swatinem/rust-cache@v2.2.1
30-
- name: Pin dependencies for MSRV
31-
if: matrix.rust.version == '1.63.0'
32-
run: |
33-
cargo update -p zstd-sys --precise "2.0.8+zstd.1.5.5"
34-
cargo update -p time --precise "0.3.20"
35-
cargo update -p home --precise "0.5.5"
36-
cargo update -p proptest --precise "1.2.0"
37-
cargo update -p url --precise "2.5.0"
38-
cargo update -p cc --precise "1.0.105"
39-
cargo update -p tokio --precise "1.38.1"
71+
uses: Swatinem/rust-cache@v2
4072
- name: Build
41-
run: cargo build ${{ matrix.features }}
73+
run: nix develop -L .#msrv --command cargo build ${{ matrix.features }}
4274
- name: Test
43-
run: cargo test ${{ matrix.features }}
75+
run: nix develop -L .#msrv --command cargo test ${{ matrix.features }}
4476

4577
check-no-std:
4678
name: Check no_std
4779
runs-on: ubuntu-latest
80+
strategy:
81+
matrix:
82+
rust:
83+
- msrv
84+
- stable
4885
steps:
49-
- name: Checkout
50-
uses: actions/checkout@v2
51-
- name: Install Rust toolchain
52-
uses: actions-rs/toolchain@v1
53-
with:
54-
toolchain: stable
55-
override: true
56-
profile: minimal
57-
# target: "thumbv6m-none-eabi"
86+
- name: checkout
87+
uses: actions/checkout@v4
88+
- name: Install Nix
89+
uses: DeterminateSystems/nix-installer-action@v11
90+
- name: Nix Cache
91+
uses: DeterminateSystems/magic-nix-cache-action@v6
5892
- name: Rust Cache
59-
uses: Swatinem/rust-cache@v2.2.1
93+
uses: Swatinem/rust-cache@v2
94+
# TODO "--target thumbv6m-none-eabi" should work but currently does not
6095
- name: Check bdk_chain
61-
working-directory: ./crates/chain
62-
# TODO "--target thumbv6m-none-eabi" should work but currently does not
63-
run: cargo check --no-default-features --features miniscript/no-std,hashbrown
64-
- name: Check bdk wallet
65-
working-directory: ./crates/wallet
66-
# TODO "--target thumbv6m-none-eabi" should work but currently does not
67-
run: cargo check --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
96+
run: nix develop -L ".#${{ matrix.rust }}" --command cargo check -p bdk_chain --no-default-features --features miniscript/no-std,hashbrown
97+
- name: Check bdk
98+
run: nix develop -L ".#${{ matrix.rust }}" --command cargo check -p bdk_wallet --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
6899
- name: Check esplora
69-
working-directory: ./crates/esplora
70-
# TODO "--target thumbv6m-none-eabi" should work but currently does not
71-
run: cargo check --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
100+
run: nix develop -L ".#${{ matrix.rust }}" --command cargo check -p bdk_esplora --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
72101

73102
check-wasm:
74103
name: Check WASM
75-
runs-on: ubuntu-20.04
76-
env:
77-
CC: clang-10
78-
CFLAGS: -I/usr/include
79-
steps:
80-
- name: Checkout
81-
uses: actions/checkout@v2
82-
# Install a recent version of clang that supports wasm32
83-
- run: wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - || exit 1
84-
- run: sudo apt-get update || exit 1
85-
- run: sudo apt-get install -y libclang-common-10-dev clang-10 libc6-dev-i386 || exit 1
86-
- name: Install Rust toolchain
87-
uses: actions-rs/toolchain@v1
88-
with:
89-
toolchain: stable
90-
override: true
91-
profile: minimal
92-
target: "wasm32-unknown-unknown"
93-
- name: Rust Cache
94-
uses: Swatinem/rust-cache@v2.2.1
95-
- name: Check bdk wallet
96-
working-directory: ./crates/wallet
97-
run: cargo check --target wasm32-unknown-unknown --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
98-
- name: Check esplora
99-
working-directory: ./crates/esplora
100-
run: cargo check --target wasm32-unknown-unknown --no-default-features --features miniscript/no-std,bdk_chain/hashbrown,async
101-
102-
fmt:
103-
name: Rust fmt
104-
runs-on: ubuntu-latest
105-
steps:
106-
- name: Checkout
107-
uses: actions/checkout@v2
108-
- name: Install Rust toolchain
109-
uses: actions-rs/toolchain@v1
110-
with:
111-
toolchain: stable
112-
override: true
113-
profile: minimal
114-
components: rustfmt
115-
- name: Check fmt
116-
run: cargo fmt --all -- --config format_code_in_doc_comments=true --check
117-
118-
clippy_check:
119104
runs-on: ubuntu-latest
105+
strategy:
106+
matrix:
107+
rust:
108+
- msrv
109+
- stable
110+
target:
111+
- wasm32-unknown-unknown
120112
steps:
121-
- uses: actions/checkout@v1
122-
- uses: actions-rs/toolchain@v1
123-
with:
124-
toolchain: 1.78.0
125-
components: clippy
126-
override: true
113+
- name: checkout
114+
uses: actions/checkout@v4
115+
- name: Install Nix
116+
uses: DeterminateSystems/nix-installer-action@v11
117+
- name: Nix Cache
118+
uses: DeterminateSystems/magic-nix-cache-action@v6
127119
- name: Rust Cache
128-
uses: Swatinem/rust-cache@v2.2.1
129-
- uses: actions-rs/clippy-check@v1
130-
with:
131-
token: ${{ secrets.GITHUB_TOKEN }}
132-
args: --all-features --all-targets -- -D warnings
120+
uses: Swatinem/rust-cache@v2
121+
- name: Check bdk
122+
run: nix develop -L ".#${{ matrix.rust }}" --command cargo check -p bdk_wallet --target ${{ matrix.target }} --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
123+
- name: Check esplora
124+
run: nix develop -L ".#${{ matrix.rust }}" --command cargo check -p bdk_esplora --target ${{ matrix.target }} --no-default-features --features miniscript/no-std,bdk_chain/hashbrown,async

.github/workflows/nightly_docs.yml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,30 @@ jobs:
77
name: Build docs
88
runs-on: ubuntu-latest
99
steps:
10-
- name: Checkout sources
11-
uses: actions/checkout@v2
12-
- name: Set default toolchain
13-
run: rustup default nightly-2024-05-12
14-
- name: Set profile
15-
run: rustup set profile minimal
16-
- name: Update toolchain
17-
run: rustup update
10+
- name: checkout
11+
uses: actions/checkout@v4
12+
- name: Install Nix
13+
uses: DeterminateSystems/nix-installer-action@v11
14+
- name: Nix Cache
15+
uses: DeterminateSystems/magic-nix-cache-action@v6
1816
- name: Rust Cache
19-
uses: Swatinem/rust-cache@v2.2.1
17+
uses: Swatinem/rust-cache@v2
2018
- name: Build docs
21-
run: cargo doc --no-deps
22-
env:
23-
RUSTDOCFLAGS: '--cfg docsrs -Dwarnings'
19+
run: nix develop -L '.#nightly' --command cargo doc --no-deps
2420
- name: Upload artifact
25-
uses: actions/upload-artifact@v2
21+
uses: actions/upload-artifact@v3
2622
with:
2723
name: built-docs
2824
path: ./target/doc/*
2925

3026
publish_docs:
31-
name: 'Publish docs'
27+
name: "Publish docs"
3228
if: github.ref == 'refs/heads/master'
3329
needs: [build_docs]
3430
runs-on: ubuntu-latest
3531
steps:
3632
- name: Checkout `bitcoindevkit.org`
37-
uses: actions/checkout@v2
33+
uses: actions/checkout@v4
3834
with:
3935
ssh-key: ${{ secrets.DOCS_PUSH_SSH_KEY }}
4036
repository: bitcoindevkit/bitcoindevkit.org
@@ -44,14 +40,14 @@ jobs:
4440
- name: Remove old latest
4541
run: rm -rf ./docs/.vuepress/public/docs-rs/bdk/nightly/latest
4642
- name: Download built docs
47-
uses: actions/download-artifact@v1
43+
uses: actions/download-artifact@v3
4844
with:
4945
name: built-docs
5046
path: ./docs/.vuepress/public/docs-rs/bdk/nightly/latest
5147
- name: Configure git
5248
run: git config user.email "github-actions@github.com" && git config user.name "github-actions"
5349
- name: Commit
54-
continue-on-error: true # If there's nothing to commit this step fails, but it's fine
50+
continue-on-error: true # If there's nothing to commit this step fails, but it's fine
5551
run: git add ./docs/.vuepress/public/docs-rs && git commit -m "Publish autogenerated nightly docs"
5652
- name: Push
5753
run: git push origin master
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Update Flake Lock File
2+
on:
3+
workflow_dispatch: # allows manual triggering
4+
schedule:
5+
- cron: "0 0 1 * *" # runs monthly on day 1 at 00:00
6+
7+
jobs:
8+
lockfile:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
- name: Install Nix
14+
uses: DeterminateSystems/nix-installer-action@v11
15+
- name: Update flake.lock
16+
uses: DeterminateSystems/update-flake-lock@v21
17+
with:
18+
pr-title: "ci: update flake.lock" # Title of PR to be created
19+
pr-labels: | # Labels to be set on the PR
20+
dependencies
21+
automated

0 commit comments

Comments
 (0)