Skip to content

Move Swift publishing workflow to main repo #3662

Move Swift publishing workflow to main repo

Move Swift publishing workflow to main repo #3662

Workflow file for this run

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 update
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