Skip to content
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
114 changes: 45 additions & 69 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,77 +26,49 @@ jobs:
cd ext-functional-test-demo
cargo test --verbose --color always
cargo test --verbose --color always --features test-broken
build:
strategy:
fail-fast: false
matrix:
platform: >-
${{ github.event_name == 'push' && github.ref == 'refs/heads/main'
&& fromJSON('["self-hosted","windows-latest","macos-latest"]')
|| fromJSON('["self-hosted"]') }}
toolchain: >-
${{ github.event_name == 'push' && github.ref == 'refs/heads/main'
&& fromJSON('["stable","beta","1.75.0"]')
|| fromJSON('["1.75.0"]') }}
exclude:
- platform: windows-latest
toolchain: 1.75.0
- platform: windows-latest
toolchain: beta
- platform: macos-latest
toolchain: beta
runs-on: ${{ matrix.platform }}

build-workspace:
uses: ./.github/workflows/ci-build.yml
with:
script: ci/ci-tests-workspace.sh

build-bindings:
uses: ./.github/workflows/ci-build.yml
with:
script: ci/ci-tests-bindings.sh
install-arm-target: true

build-cfg-flags:
uses: ./.github/workflows/ci-build.yml
with:
script: ci/ci-tests-cfg-flags.sh

build-sync:
uses: ./.github/workflows/ci-build.yml
with:
script: ci/ci-tests-sync.sh
setup-bitcoind: true
ci-env: true

