@@ -143,6 +143,32 @@ jobs:
143
143
working-directory : tools/sdk-cli
144
144
run : cargo test
145
145
146
+ build-common :
147
+ name : Test sdk-common
148
+ runs-on : ubuntu-latest
149
+ steps :
150
+ - name : Checkout repo
151
+ uses : actions/checkout@v3
152
+
153
+ - name : Install rust
154
+ run : |
155
+ rustup set auto-self-update disable
156
+ rustup toolchain install stable --profile minimal
157
+
158
+ - uses : Swatinem/rust-cache@v2
159
+ with :
160
+ workspaces : libs/sdk-common -> ../target
161
+
162
+ - name : Install Protoc
163
+ uses : arduino/setup-protoc@v2
164
+ with :
165
+ version : " 23.4"
166
+ repo-token : ${{ secrets.GITHUB_TOKEN }}
167
+
168
+ - name : Run sdk-common tests
169
+ working-directory : libs/sdk-common
170
+ run : cargo test
171
+
146
172
clippy :
147
173
name : Clippy
148
174
runs-on : ubuntu-latest
@@ -273,3 +299,56 @@ jobs:
273
299
274
300
- name : dart-format
275
301
run : dart format -o none --set-exit-if-changed -l 110 .
302
+
303
+ # Create a new plain Rust project, add the SDK as single dependency and try to compile it.
304
+ # This tests whether the SDK compiles with the latest version of the dependencies that can be updated.
305
+ #
306
+ # Our checked-in Cargo.lock contains the specific combination of all direct and transitive dependency versions.
307
+ # This dependency tree snapshot was tested against during development and is what we release.
308
+ #
309
+ # However, when integrating the SDK in a new Rust project, Cargo not use our Cargo.lock. Instead, it will try to generate
310
+ # a new Cargo.lock based on our (and our dependencies') Cargo.toml files. This means that, where a dependency version range
311
+ # is used in a Cargo.toml, Cargo will try to upgrade it to the latest matching version. If this happens, this new dependency
312
+ # version may even result in the whole project failing to compile. In that case, the only solution is to manually pin
313
+ # the problematic dependencies to the last known good versions, in the application's Cargo.toml.
314
+ #
315
+ # Since this is the situation new projects are faced with when adding the SDK as a Rust dependency, we simulate it here
316
+ # to get an early warning signal, should any newer dependency cause it to fail to compile.
317
+ #
318
+ # See discussion at https://github.com/breez/breez-sdk/issues/969#issuecomment-2104700522
319
+ check-sdk-as-dependency :
320
+ name : Check SDK as Rust dependency in fresh project
321
+ runs-on : ubuntu-latest
322
+ steps :
323
+ - name : Checkout repo
324
+ uses : actions/checkout@v3
325
+
326
+ - name : Install rust
327
+ run : |
328
+ rustup set auto-self-update disable
329
+ rustup toolchain install stable --profile minimal
330
+
331
+ - uses : Swatinem/rust-cache@v2
332
+ with :
333
+ workspaces : |
334
+ libs -> target
335
+
336
+ - name : Install Protoc
337
+ uses : arduino/setup-protoc@v2
338
+ with :
339
+ version : " 23.4"
340
+ repo-token : ${{ secrets.GITHUB_TOKEN }}
341
+
342
+ - name : test-new-project-with-sdk-dependency
343
+ run : |
344
+ mkdir new-project
345
+ cd new-project
346
+ cargo init --name test_project --vcs none
347
+
348
+ # A project might reference our SDK as a git repository
349
+ # cargo add --git https://github.com/breez/breez-sdk breez-sdk-core
350
+
351
+ # In this test, we reference the checked out repo (e.g. this PR branch)
352
+ cargo add --path ../libs/sdk-core breez-sdk-core
353
+
354
+ cargo clippy -- -D warnings
0 commit comments