Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: move to Nix (simpler, easy to maintain version) #1320

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
13 changes: 6 additions & 7 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ name: Audit
on:
push:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
- "**/Cargo.toml"
- "**/Cargo.lock"
schedule:
- cron: '0 0 * * 0' # Once per week
- cron: "0 0 * * 0" # Once per week

jobs:

security_audit:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
31 changes: 11 additions & 20 deletions .github/workflows/code_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,26 @@ jobs:
Codecov:
name: Code Coverage
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-Cinstrument-coverage"
RUSTDOCFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "./target/coverage/%p-%m.profraw"

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install lcov tools
run: sudo apt-get install lcov -y
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
components: llvm-tools-preview
- name: checkout
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v14
- name: Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Rust Cache
uses: Swatinem/[email protected]
uses: Swatinem/rust-cache@v2
# Code Coverage
- name: Install grcov
run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi
- name: Test
run: cargo test --all-features
run: nix develop ".#coverage" -L --command cargo test --all-features
- name: Make coverage directory
run: mkdir coverage
- name: Run grcov
run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --keep-only '**/crates/**' --ignore '**/tests/**' --ignore '**/examples/**' -o ./coverage/lcov.info
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
- name: Generate HTML coverage report
run: genhtml -o coverage-report.html --ignore-errors source ./coverage/lcov.info
run: nix develop ".#coverage" -L --command genhtml -o coverage-report.html --ignore-errors source ./coverage/lcov.info
- name: Coveralls upload
uses: coverallsapp/github-action@master
with:
Expand Down
218 changes: 100 additions & 118 deletions .github/workflows/cont_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,149 +3,133 @@ on: [push, pull_request]
name: CI

jobs:
self-care:
name: Flake self-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check Nix flake inputs
uses: DeterminateSystems/flake-checker-action@v9
with:
fail-mode: true

pre-commit-checks:
name: "Pre-commit checks: cargo fmt, typos, pgp-signed and conventional commits"
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v14
- name: Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Pre-commit checks
run: nix flake check

prepare:
clippy:
name: "Stable build, clippy and test"
runs-on: ubuntu-latest
outputs:
rust_version: ${{ steps.read_toolchain.outputs.rust_version }}
strategy:
matrix:
features:
- --no-default-features
- --all-features
steps:
- name: "Checkout repo"
- name: checkout
uses: actions/checkout@v4
- name: "Read rust version"
id: read_toolchain
run: echo "rust_version=$(cat rust-version)" >> $GITHUB_OUTPUT

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v14
- name: Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Build
run: nix develop -i -L .#stable --command cargo build ${{ matrix.features }}
- name: Clippy
run: nix develop -i -L .#stable --command cargo clippy ${{ matrix.features }} -- -D warnings
- name: Test
run: nix develop -i -L .#stable --command cargo test ${{ matrix.features }}

build-test:
name: Build and test
name: "MSRV build and test"
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- version: stable
clippy: true
- version: 1.63.0 # MSRV
features:
- --no-default-features
- --all-features
steps:
- name: checkout
uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust.version }}
override: true
profile: minimal
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v14
- name: Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Rust Cache
uses: Swatinem/[email protected]
- name: Pin dependencies for MSRV
notmandatory marked this conversation as resolved.
Show resolved Hide resolved
if: matrix.rust.version == '1.63.0'
run: |
cargo update -p zstd-sys --precise "2.0.8+zstd.1.5.5"
cargo update -p time --precise "0.3.20"
cargo update -p home --precise "0.5.5"
cargo update -p proptest --precise "1.2.0"
cargo update -p url --precise "2.5.0"
cargo update -p cc --precise "1.0.105"
cargo update -p tokio --precise "1.38.1"
cargo update -p tokio-util --precise "0.7.11"
uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build ${{ matrix.features }}
run: nix develop -i -L .#msrv --command cargo build ${{ matrix.features }}
- name: Test
run: cargo test ${{ matrix.features }}
run: nix develop -i -L .#msrv --command cargo test ${{ matrix.features }}

