-
Notifications
You must be signed in to change notification settings - Fork 23
334 lines (316 loc) · 11.1 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
name: CI
on:
pull_request:
merge_group:
push:
branches:
- "staging"
- "main"
env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
FLUTTER_VERSION: "3.19.1"
jobs:
formatting-dprint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- uses: dprint/[email protected]
generate-ffi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: extractions/setup-just@v1
- name: Setup rust toolchain
run: rustup show
- uses: Swatinem/[email protected]
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: "stable"
cache: true
cache-key: flutter-${{ env.FLUTTER_VERSION }}
cache-path: ${{ runner.tool_cache }}/flutter
- name: Install FFI bindings
run: just deps-gen
- name: Generate FFI bindings
run: just gen
- name: Upload Rust bridge_generated directory
uses: actions/upload-artifact@v2
with:
name: rust_bridge_generated
path: mobile/native/src/bridge_generated/
- name: Upload Dart bridge_generated directory
uses: actions/upload-artifact@v2
with:
name: dart_bridge_generated
path: mobile/lib/bridge_generated/
- name: Upload Dart mocks directory
uses: actions/upload-artifact@v2
with:
name: dart_mocks_generated
path: mobile/test/*.mocks.dart
lint-commits:
runs-on: ubuntu-latest
if: github.event.ref != 'refs/heads/main'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get all commits on current main
run: git fetch origin main
- name: Log all commits we will analyse
run: git log --pretty=format:%s origin/main..HEAD
- name: Disallow fixup! commits
run: git log --pretty=format:%s origin/main..HEAD | grep -zv fixup!
- name: Disallow squash! commits
run: git log --pretty=format:%s origin/main..HEAD | grep -zv squash!
clippy:
runs-on: ubuntu-latest
needs: generate-ffi
steps:
- uses: actions/checkout@v3
- uses: extractions/setup-just@v1
- name: Setup rust toolchain
run: rustup show
- uses: Swatinem/[email protected]
- name: Download RUST FFI bindings
uses: actions/download-artifact@v2
with:
name: rust_bridge_generated
path: mobile/native/src/bridge_generated
- run: cargo clippy --all-targets --all-features -- -D warnings
flutter-format-and-lint:
runs-on: ubuntu-latest
needs: generate-ffi
name: "Format and lint Flutter code"
steps:
- uses: actions/checkout@v3
- uses: extractions/setup-just@v1
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: "stable"
cache: true
cache-key: flutter-${{ env.FLUTTER_VERSION }}
cache-path: ${{ runner.tool_cache }}/flutter
- name: Download Dart mocks directory
uses: actions/download-artifact@v2
with:
name: dart_mocks_generated
path: mobile/test
- name: Download Dart bridge_generated directory
uses: actions/download-artifact@v2
with:
name: dart_bridge_generated
path: mobile/lib/bridge_generated
- name: Verify flutter formatting
# Mocks are actually ignored by the linter because they include `// ignore_for_file: type=lint`, but `dart format` reports changes on them nonetheless.
# The solution using a `find` command is from here: https://github.com/dart-lang/dart_style/issues/864
run: dart format --output=none --set-exit-if-changed --line-length 100 $(find . -name "*.dart" -not \( -name "*.*freezed.dart" -o -name "*.mocks.dart" \) )
- name: Analyse flutter code
run: just lint-flutter
unit-tests:
runs-on: ubuntu-latest
needs: [generate-ffi, clippy]
steps:
- uses: actions/checkout@v3
- uses: extractions/setup-just@v1
- name: Setup rust toolchain
run: rustup show
- uses: Swatinem/[email protected]
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: "stable"
cache: true
cache-key: flutter-${{ env.FLUTTER_VERSION }}
cache-path: ${{ runner.tool_cache }}/flutter
- name: Download Rust generated FFI flutter bindings
uses: actions/download-artifact@v2
with:
name: rust_bridge_generated
path: mobile/native/src/bridge_generated
- name: Running cargo tests
run: RUST_BACKTRACE=1 cargo test
# Flutter tests run `build_runner`, so no need to download mocks
- name: Download Dart bridge_generated directory
uses: actions/download-artifact@v2
with:
name: dart_bridge_generated
path: mobile/lib/bridge_generated
- name: Running flutter tests
run: just flutter-test
ln-dlc-node-tests:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: extractions/setup-just@v1
- name: Setup rust toolchain
run: rustup show
- uses: Swatinem/[email protected]
- name: Start containers
run: |
just docker
sleep 10 # We need to give docker a bit of time to startup
- name: Test containers are up
run: |
curl http://localhost:8080/bitcoin -d '{"jsonrpc": "1.0", "method": "sendtoaddress", "params": ["bcrt1qylgu6ffkp3p0m8tw8kp4tt2dmdh755f4r5dq7s", 0.1]}'
- name: Run LN-DLC tests
run: RUST_BACKTRACE=1 cargo test -p ln-dlc-node -- --ignored --nocapture --test-threads=1
- name: bitcoin logs on e2e tests error
if: failure()
run: docker logs bitcoin
- name: faucet logs on e2e tests error
if: failure()
run: docker logs faucet
- name: electrs logs on e2e tests error
if: failure()
run: docker logs electrs
- name: esplora logs on e2e tests error
if: failure()
run: docker logs esplora
- name: show disk space after tests
if: always()
run: df -h
e2e_tests_prepare:
needs: generate-ffi
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# when set to "true" but frees about 6 GB
tool-cache: false
large-packages: false
- uses: actions/checkout@v3
- uses: extractions/setup-just@v1
- name: Setup rust toolchain
run: rustup show
- uses: actions/cache@v4
env:
cache-name: test-cache
with:
path: |
target/debug/deps
target/debug/coordinator
key: test-cache-${{ github.run_id }}-${{ github.run_number }}
- name: Download RUST FFI bindings
uses: actions/download-artifact@v2
with:
name: rust_bridge_generated
path: mobile/native/src/bridge_generated
- name: build e2e tests only
run: cargo test -p tests-e2e --no-run
- name: build coordinator
run: cargo build --bin coordinator
- name: set-matrix
id: set-matrix
run: echo "matrix=$(scripts/get_test_list.sh)}" >> $GITHUB_OUTPUT
e2e_tests:
name: e2e-tests
needs: e2e_tests_prepare
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
tests: ${{ fromJson(needs.e2e_tests_prepare.outputs.matrix) }}
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v4
env:
cache-name: test-cache
with:
path: |
target/debug/deps
target/debug/coordinator
key: test-cache-${{ github.run_id }}-${{ github.run_number }}
- uses: extractions/setup-just@v1
- name: Start containers
run: |
just docker
sleep 10 # We need to give docker a bit of time to startup
- name: show disk space before tests
run: df -h
- name: Test containers are up
run: |
curl http://localhost:8080/bitcoin -d '{"jsonrpc": "1.0", "method": "sendtoaddress", "params": ["bcrt1qylgu6ffkp3p0m8tw8kp4tt2dmdh755f4r5dq7s", 0.1]}'
- name: Run coordinator
run: |
#!/usr/bin/env bash
set -euxo pipefail
just wait-for-electrs-to-be-ready
settings_target_path="data/coordinator/regtest/coordinator-settings.toml"
cp coordinator/example-settings/test-coordinator-settings.toml "$settings_target_path"
echo "Copied test settings to $settings_target_path"
echo "Starting coordinator"
ls -lah ./target/debug/
./target/debug/coordinator &> ./data/coordinator/regtest.log &
just wait-for-coordinator-to-be-ready
echo "Coordinator successfully started."
- name: Run maker
run: |
docker run --pull always -d --name maker ghcr.io/get10101/aristides/aristides:main regtest --orderbook http://172.17.0.1:8000
echo "Maker successfully started."
- name: Run e2e tests
run: RUST_BACKTRACE=1 ${{ matrix.tests }} --nocapture --ignored
- name: Print maker logs on e2e tests error
if: failure()
run: docker logs maker
- name: Print coordinator logs on e2e tests error
if: failure()
run: cat data/coordinator/regtest.log
- name: bitcoin logs on e2e tests error
if: failure()
run: docker logs bitcoin
- name: faucet logs on e2e tests error
if: failure()
run: docker logs faucet
- name: electrs logs on e2e tests error
if: failure()
run: docker logs electrs
- name: esplora logs on e2e tests error
if: failure()
run: docker logs esplora
- name: database logs on e2e tests error
if: failure()
run: docker logs db
- name: show disk space after tests
if: always()
run: df -h
e2e_tests_check:
needs: e2e_tests
runs-on: ubuntu-latest
steps:
- run: echo "success"
payout-curve:
runs-on: ubuntu-latest
needs: generate-ffi
timeout-minutes: 30
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# when set to "true" but frees about 6 GB
tool-cache: false
large-packages: false
- uses: actions/checkout@v3
- uses: extractions/setup-just@v1
- name: Setup rust toolchain
run: rustup show
- uses: Swatinem/[email protected]
- name: Download RUST FFI bindings
uses: actions/download-artifact@v2
with:
name: rust_bridge_generated
path: mobile/native/src/bridge_generated
- name: Run payout curve example tests
run: cargo run -p payout_curve --example payout_curve_csv