Add subcrate which impls a simple SPV client from Bitcoin Core RPC
[rust-lightning] / .github / workflows / build.yml
1 name: Continuous Integration Checks
2
3 on: [push, pull_request]
4
5 jobs:
6   build:
7     strategy:
8       matrix:
9         toolchain: [ stable,
10                      nightly,
11                      # 1.22.0 is MSRV for rust-lightning in general:
12                      1.22.0,
13                      # 1.34.2 is Debian stable
14                      1.34.2,
15                      # 1.39.0 is MSRV for lightning-net-tokio and lightning-block-sync and generates coverage
16                      1.39.0]
17         include:
18           - toolchain: stable
19             build-net-tokio: true
20           - toolchain: nightly
21             build-net-tokio: true
22             run-mutagen: true
23           - toolchain: 1.39.0
24             build-net-tokio: true
25             coverage: true
26     runs-on: ubuntu-latest
27     steps:
28       - name: Checkout source code
29         uses: actions/checkout@v2
30       - name: Install Rust ${{ matrix.toolchain }} toolchain
31         uses: actions-rs/toolchain@v1
32         with:
33           toolchain: ${{ matrix.toolchain }}
34           override: true
35           profile: minimal
36       - name: Build on Rust ${{ matrix.toolchain }} with net-tokio
37         if: matrix.build-net-tokio
38         run: RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always
39       - name: Build on Rust ${{ matrix.toolchain }}
40         if: "! matrix.build-net-tokio"
41         run: RUSTFLAGS="-C link-dead-code" cargo build --verbose  --color always -p lightning
42       - name: Build Block Sync Clients on Rust ${{ matrix.toolchain }} with features
43         if: matrix.build-net-tokio
44         run: |
45           cd lightning-block-sync
46           RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rest-client
47           RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client
48           RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client,rest-client
49           RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client,rest-client,tokio
50           cd ..
51       - name: Test on Rust ${{ matrix.toolchain }} with net-tokio
52         if: matrix.build-net-tokio
53         run: RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always
54       - name: Test on Rust ${{ matrix.toolchain }}
55         if: "! matrix.build-net-tokio"
56         run: RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always  -p lightning
57       - name: Run mutagen tests on ${{ matrix.toolchain }}
58         if: matrix.run-mutagen
59      # Run mutagen on nightly with TheBlueMatt's fork which exits with non-0 status
60      # if any mutations resulted in anything except test failures to prevent regressions.
61         run: |
62           rm -rf mutagen && git clone https://github.com/TheBlueMatt/mutagen
63           cargo install --force --path mutagen/mutagen-runner
64           cd lightning
65           ~/.cargo/bin/cargo-mutagen --features mutation_testing
66      # Generate code cov information on Rust 1.39.0
67       - name: Install deps for kcov
68         if: matrix.coverage
69         run: |
70           sudo apt-get update
71           sudo apt-get -y install binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev
72       - name: Install kcov
73         if: matrix.coverage
74         run: |
75           wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz
76           tar xzf master.tar.gz
77           cd kcov-master && mkdir build && cd build
78           cmake ..
79           make
80           make install DESTDIR=../../kcov-build
81           cd ../.. && rm -rf kcov-master master.tar.gz
82       - name: Generate coverage report
83         if: matrix.coverage
84         run: |
85           for file in target/debug/lightning-*; do
86             [ -x "${file}" ] || continue;
87             mkdir -p "target/cov/$(basename $file)";
88             ./kcov-build/usr/local/bin/kcov --exclude-pattern=/.cargo,/usr/lib --verify "target/cov/$(basename $file)" "$file";
89           done
90       - name: Upload coverage
91         if: matrix.coverage
92         uses: codecov/codecov-action@v1
93         with:
94           fail_ci_if_error: true
95
96   fuzz:
97     runs-on: ubuntu-latest
98     env:
99       TOOLCHAIN: stable
100     steps:
101       - name: Checkout source code
102         uses: actions/checkout@v2
103       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
104         uses: actions-rs/toolchain@v1
105         with:
106           toolchain: ${{ env.TOOLCHAIN }}
107           override: true
108           profile: minimal
109       - name: Install dependencies for honggfuzz
110         run: |
111           sudo apt-get update
112           sudo apt-get -y install build-essential binutils-dev libunwind-dev
113       - name: Sanity check fuzz targets on Rust ${{ env.TOOLCHAIN }}
114         run: cd fuzz && cargo test --verbose --color always
115       - name: Run fuzzers
116         run: cd fuzz && ./ci-fuzz.sh