Remove unnecessary include in Github Actions script.
[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     runs-on: ubuntu-latest
26     steps:
27       - name: Checkout source code
28         uses: actions/checkout@v2
29       - name: Install Rust ${{ matrix.toolchain }} toolchain
30         uses: actions-rs/toolchain@v1
31         with:
32           toolchain: ${{ matrix.toolchain }}
33           override: true
34           profile: minimal
35       - name: Build on Rust ${{ matrix.toolchain }} with net-tokio
36         if: "matrix.build-net-tokio && !matrix.coverage"
37         run: cargo build --verbose --color always
38       - name: Build on Rust ${{ matrix.toolchain }} with net-tokio and full code-linking for coverage generation
39         if: matrix.coverage
40         run: RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always
41       - name: Build on Rust ${{ matrix.toolchain }}
42         if: "! matrix.build-net-tokio"
43         run: cargo build --verbose  --color always -p lightning
44       - name: Test on Rust ${{ matrix.toolchain }} with net-tokio
45         if: "matrix.build-net-tokio && !matrix.coverage"
46         run: cargo test --verbose --color always
47       - name: Test on Rust ${{ matrix.toolchain }} with net-tokio and full code-linking for coverage generation
48         if: matrix.coverage
49         run: RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always
50       - name: Test on Rust ${{ matrix.toolchain }}
51         if: "! matrix.build-net-tokio"
52         run: cargo test --verbose --color always  -p lightning
53       - name: Install deps for kcov
54         if: matrix.coverage
55         run: |
56           sudo apt-get update
57           sudo apt-get -y install binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev
58       - name: Install kcov
59         if: matrix.coverage
60         run: |
61           wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz
62           tar xzf master.tar.gz
63           cd kcov-master && mkdir build && cd build
64           cmake ..
65           make
66           make install DESTDIR=../../kcov-build
67           cd ../.. && rm -rf kcov-master master.tar.gz
68       - name: Generate coverage report
69         if: matrix.coverage
70         run: |
71           for file in target/debug/lightning-*; do
72             [ -x "${file}" ] || continue;
73             mkdir -p "target/cov/$(basename $file)";
74             ./kcov-build/usr/local/bin/kcov --exclude-pattern=/.cargo,/usr/lib --verify "target/cov/$(basename $file)" "$file";
75           done
76       - name: Upload coverage
77         if: matrix.coverage
78         uses: codecov/codecov-action@v1
79         with:
80           # Could you use this to fake the coverage report for your PR? Sure.
81           # Will anyone be impressed by your amazing coverage? No
82           # Maybe if codecov wasn't broken we wouldn't need to do this...
83           token: f421b687-4dc2-4387-ac3d-dc3b2528af57
84           fail_ci_if_error: true
85
86   check_commits:
87     runs-on: ubuntu-latest
88     env:
89       TOOLCHAIN: stable
90     steps:
91       - name: Checkout source code
92         uses: actions/checkout@v2
93         with:
94           fetch-depth: 0
95       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
96         uses: actions-rs/toolchain@v1
97         with:
98           toolchain: ${{ env.TOOLCHAIN }}
99           override: true
100           profile: minimal
101       - name: Fetch full tree and rebase on upstream
102         run: |
103           git remote add upstream https://github.com/rust-bitcoin/rust-lightning
104           git fetch upstream
105           git rebase upstream/main
106       - name: For each commit, run cargo check (including in fuzz)
107         run: ci/check-each-commit.sh upstream/main
108
109   fuzz:
110     runs-on: ubuntu-latest
111     env:
112       TOOLCHAIN: stable
113     steps:
114       - name: Checkout source code
115         uses: actions/checkout@v2
116       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
117         uses: actions-rs/toolchain@v1
118         with:
119           toolchain: ${{ env.TOOLCHAIN }}
120           override: true
121           profile: minimal
122       - name: Install dependencies for honggfuzz
123         run: |
124           sudo apt-get update
125           sudo apt-get -y install build-essential binutils-dev libunwind-dev
126       - name: Sanity check fuzz targets on Rust ${{ env.TOOLCHAIN }}
127         run: cd fuzz && cargo test --verbose --color always
128       - name: Run fuzzers
129         run: cd fuzz && ./ci-fuzz.sh
130
131   check_bindings:
132     runs-on: ubuntu-latest
133     # Ubuntu's version of rustc uses its own LLVM instead of being a real native package.
134     # This leaves us with an incompatible LLVM version when linking. Instead, use a real OS.
135     # We further (temporarily) use Debian experimental since testing links rustc against the
136     # brand-new llvm-10, but clang/llvm still default to LLVM 9.
137     container: debian:experimental
138     env:
139       TOOLCHAIN: stable
140     steps:
141       - name: Install native Rust toolchain, Valgrind, and build utilitis
142         run: |
143           echo 'Package: llvm llvm-runtime clang lld' > /etc/apt/preferences.d/99-llvm10
144           echo 'Pin: release n=experimental' >> /etc/apt/preferences.d/99-llvm10
145           echo 'Pin-Priority: 995' >> /etc/apt/preferences.d/99-llvm10
146           apt-get update
147           apt-get -y dist-upgrade
148           apt-get -y install cargo valgrind lld git g++ clang
149       - name: Checkout source code
150         uses: actions/checkout@v2
151       - name: Sanity test bindings
152         working-directory: lightning-c-bindings
153         run: cargo check
154       - name: Install cbindgen
155         run: cargo install --force cbindgen
156       - name: Rebuild bindings, and check the sample app builds + links
157         run: ./genbindings.sh
158       - name: Check that the latest bindings are in git
159         run: |
160           if [ "$(git diff)" != "" ]; then
161             # cbindgen's bindings output order can be FS-dependant, so check that the lines are all the same:
162             mv lightning-c-bindings/include/lightning.h lightning-c-bindings/include/lightning.h.new
163             git checkout lightning-c-bindings/include/lightning.h
164             cat lightning-c-bindings/include/lightning.h | sort > lightning-c-bindings/include/lightning.h.sorted
165             cat lightning-c-bindings/include/lightning.h.new | sort > lightning-c-bindings/include/lightning.h.new.sorted
166             diff lightning-c-bindings/include/lightning.h.sorted lightning-c-bindings/include/lightning.h.new.sorted
167             #
168             mv lightning-c-bindings/include/lightningpp.hpp lightning-c-bindings/include/lightningpp.hpp.new
169             git checkout lightning-c-bindings/include/lightningpp.hpp
170             cat lightning-c-bindings/include/lightningpp.hpp | sort > lightning-c-bindings/include/lightningpp.hpp.sorted
171             cat lightning-c-bindings/include/lightningpp.hpp.new | sort > lightning-c-bindings/include/lightningpp.hpp.new.sorted
172             diff lightning-c-bindings/include/lightningpp.hpp.sorted lightning-c-bindings/include/lightningpp.hpp.new.sorted
173             #
174             [ "$(diff lightning-c-bindings/include/lightning.h.sorted lightning-c-bindings/include/lightning.h.new.sorted)" != "" ] && exit 2
175             [ "$(diff lightning-c-bindings/include/lightningpp.hpp.sorted lightning-c-bindings/include/lightningpp.hpp.new.sorted)" != "" ] && exit 3
176             git diff --exit-code
177           fi