Merge pull request #679 from ariard/2020-08-concurrent-watchtowers
[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                      beta,
11                      # 1.30.0 is MSRV for Rust-Lightning
12                      1.30.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: beta
21             build-net-tokio: true
22           - toolchain: 1.39.0
23             build-net-tokio: true
24             coverage: true
25           - toolchain: 1.34.2
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           # Could you use this to fake the coverage report for your PR? Sure.
76           # Will anyone be impressed by your amazing coverage? No
77           # Maybe if codecov wasn't broken we wouldn't need to do this...
78           token: f421b687-4dc2-4387-ac3d-dc3b2528af57
79           fail_ci_if_error: true
80
81   check_commits:
82     runs-on: ubuntu-latest
83     env:
84       TOOLCHAIN: stable
85     steps:
86       - name: Checkout source code
87         uses: actions/checkout@v2
88         with:
89           fetch-depth: 0
90       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
91         uses: actions-rs/toolchain@v1
92         with:
93           toolchain: ${{ env.TOOLCHAIN }}
94           override: true
95           profile: minimal
96       - name: Fetch full tree and rebase on upstream
97         run: |
98           git remote add upstream https://github.com/rust-bitcoin/rust-lightning
99           git fetch upstream
100           git rebase upstream/main
101       - name: For each commit, run cargo check (including in fuzz)
102         run: ci/check-each-commit.sh upstream/main
103
104   fuzz:
105     runs-on: ubuntu-latest
106     env:
107       TOOLCHAIN: stable
108     steps:
109       - name: Checkout source code
110         uses: actions/checkout@v2
111       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
112         uses: actions-rs/toolchain@v1
113         with:
114           toolchain: ${{ env.TOOLCHAIN }}
115           override: true
116           profile: minimal
117       - name: Install dependencies for honggfuzz
118         run: |
119           sudo apt-get update
120           sudo apt-get -y install build-essential binutils-dev libunwind-dev
121       - name: Sanity check fuzz targets on Rust ${{ env.TOOLCHAIN }}
122         run: cd fuzz && cargo test --verbose --color always
123       - name: Run fuzzers
124         run: cd fuzz && ./ci-fuzz.sh
125
126   check_bindings:
127     runs-on: ubuntu-latest
128     # Ubuntu's version of rustc uses its own LLVM instead of being a real native package.
129     # This leaves us with an incompatible LLVM version when linking. Instead, use a real OS.
130     # We further (temporarily) use Debian experimental since testing links rustc against the
131     # brand-new llvm-10, but clang/llvm still default to LLVM 9.
132     container: debian:experimental
133     env:
134       TOOLCHAIN: stable
135     steps:
136       - name: Install native Rust toolchain, Valgrind, and build utilitis
137         run: |
138           echo 'Package: llvm llvm-runtime clang lld' > /etc/apt/preferences.d/99-llvm10
139           echo 'Pin: release n=experimental' >> /etc/apt/preferences.d/99-llvm10
140           echo 'Pin-Priority: 995' >> /etc/apt/preferences.d/99-llvm10
141           apt-get update
142           apt-get -y dist-upgrade
143           apt-get -y install cargo valgrind lld git g++ clang
144       - name: Checkout source code
145         uses: actions/checkout@v2
146       - name: Sanity test bindings
147         working-directory: lightning-c-bindings
148         run: cargo check
149       - name: Install cbindgen
150         run: cargo install --force cbindgen
151       - name: Rebuild bindings, and check the sample app builds + links
152         run: ./genbindings.sh
153       - name: Check that the latest bindings are in git
154         run: |
155           if [ "$(git diff)" != "" ]; then
156             # cbindgen's bindings output order can be FS-dependant, so check that the lines are all the same:
157             mv lightning-c-bindings/include/lightning.h lightning-c-bindings/include/lightning.h.new
158             git checkout lightning-c-bindings/include/lightning.h
159             cat lightning-c-bindings/include/lightning.h | sort > lightning-c-bindings/include/lightning.h.sorted
160             cat lightning-c-bindings/include/lightning.h.new | sort > lightning-c-bindings/include/lightning.h.new.sorted
161             diff lightning-c-bindings/include/lightning.h.sorted lightning-c-bindings/include/lightning.h.new.sorted
162             #
163             mv lightning-c-bindings/include/lightningpp.hpp lightning-c-bindings/include/lightningpp.hpp.new
164             git checkout lightning-c-bindings/include/lightningpp.hpp
165             cat lightning-c-bindings/include/lightningpp.hpp | sort > lightning-c-bindings/include/lightningpp.hpp.sorted
166             cat lightning-c-bindings/include/lightningpp.hpp.new | sort > lightning-c-bindings/include/lightningpp.hpp.new.sorted
167             diff lightning-c-bindings/include/lightningpp.hpp.sorted lightning-c-bindings/include/lightningpp.hpp.new.sorted
168             #
169             [ "$(diff lightning-c-bindings/include/lightning.h.sorted lightning-c-bindings/include/lightning.h.new.sorted)" != "" ] && exit 2
170             [ "$(diff lightning-c-bindings/include/lightningpp.hpp.sorted lightning-c-bindings/include/lightningpp.hpp.new.sorted)" != "" ] && exit 3
171             git diff --exit-code
172           fi