-
Notifications
You must be signed in to change notification settings - Fork 43
353 lines (294 loc) · 10.3 KB
/
main.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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
name: CI
# Controls when the workflow will run
on:
# Triggers the workflow on push events but only for the "main" branch
push:
branches: [ main ]
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
fmt:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Format
run: |
cd libs
cargo fmt -- --check
cd ../tools/sdk-cli
cargo fmt -- --check
build-core:
name: Test sdk-core
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install rust
run: |
rustup set auto-self-update disable
rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@v2
with:
workspaces: libs/sdk-core -> ../target
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "27.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run sdk-core tests
working-directory: libs/sdk-core
run: cargo test
build-bindings:
name: Test sdk-bindings
runs-on: macOS-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install rust
run: |
rustup set auto-self-update disable
rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@v2
with:
workspaces: libs/sdk-bindings -> ../target
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "27.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build sdk-bindings
working-directory: libs/sdk-bindings
run: cargo build
- name: Build C# bindings
working-directory: libs/sdk-bindings
run: |
cargo install uniffi-bindgen-cs --git https://github.com/breez/uniffi-bindgen-cs --branch namespace
uniffi-bindgen-cs src/breez_sdk.udl -o ffi/csharp -c ./uniffi.toml
cp ../target/debug/libbreez_sdk_bindings.dylib ffi/csharp
- name: Build golang bindings
working-directory: libs/sdk-bindings
run: |
cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.1.5+v0.23.0
uniffi-bindgen-go src/breez_sdk.udl -o ffi/golang -c ./uniffi.toml
cp ../target/debug/libbreez_sdk_bindings.dylib ffi/golang
cp -r ffi/golang/breez/breez_sdk tests/bindings/golang/
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: '1.19.9'
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Run sdk-bindings tests
run: |
curl -o jna-5.12.1.jar https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.12.1/jna-5.12.1.jar
export CLASSPATH=$(pwd)/jna-5.12.1.jar;
cd libs/sdk-bindings
cargo test
build-cli:
name: Test sdk-cli
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install rust
run: |
rustup set auto-self-update disable
rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@v2
with:
workspaces: tools/sdk-cli -> target
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "27.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run tools tests
working-directory: tools/sdk-cli
run: cargo test
build-common:
name: Test sdk-common
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install rust
run: |
rustup set auto-self-update disable
rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@v2
with:
workspaces: libs/sdk-common -> ../target
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "27.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run sdk-common tests
working-directory: libs/sdk-common
run: cargo test
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install rust
run: |
rustup set auto-self-update disable
rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@v2
with:
workspaces: |
libs -> target
tools/sdk-cli -> target
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "27.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: clippy
run: |
cd libs
# Explicitly allow clippy::uninlined-format-args lint because it's present in the generated breez_sdk.uniffi.rs
cargo clippy -- -D warnings -A clippy::uninlined-format-args
cargo clippy --tests -- -D warnings -A clippy::uninlined-format-args
cd ../tools/sdk-cli
cargo clippy -- -D warnings
react-native:
name: Check react native
runs-on: macOS-14
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install rust
run: |
rustup set auto-self-update disable
rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@v2
with:
workspaces: |
libs -> target
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "27.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: React native codegen
working-directory: libs/sdk-react-native
run: |
yarn global add tslint typescript
brew install kotlin ktlint swiftformat
make react-native
- name: Check git status
env:
GIT_PAGER: cat
run: |
status=$(git status --porcelain)
if [[ -n "$status" ]]; then
echo "Git status has changes"
echo "$status"
git diff
exit 1
else
echo "No changes in git status"
fi
flutter:
name: Check flutter
runs-on: macOS-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install rust
run: |
rustup set auto-self-update disable
rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@v2
with:
workspaces: |
libs -> target
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "27.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- name: Flutter bridge codegen
working-directory: libs/sdk-flutter
run: |
make init
make flutter_rust_bridge
- name: Check git status
env:
GIT_PAGER: cat
run: |
status=$(git status --porcelain)
if [[ -n "$status" ]]; then
echo "Git status has changes"
echo "$status"
git diff
exit 1
else
echo "No changes in git status"
fi
- name: dart-analyze
run: dart analyze --fatal-infos
- name: dart-format
run: dart format -o none --set-exit-if-changed -l 110 .
# Create a new plain Rust project, add the SDK as single dependency and try to compile it.
# This tests whether the SDK compiles with the latest version of the dependencies that can be updated.
#
# Our checked-in Cargo.lock contains the specific combination of all direct and transitive dependency versions.
# This dependency tree snapshot was tested against during development and is what we release.
#
# However, when integrating the SDK in a new Rust project, Cargo not use our Cargo.lock. Instead, it will try to generate
# a new Cargo.lock based on our (and our dependencies') Cargo.toml files. This means that, where a dependency version range
# is used in a Cargo.toml, Cargo will try to upgrade it to the latest matching version. If this happens, this new dependency
# version may even result in the whole project failing to compile. In that case, the only solution is to manually pin
# the problematic dependencies to the last known good versions, in the application's Cargo.toml.
#
# Since this is the situation new projects are faced with when adding the SDK as a Rust dependency, we simulate it here
# to get an early warning signal, should any newer dependency cause it to fail to compile.
#
# See discussion at https://github.com/breez/breez-sdk/issues/969#issuecomment-2104700522
check-sdk-as-dependency:
name: Check SDK as Rust dependency in fresh project
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install rust
run: |
rustup set auto-self-update disable
rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@v2
with:
workspaces: |
libs -> target
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "27.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: test-new-project-with-sdk-dependency
run: |
mkdir new-project
cd new-project
cargo init --name test_project --vcs none
# A project might reference our SDK as a git repository
# cargo add --git https://github.com/breez/breez-sdk breez-sdk-core
# In this test, we reference the checked out repo (e.g. this PR branch)
cargo add --path ../libs/sdk-core breez-sdk-core
cargo clippy -- -D warnings