50a3b7c04218d7c6c68655410ee9c1f9badc84e4
[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 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: Test on Rust ${{ matrix.toolchain }} with net-tokio
43         if: matrix.build-net-tokio
44         run: RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always
45       - name: Test on Rust ${{ matrix.toolchain }}
46         if: "! matrix.build-net-tokio"
47         run: RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always  -p lightning
48       - name: Run mutagen tests on ${{ matrix.toolchain }}
49         if: matrix.run-mutagen
50      # Run mutagen on nightly with TheBlueMatt's fork which exits with non-0 status
51      # if any mutations resulted in anything except test failures to prevent regressions.
52         run: |
53           rm -rf mutagen && git clone https://github.com/TheBlueMatt/mutagen
54           cargo install --force --path mutagen/mutagen-runner
55           cd lightning
56           ~/.cargo/bin/cargo-mutagen --features mutation_testing
57      # Generate code cov information on Rust 1.39.0
58       - name: Install deps for kcov
59         if: matrix.coverage
60         run: |
61           sudo apt-get update
62           sudo apt-get -y install binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev
63       - name: Install kcov
64         if: matrix.coverage
65         run: |
66           wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz
67           tar xzf master.tar.gz
68           cd kcov-master && mkdir build && cd build
69           cmake ..
70           make
71           make install DESTDIR=../../kcov-build
72           cd ../.. && rm -rf kcov-master master.tar.gz
73       - name: Generate coverage report
74         if: matrix.coverage
75         run: |
76           for file in target/debug/lightning-*; do
77             [ -x "${file}" ] || continue;
78             mkdir -p "target/cov/$(basename $file)";
79             ./kcov-build/usr/local/bin/kcov --exclude-pattern=/.cargo,/usr/lib --verify "target/cov/$(basename $file)" "$file";
80           done
81       - name: Upload coverage
82         if: matrix.coverage
83         uses: codecov/codecov-action@v1
84         with:
85           fail_ci_if_error: true
86
87   fuzz:
88     runs-on: ubuntu-latest
89     env:
90       TOOLCHAIN: stable
91     steps:
92       - name: Checkout source code
93         uses: actions/checkout@v2
94       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
95         uses: actions-rs/toolchain@v1
96         with:
97           toolchain: ${{ env.TOOLCHAIN }}
98           override: true
99           profile: minimal
100       - name: Install dependencies for honggfuzz
101         run: |
102           sudo apt-get update
103           sudo apt-get -y install build-essential binutils-dev libunwind-dev
104       - name: Sanity check fuzz targets on Rust ${{ env.TOOLCHAIN }}
105         run: cd fuzz && cargo test --verbose --color always
106       - name: Run fuzzers
107         run: cd fuzz && ./ci-fuzz.sh