This repository has been archived by the owner on Mar 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
212 lines (178 loc) · 6.78 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: CI
on:
push:
branches:
- 'staging'
- 'trying'
- 'master'
- 'dev'
pull_request:
jobs:
static_analysis:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install Rust
id: toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
- name: Install NodeJS 14.x
uses: actions/setup-node@v1
with:
node-version: '14.x'
- name: Cache cargo registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
# The registry cache is useful as long as we need the same dependencies as another job, regardless of the Rust version and operating system.
key: cargo-registry-${{ hashFiles('Cargo.lock') }}-v2
- name: Cache dprint plugins
uses: actions/cache@v2
with:
path: ~/.cache/dprint/cache/plugins
key: dprint-plugins-${{ hashFiles('.dprintrc.json') }}
- name: Cache cargo binaries
uses: actions/cache@v2
with:
path: ~/.cargo/bin
# The cargo binary cache is useful as long as we use the same Rust version but regardless of our dependencies.
key: ubuntu-latest-cargo-binaries-${{ steps.toolchain.outputs.rustc_hash }}-v3
- name: Cache target directory
uses: actions/cache@v2
with:
path: target
# The target directory is only useful with the same Rust version, dependencies and operating system.
key: ubuntu-latest-target-${{ steps.toolchain.outputs.rustc_hash }}-${{ hashFiles('Cargo.lock') }}-clippy-v2
- name: Install dprint
run: |
curl -fsSL https://dprint.dev/install.sh | sh
echo "/home/runner/.dprint/bin" >> $GITHUB_PATH
- name: Check formatting
run: dprint check
- name: Run linter
run: make lint
build:
strategy:
matrix:
target: [x86_64-unknown-linux-gnu, armv7-unknown-linux-gnueabihf, x86_64-apple-darwin, x86_64-pc-windows-gnu]
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
test_features: testcontainers
- target: armv7-unknown-linux-gnueabihf
os: ubuntu-latest
# This target is only for cross-compiling, skip all tests.
skip_unit_tests: true
skip_e2e_tests: true
- target: x86_64-apple-darwin
os: macos-latest
skip_e2e_tests: true
- target: x86_64-pc-windows-gnu
os: windows-latest
skip_e2e_tests: true # Our e2e test framework doesn't work on windows.
file_ext: .exe
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
id: toolchain
with:
profile: minimal
override: true
target: ${{ matrix.target }}
- name: Install compiler for armhf arch
if: matrix.target == 'armv7-unknown-linux-gnueabihf'
run: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf
- name: Cache cargo registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
# The registry cache is useful as long as we need the same dependencies as another job, regardless of the Rust version and operating system.
key: cargo-registry-${{ hashFiles('Cargo.lock') }}-v3
- name: Cache cargo binaries
uses: actions/cache@v2
with:
path: ~/.cargo/bin
# The cargo binary cache is useful as long as we use the same Rust version and operating system, but regardless of our dependencies.
key: ${{ matrix.os }}-cargo-binaries-${{ steps.toolchain.outputs.rustc_hash }}-v2
- name: Cache target directory
uses: actions/cache@v2
if: matrix.os == 'ubuntu-latest'
with:
path: target
# The target directory is only useful with the same Rust version, dependencies and operating system.
key: ${{ matrix.target }}-target-${{ steps.toolchain.outputs.rustc_hash }}-${{ hashFiles('Cargo.lock') }}-build-v3
- name: Build docs
run: cargo doc
- name: Run unit tests
if: (!matrix.skip_unit_tests)
shell: bash
run: |
(cd ./comit; cargo test --features "${{ matrix.test_features }}")
(cd ./cnd; cargo test)
(cd ./nectar; cargo test --features "${{ matrix.test_features }}")
- name: Build binaries
env:
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc
run: |
cargo build -p cnd --target ${{ matrix.target }}
cargo build -p nectar --target ${{ matrix.target }}
- name: Upload cnd binary
uses: actions/upload-artifact@v1
with:
name: cnd-${{ matrix.target }}
path: target/${{ matrix.target }}/debug/cnd${{ matrix.file_ext }}
- name: Upload nectar binary
uses: actions/upload-artifact@v1
with:
name: nectar-${{ matrix.target }}
path: target/${{ matrix.target }}/debug/nectar${{ matrix.file_ext }}
- name: Install NodeJS 14.x
if: (!matrix.skip_e2e_tests)
uses: actions/setup-node@v1
with:
node-version: '14.x'
- name: Cache node_modules directory
if: (!matrix.skip_e2e_tests)
uses: actions/cache@v2
with:
path: tests/node_modules
key: ${{ matrix.os }}-node-14-node-modules-directory-${{ hashFiles('tests/package.json') }}
- name: Run e2e tests
if: (!matrix.skip_e2e_tests)
run: |
export PATH=$HOME/.cargo/bin:$HOME/.local/bin:$PATH
cd tests
yarn install
yarn test
- name: Upload bitcoind log
if: (!matrix.skip_e2e_tests) && failure()
uses: actions/upload-artifact@v2-preview
with:
name: ${{ matrix.os }}-e2e-logs-bitcoind.log
path: tests/log/bitcoind/regtest/debug.log
- name: Upload parity log
if: (!matrix.skip_e2e_tests) && failure()
uses: actions/upload-artifact@v2-preview
with:
name: ${{ matrix.os }}-e2e-logs-parity.log
path: tests/log/parity/parity.log
- name: Upload lnd logs
if: (!matrix.skip_e2e_tests) && failure()
uses: actions/upload-artifact@v2-preview
with:
name: ${{ matrix.os }}-e2e-logs-lnd
path: tests/log/lnd-*/logs/bitcoin/regtest/lnd.log
- name: Upload e2e logs
if: (!matrix.skip_e2e_tests) && failure()
uses: actions/upload-artifact@v2-preview
with:
name: ${{ matrix.os }}-e2e-test-logs
path: tests/log/tests/