From e2ab7cf333cb57d229ca37e8a0fa15565903f2f1 Mon Sep 17 00:00:00 2001 From: SimonThormeyer Date: Mon, 17 Jun 2024 15:59:11 +0200 Subject: [PATCH] chore: optimize ci --- .github/workflows/bindings.yml | 16 --- .github/workflows/swift-bindings.yml | 159 +++++++++++++++++++++++++++ crypto-ffi/Makefile.toml | 8 +- 3 files changed, 166 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/swift-bindings.yml diff --git a/.github/workflows/bindings.yml b/.github/workflows/bindings.yml index a5502d4edf..5e5a9252a4 100644 --- a/.github/workflows/bindings.yml +++ b/.github/workflows/bindings.yml @@ -56,22 +56,6 @@ jobs: cd crypto-ffi/bindings ./gradlew android:build -x lint -x lintRelease - check-swift: - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - rustflags: '' - target: "aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim" - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.3 - - name: Setup cargo-make - uses: davidB/rust-cargo-make@v1 - - run: | - cd crypto-ffi - cargo make ios-create-xcframework - check-wasm: runs-on: ubuntu-latest env: diff --git a/.github/workflows/swift-bindings.yml b/.github/workflows/swift-bindings.yml new file mode 100644 index 0000000000..25c5f91d2a --- /dev/null +++ b/.github/workflows/swift-bindings.yml @@ -0,0 +1,159 @@ +name: Check swift + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + push: + branches: + - develop + pull_request: + +env: + CARGO_TERM_COLOR: always + CARGO_NET_GIT_FETCH_WITH_CLI: true + CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + +jobs: + release-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + rustflags: '' + target: aarch64-apple-darwin + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Setup cargo-make + uses: davidB/rust-cargo-make@v1 + - name: Run release-build + run: | + cd crypto-ffi + cargo make release-build-aarch64-apple-darwin + + compile-ffi-swift: + runs-on: ubuntu-latest + needs: release-build + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Setup cargo-make + uses: davidB/rust-cargo-make@v1 + - name: Run compile-ffi-swift + run: | + cd crypto-ffi + cargo make compile-ffi-swift + + ffi-swift: + runs-on: ubuntu-latest + needs: compile-ffi-swift + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Setup cargo-make + uses: davidB/rust-cargo-make@v1 + - name: Run ffi-swift + run: | + cd crypto-ffi + cargo make ffi-swift + + ios-device: + runs-on: macos-latest + needs: ffi-swift + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + rustflags: '' + target: "aarch64-apple-ios" + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Setup cargo-make + uses: davidB/rust-cargo-make@v1 + - name: Run ios-device + run: | + cd crypto-ffi + cargo make ios-device + + ios-simulator-x86: + runs-on: macos-latest + needs: ffi-swift + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + rustflags: '' + target: "x86_64-apple-ios" + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Setup cargo-make + uses: davidB/rust-cargo-make@v1 + - name: Run ios-simulator-x86 + run: | + cd crypto-ffi + cargo make ios-simulator-x86 + + ios-simulator-arm: + runs-on: macos-latest + needs: ffi-swift + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + rustflags: '' + target: "aarch64-apple-ios-sim" + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Setup cargo-make + uses: davidB/rust-cargo-make@v1 + - name: Run ios-simulator-arm + env: + CRATE_CC_NO_DEFAULTS: 1 + TARGET_CFLAGS: $(echo "--target=arm64-apple-ios14.0.0-simulator -mios-simulator-version-min=14.0 -isysroot `xcrun --show-sdk-path --sdk iphonesimulator`") + run: | + cd crypto-ffi + cargo make ios-simulator-arm + + ios: + runs-on: macos-latest + needs: [ios-device, ios-simulator-x86, ios-simulator-arm] + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + rustflags: '' + target: "aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim" + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Setup cargo-make + uses: davidB/rust-cargo-make@v1 + - name: Run ios + run: | + cd crypto-ffi + cargo make ios + + ios-create-xcframework: + runs-on: macos-latest + needs: ios + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + rustflags: '' + target: "aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim" + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Setup cargo-make + uses: davidB/rust-cargo-make@v1 + - name: Run ios-create-xcframework + run: | + cd crypto-ffi + cargo make ios-create-xcframework diff --git a/crypto-ffi/Makefile.toml b/crypto-ffi/Makefile.toml index c7651f87f0..5507a811a9 100644 --- a/crypto-ffi/Makefile.toml +++ b/crypto-ffi/Makefile.toml @@ -19,6 +19,11 @@ args = ["check"] command = "cargo" args = ["build", "--release"] +# Needed to cross compile for apple on linux in CI +[tasks.release-build-aarch64-apple-darwin] +command = "cargo" +args = ["build", "--release", "--target", "aarch64-apple-darwin"] + ##################################### DOCS #################################### [tasks.docs-rust-generic] @@ -119,6 +124,7 @@ args = ["run", "build_ts.ts"] [tasks.compile-ffi-swift] dependencies = ["release-build"] +linux = { dependencies = ["release-build-aarch64-apple-darwin"] } command = "cargo" args = [ "run", @@ -127,7 +133,7 @@ args = [ "generate", "--language", "swift", "--out-dir", "./bindings/swift/WireCoreCrypto/WireCoreCrypto", - "--library", "../target/release/libcore_crypto_ffi.${LIBRARY_EXTENSION}" + "--library", "../target/release/libcore_crypto_ffi.dylib" ] [tasks.ffi-swift]