98f4f19a4d6a898f78859c2aa4d1466beee1cf88
[rust-lightning] / .github / workflows / build.yml
1 name: Continuous Integration Checks
2
3 on:
4   push:
5
6 jobs:
7   build:
8     strategy:
9       matrix:
10         toolchain: [ stable,
11                      beta,
12                      # 1.22.0 is MSRV for rust-lightning in general:
13                      1.22.0,
14                      # 1.34.2 is Debian stable
15                      1.34.2,
16                      # 1.39.0 is MSRV for lightning-net-tokio and generates coverage
17                      1.39.0]
18         include:
19           - toolchain: stable
20             build-net-tokio: true
21           - toolchain: beta
22             build-net-tokio: 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: Install deps for kcov
49         if: matrix.coverage
50         run: |
51           sudo apt-get update
52           sudo apt-get -y install binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev
53       - name: Install kcov
54         if: matrix.coverage
55         run: |
56           wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz
57           tar xzf master.tar.gz
58           cd kcov-master && mkdir build && cd build
59           cmake ..
60           make
61           make install DESTDIR=../../kcov-build
62           cd ../.. && rm -rf kcov-master master.tar.gz
63       - name: Generate coverage report
64         if: matrix.coverage
65         run: |
66           for file in target/debug/lightning-*; do
67             [ -x "${file}" ] || continue;
68             mkdir -p "target/cov/$(basename $file)";
69             ./kcov-build/usr/local/bin/kcov --exclude-pattern=/.cargo,/usr/lib --verify "target/cov/$(basename $file)" "$file";
70           done
71       - name: Upload coverage
72         if: matrix.coverage
73         uses: codecov/codecov-action@v1
74         with:
75           fail_ci_if_error: true
76
77   fuzz:
78     runs-on: ubuntu-latest
79     env:
80       TOOLCHAIN: stable
81     steps:
82       - name: Checkout source code
83         uses: actions/checkout@v2
84       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
85         uses: actions-rs/toolchain@v1
86         with:
87           toolchain: ${{ env.TOOLCHAIN }}
88           override: true
89           profile: minimal
90       - name: Install dependencies for honggfuzz
91         run: |
92           sudo apt-get update
93           sudo apt-get -y install build-essential binutils-dev libunwind-dev
94       - name: Fuzz test on Rust ${{ matrix.TOOLCHAIN }}
95         run: cd fuzz && cargo test --verbose --color always
96       - name: Generate fuzz report
97         run: cd fuzz && ./ci-fuzz.sh