check-no-std:
name: Check no_std
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- msrv
- stable
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
# target: "thumbv6m-none-eabi"
- name: checkout
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v14
- name: Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Rust Cache
uses: Swatinem/[email protected]
uses: Swatinem/rust-cache@v2
# TODO "--target thumbv6m-none-eabi" should work but currently does not
- name: Check bdk_chain
working-directory: ./crates/chain
# TODO "--target thumbv6m-none-eabi" should work but currently does not
run: cargo check --no-default-features --features miniscript/no-std,hashbrown
- name: Check bdk wallet
run: nix develop -i -L ".#${{ matrix.rust }}" --command cargo check --no-default-features --features miniscript/no-std,hashbrown
- name: Check bdk_wallet
working-directory: ./crates/wallet
# TODO "--target thumbv6m-none-eabi" should work but currently does not
run: cargo check --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
- name: Check esplora
run: nix develop -i -L ".#${{ matrix.rust }}" --command cargo check --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
- name: Check bdk_esplora
working-directory: ./crates/esplora
# TODO "--target thumbv6m-none-eabi" should work but currently does not
run: cargo check --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
run: nix develop -i -L ".#${{ matrix.rust }}" --command cargo check --no-default-features --features miniscript/no-std,bdk_chain/hashbrown

check-wasm:
name: Check WASM
runs-on: ubuntu-20.04
env:
CC: clang-10
CFLAGS: -I/usr/include
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- msrv
- stable
target:
- wasm32-unknown-unknown
steps:
- name: Checkout
uses: actions/checkout@v2
# Install a recent version of clang that supports wasm32
- run: wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - || exit 1
- run: sudo apt-get update || exit 1
- run: sudo apt-get install -y libclang-common-10-dev clang-10 libc6-dev-i386 || exit 1
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
target: "wasm32-unknown-unknown"
- name: checkout
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v14
- name: Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Rust Cache
uses: Swatinem/rust-cache@v2.2.1
- name: Check bdk wallet
uses: Swatinem/rust-cache@v2
- name: Check bdk_wallet
working-directory: ./crates/wallet
run: cargo check --target wasm32-unknown-unknown --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
- name: Check esplora
run: nix develop -i -L ".#${{ matrix.rust }}" --command cargo check --target ${{ matrix.target }} --no-default-features --features miniscript/no-std,bdk_chain/hashbrown
- name: Check bdk_esplora
working-directory: ./crates/esplora
run: cargo check --target wasm32-unknown-unknown --no-default-features --features miniscript/no-std,bdk_chain/hashbrown,async

fmt:
name: Rust fmt
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
components: rustfmt
- name: Check fmt
run: cargo fmt --all -- --config format_code_in_doc_comments=true --check

clippy_check:
needs: prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ needs.prepare.outputs.rust_version }}
components: clippy
override: true
- name: Rust Cache
uses: Swatinem/[email protected]
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --all-targets -- -D warnings
run: nix develop -i -L ".#${{ matrix.rust }}" --command cargo check --target ${{ matrix.target }} --no-default-features --features miniscript/no-std,bdk_chain/hashbrown,async

build-examples:
name: Build Examples
name: Build examples
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -160,15 +144,13 @@ jobs:
- wallet_rpc
steps:
- name: checkout
uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v14
- name: Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Rust Cache
uses: Swatinem/rust-cache@v2.2.1
- name: Build
uses: Swatinem/rust-cache@v2
- name: Build examples
working-directory: example-crates/${{ matrix.example-dir }}
run: cargo build
run: nix develop -i -L .#stable --command cargo build
26 changes: 11 additions & 15 deletions .github/workflows/nightly_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,30 @@ jobs:
name: Build docs
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Set default toolchain
run: rustup default nightly-2024-05-12
- name: Set profile
run: rustup set profile minimal
- name: Update toolchain
run: rustup update
- name: checkout
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v11
- name: Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v6
- name: Rust Cache
uses: Swatinem/rust-cache@v2.2.1
uses: Swatinem/rust-cache@v2
- name: Build docs
run: cargo doc --no-deps
env:
RUSTDOCFLAGS: '--cfg docsrs -Dwarnings'
run: nix develop -L '.#nightly' --command cargo doc --no-deps
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: built-docs
path: ./target/doc/*

publish_docs:
name: 'Publish docs'
name: "Publish docs"
if: github.ref == 'refs/heads/master'
needs: [build_docs]
runs-on: ubuntu-latest
steps:
- name: Checkout `bitcoindevkit.org`
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.DOCS_PUSH_SSH_KEY }}
repository: bitcoindevkit/bitcoindevkit.org
Expand All @@ -51,7 +47,7 @@ jobs:
- name: Configure git
run: git config user.email "[email protected]" && git config user.name "github-actions"
- name: Commit
continue-on-error: true # If there's nothing to commit this step fails, but it's fine
continue-on-error: true # If there's nothing to commit this step fails, but it's fine
run: git add ./docs/.vuepress/public/docs-rs && git commit -m "Publish autogenerated nightly docs"
- name: Push
run: git push origin master
Loading
Loading