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
99 changes: 27 additions & 72 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,77 +26,28 @@ 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 }}
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'"
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

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

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

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

coverage:
needs: fuzz
Expand Down Expand Up @@ -305,6 +256,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 Expand Up @@ -344,7 +299,7 @@ jobs:
TOR_PROXY="127.0.0.1:9050" RUSTFLAGS="--cfg=tor" cargo test --verbose --color always -p lightning-net-tokio

notify-failure:
needs: [build, fuzz, linting, rustfmt, check_release, check_docs, benchmark, ext-test, tor-connect, coverage]
needs: [build-workspace, build-bindings, build-nostd-and-cfg, build-sync, fuzz, linting, rustfmt, check_release, check_docs, benchmark, ext-test, tor-connect, coverage]
if: failure() && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
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

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: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./${{ inputs.script }}
25 changes: 25 additions & 0 deletions ci/ci-tests-bindings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -eox pipefail

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

ci_step_start "Test c_bindings full workspace"
# 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
ci_step_end

ci_step_start "Test c_bindings no-default-features per crate"
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
ci_step_end

ci_print_summary
49 changes: 49 additions & 0 deletions ci/ci-tests-common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/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

CI_STEP_START_TIME=""
CI_STEP_NAME=""
CI_SUMMARY=""

function ci_step_start {
CI_STEP_NAME="$1"
CI_STEP_START_TIME=$(date +%s)
echo "::group::$CI_STEP_NAME"
}

function ci_step_end {
local elapsed=$(( $(date +%s) - CI_STEP_START_TIME ))
local mins=$(( elapsed / 60 ))
local secs=$(( elapsed % 60 ))
echo "::endgroup::"
echo "TIMING: ${CI_STEP_NAME} completed in ${mins}m ${secs}s"
CI_SUMMARY="${CI_SUMMARY}${mins}m ${secs}s ${CI_STEP_NAME}\n"
}

function ci_print_summary {
echo ""
echo "===== TIMING SUMMARY ====="
echo -e "$CI_SUMMARY"
echo "=========================="
}
69 changes: 69 additions & 0 deletions ci/ci-tests-nostd-and-cfg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash
set -eox pipefail

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

ci_step_start "Test 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
ci_step_end

ci_step_start "Test ldk_test_vectors and serde"
# 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
ci_step_end

ci_step_start "Test no-std-check downstream crate"
# check no-std compatibility across dependencies
pushd no-std-check
cargo check --quiet --color always
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
popd
ci_step_end

ci_step_start "Test msrv-no-dev-deps-check"
# 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
ci_step_end

if [ -f "$(which arm-none-eabi-gcc)" ]; then
ci_step_start "Build no-std-check for ARM"
pushd no-std-check
cargo build --quiet --target=thumbv7m-none-eabi
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
popd
ci_step_end
fi

ci_step_start "Test taproot cfg flag"
RUSTFLAGS="--cfg=taproot" cargo test --quiet --color always -p lightning
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
ci_step_end

ci_step_start "Test simple_close cfg flag"
RUSTFLAGS="--cfg=simple_close" cargo test --quiet --color always -p lightning
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
ci_step_end

ci_step_start "Test lsps1_service cfg flag"
RUSTFLAGS="--cfg=lsps1_service" cargo test --quiet --color always -p lightning-liquidity
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
ci_step_end

ci_step_start "Test peer_storage cfg flag"
RUSTFLAGS="--cfg=peer_storage" cargo test --quiet --color always -p lightning
ci_step_end

ci_print_summary
Loading