build-complete:
runs-on: ubuntu-latest
needs:
- build-workspace
- build-bindings
- build-cfg-flags
- build-sync
if: always()
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Install Rust ${{ matrix.toolchain }} toolchain
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ matrix.toolchain }}
- name: Use rust-lld linker on Windows
if: matrix.platform == 'windows-latest'
shell: bash
run: echo "RUSTFLAGS=-C linker=rust-lld" >> "$GITHUB_ENV"
- name: Install no-std-check dependencies for ARM Embedded
if: "matrix.platform == 'self-hosted'"
- name: Verify all build jobs succeeded
run: |
rustup target add thumbv7m-none-eabi
- name: shellcheck the CI and `contrib` scripts
if: "matrix.platform == 'self-hosted'"
run: |
shellcheck ci/*.sh -aP ci
shellcheck contrib/*.sh -aP contrib
- name: Set RUSTFLAGS to deny warnings
if: "matrix.toolchain == '1.75.0'"
run: echo "RUSTFLAGS=-D warnings" >> "$GITHUB_ENV"
- name: Enable caching for bitcoind
if: matrix.platform != 'windows-latest'
id: cache-bitcoind
uses: actions/cache@v4
with:
path: bin/bitcoind-${{ runner.os }}-${{ runner.arch }}
key: bitcoind-${{ runner.os }}-${{ runner.arch }}
- name: Enable caching for electrs
if: matrix.platform != 'windows-latest'
id: cache-electrs
uses: actions/cache@v4
with:
path: bin/electrs-${{ runner.os }}-${{ runner.arch }}
key: electrs-${{ runner.os }}-${{ runner.arch }}
- name: Download bitcoind/electrs
if: "matrix.platform != 'windows-latest' && (steps.cache-bitcoind.outputs.cache-hit != 'true' || steps.cache-electrs.outputs.cache-hit != 'true')"
run: |
source ./contrib/download_bitcoind_electrs.sh
mkdir bin
mv "$BITCOIND_EXE" bin/bitcoind-${{ runner.os }}-${{ runner.arch }}
mv "$ELECTRS_EXE" bin/electrs-${{ runner.os }}-${{ runner.arch }}
- name: Set bitcoind/electrs environment variables
if: matrix.platform != 'windows-latest'
run: |
echo "BITCOIND_EXE=$( pwd )/bin/bitcoind-${{ runner.os }}-${{ runner.arch }}" >> "$GITHUB_ENV"
echo "ELECTRS_EXE=$( pwd )/bin/electrs-${{ runner.os }}-${{ runner.arch }}" >> "$GITHUB_ENV"
- name: Run CI script
shell: bash # Default on Winblows is powershell
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh
if [[ "${{ needs.build-workspace.result }}" != "success" ||
"${{ needs.build-bindings.result }}" != "success" ||
"${{ needs.build-cfg-flags.result }}" != "success" ||
"${{ needs.build-sync.result }}" != "success" ]]; then
echo "One or more build jobs failed or were cancelled."
exit 1
fi
echo "All build jobs completed successfully."

coverage:
needs: fuzz
Expand Down Expand Up @@ -305,6 +277,10 @@ jobs:
- name: Install clippy
run: |
rustup component add clippy
- name: shellcheck the CI and `contrib` scripts
run: |
shellcheck ci/*.sh -aP ci
shellcheck contrib/*.sh -aP contrib
- name: Run default clippy linting
run: |
./ci/check-lint.sh
Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: CI Build Job

on:
workflow_call:
inputs:
script:
description: CI script to run (relative to repo root)
required: true
type: string
install-arm-target:
description: Whether to install ARM embedded target
type: boolean
default: false
setup-bitcoind:
description: Whether to set up bitcoind/electrs
type: boolean
default: false
ci-env:
description: Whether to set CI_ENV=1
type: boolean
default: false

jobs:
build:
strategy:
fail-fast: false
matrix:
platform: >-
${{ github.event_name == 'push' && github.ref == 'refs/heads/main'
&& fromJSON('["self-hosted","windows-latest","macos-latest"]')
|| fromJSON('["self-hosted"]') }}
toolchain: >-
${{ github.event_name == 'push' && github.ref == 'refs/heads/main'
&& fromJSON('["stable","beta","1.75.0"]')
|| fromJSON('["1.75.0"]') }}
exclude:
- platform: windows-latest
toolchain: 1.75.0
- platform: windows-latest
toolchain: beta
- platform: macos-latest
toolchain: beta
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Install Rust ${{ matrix.toolchain }} toolchain
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ matrix.toolchain }}
- name: Use rust-lld linker on Windows
if: matrix.platform == 'windows-latest'
shell: bash
run: echo "RUSTFLAGS=-C linker=rust-lld" >> "$GITHUB_ENV"
- name: Set RUSTFLAGS to deny warnings
if: "matrix.toolchain == '1.75.0'"
run: echo "RUSTFLAGS=-D warnings" >> "$GITHUB_ENV"
- name: Install no-std-check dependencies for ARM Embedded
if: inputs.install-arm-target && matrix.platform == 'self-hosted'
run: |
rustup target add thumbv7m-none-eabi
- name: Enable caching for bitcoind
if: inputs.setup-bitcoind && matrix.platform != 'windows-latest'
id: cache-bitcoind
uses: actions/cache@v4
with:
path: bin/bitcoind-${{ runner.os }}-${{ runner.arch }}
key: bitcoind-${{ runner.os }}-${{ runner.arch }}
- name: Enable caching for electrs
if: inputs.setup-bitcoind && matrix.platform != 'windows-latest'
id: cache-electrs
uses: actions/cache@v4
with:
path: bin/electrs-${{ runner.os }}-${{ runner.arch }}
key: electrs-${{ runner.os }}-${{ runner.arch }}
- name: Download bitcoind/electrs
if: >-
inputs.setup-bitcoind && matrix.platform != 'windows-latest'
&& (steps.cache-bitcoind.outputs.cache-hit != 'true'
|| steps.cache-electrs.outputs.cache-hit != 'true')
run: |
source ./contrib/download_bitcoind_electrs.sh
mkdir bin
mv "$BITCOIND_EXE" bin/bitcoind-${{ runner.os }}-${{ runner.arch }}
mv "$ELECTRS_EXE" bin/electrs-${{ runner.os }}-${{ runner.arch }}
- name: Set bitcoind/electrs environment variables
if: inputs.setup-bitcoind && matrix.platform != 'windows-latest'
run: |
echo "BITCOIND_EXE=$( pwd )/bin/bitcoind-${{ runner.os }}-${{ runner.arch }}" >> "$GITHUB_ENV"
echo "ELECTRS_EXE=$( pwd )/bin/electrs-${{ runner.os }}-${{ runner.arch }}" >> "$GITHUB_ENV"
- name: Run CI script
shell: bash
run: ${{ inputs.ci-env && 'CI_ENV=1 ' || '' }}CI_MINIMIZE_DISK_USAGE=1 ./${{ inputs.script }}
56 changes: 56 additions & 0 deletions ci/ci-tests-bindings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
set -eox pipefail

# shellcheck source=ci/ci-tests-common.sh
source "$(dirname "$0")/ci-tests-common.sh"

echo -e "\n\nTesting c_bindings builds"
# Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
# disable doctests in `c_bindings` so we skip doctests entirely here.
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test --quiet --color always --lib --bins --tests

for DIR in lightning-invoice lightning-rapid-gossip-sync; do
# check if there is a conflict between no_std and the c_bindings cfg
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p $DIR --quiet --color always --no-default-features
done

# Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
# disable doctests in `c_bindings` so we skip doctests entirely here.
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p lightning-background-processor --quiet --color always --no-default-features --lib --bins --tests
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p lightning --quiet --color always --no-default-features --lib --bins --tests

echo -e "\n\nTesting no_std builds"
for DIR in lightning-invoice lightning-rapid-gossip-sync lightning-liquidity; do
cargo test -p $DIR --quiet --color always --no-default-features
done

cargo test -p lightning --quiet --color always --no-default-features
cargo test -p lightning-background-processor --quiet --color always --no-default-features

echo -e "\n\nTesting other crate-specific builds"
# Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
RUSTFLAGS="$RUSTFLAGS --cfg=ldk_test_vectors" cargo test -p lightning --quiet --color always --no-default-features --features=std
# This one only works for lightning-invoice
# check that compile with no_std and serde works in lightning-invoice
cargo test -p lightning-invoice --quiet --color always --no-default-features --features serde

echo -e "\n\nTesting no_std build on a downstream no-std crate"
# check no-std compatibility across dependencies
pushd no-std-check
cargo check --quiet --color always
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
popd

# Test that we can build downstream code with only the "release pins".
pushd msrv-no-dev-deps-check
PIN_RELEASE_DEPS
cargo check --quiet
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
popd

if [ -f "$(which arm-none-eabi-gcc)" ]; then
pushd no-std-check
cargo build --quiet --target=thumbv7m-none-eabi
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
popd
fi
14 changes: 14 additions & 0 deletions ci/ci-tests-cfg-flags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -eox pipefail

# shellcheck source=ci/ci-tests-common.sh
source "$(dirname "$0")/ci-tests-common.sh"

echo -e "\n\nTest cfg-flag builds"
RUSTFLAGS="--cfg=taproot" cargo test --quiet --color always -p lightning
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
RUSTFLAGS="--cfg=simple_close" cargo test --quiet --color always -p lightning
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
RUSTFLAGS="--cfg=lsps1_service" cargo test --quiet --color always -p lightning-liquidity
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
RUSTFLAGS="--cfg=peer_storage" cargo test --quiet --color always -p lightning
23 changes: 23 additions & 0 deletions ci/ci-tests-common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
# ci/ci-tests-common.sh - Shared helpers for CI test scripts.
# Source this file; do not execute it directly.
# shellcheck disable=SC2002,SC2207

RUSTC_MINOR_VERSION=$(rustc --version | awk '{ split($2,a,"."); print a[2] }')

# Some crates require pinning to meet our MSRV even for our downstream users,
# which we do here.
# Further crates which appear only as dev-dependencies are pinned further down.
function PIN_RELEASE_DEPS {
return 0 # Don't fail the script if our rustc is higher than the last check
}

PIN_RELEASE_DEPS # pin the release dependencies in our main workspace

# The backtrace v0.3.75 crate relies on rustc 1.82
[ "$RUSTC_MINOR_VERSION" -lt 82 ] && cargo update -p backtrace --precise "0.3.74" --quiet

# Starting with version 1.2.0, the `idna_adapter` crate has an MSRV of rustc 1.81.0.
[ "$RUSTC_MINOR_VERSION" -lt 81 ] && cargo update -p idna_adapter --precise "1.1.0" --quiet

export RUST_BACKTRACE=1
33 changes: 33 additions & 0 deletions ci/ci-tests-sync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
set -eox pipefail

# shellcheck source=ci/ci-tests-common.sh
source "$(dirname "$0")/ci-tests-common.sh"

echo -e "\n\nChecking and testing Block Sync Clients with features"

cargo test -p lightning-block-sync --quiet --color always --features rest-client
cargo check -p lightning-block-sync --quiet --color always --features rest-client
cargo test -p lightning-block-sync --quiet --color always --features rpc-client
cargo check -p lightning-block-sync --quiet --color always --features rpc-client
cargo test -p lightning-block-sync --quiet --color always --features rpc-client,rest-client
cargo check -p lightning-block-sync --quiet --color always --features rpc-client,rest-client
cargo test -p lightning-block-sync --quiet --color always --features rpc-client,rest-client,tokio
cargo check -p lightning-block-sync --quiet --color always --features rpc-client,rest-client,tokio

echo -e "\n\nChecking Transaction Sync Clients with features."
cargo check -p lightning-transaction-sync --quiet --color always --features esplora-blocking
cargo check -p lightning-transaction-sync --quiet --color always --features esplora-async
cargo check -p lightning-transaction-sync --quiet --color always --features esplora-async-https
cargo check -p lightning-transaction-sync --quiet --color always --features electrum

if [ -z "$CI_ENV" ] && [[ -z "$BITCOIND_EXE" || -z "$ELECTRS_EXE" ]]; then
echo -e "\n\nSkipping testing Transaction Sync Clients due to BITCOIND_EXE or ELECTRS_EXE being unset."
cargo check -p lightning-transaction-sync --tests
else
echo -e "\n\nTesting Transaction Sync Clients with features."
cargo test -p lightning-transaction-sync --quiet --color always --features esplora-blocking
cargo test -p lightning-transaction-sync --quiet --color always --features esplora-async
cargo test -p lightning-transaction-sync --quiet --color always --features esplora-async-https
cargo test -p lightning-transaction-sync --quiet --color always --features electrum
fi
42 changes: 42 additions & 0 deletions ci/ci-tests-workspace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
#shellcheck disable=SC2002,SC2207
set -eox pipefail

# shellcheck source=ci/ci-tests-common.sh
source "$(dirname "$0")/ci-tests-common.sh"

echo -e "\n\nChecking the workspace, except lightning-transaction-sync."
cargo check --quiet --color always

WORKSPACE_MEMBERS=( $(cat Cargo.toml | tr '\n' '\r' | sed 's/\r //g' | tr '\r' '\n' | grep '^members =' | sed 's/members.*=.*\[//' | tr -d '"' | tr ',' ' ') )

echo -e "\n\nTesting the workspace, except lightning-transaction-sync."
cargo test --quiet --color always

echo -e "\n\nTesting upgrade from prior versions of LDK"
pushd lightning-tests
cargo test --quiet
popd

echo -e "\n\nChecking and building docs for all workspace members individually..."
for DIR in "${WORKSPACE_MEMBERS[@]}"; do
cargo check -p "$DIR" --quiet --color always
cargo doc -p "$DIR" --quiet --document-private-items
done

echo -e "\n\nChecking and testing lightning with features"
cargo test -p lightning --quiet --color always --features dnssec
cargo check -p lightning --quiet --color always --features dnssec
cargo doc -p lightning --quiet --document-private-items --features dnssec

echo -e "\n\nChecking and testing lightning-persister with features"
cargo test -p lightning-persister --quiet --color always --features tokio
cargo check -p lightning-persister --quiet --color always --features tokio
cargo doc -p lightning-persister --quiet --document-private-items --features tokio

echo -e "\n\nTest Custom Message Macros"
cargo test -p lightning-custom-message --quiet --color always
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean

echo -e "\n\nTest backtrace-debug builds"
cargo test -p lightning --quiet --color always --features backtrace
Loading
Loading