Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: iOS interop [WPB-15034] #850

Merged
merged 5 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 53 additions & 48 deletions .github/workflows/bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
build-jvm-linux:
uses: ./.github/workflows/build-jvm-linux.yml

build-ios:
uses: ./.github/workflows/build-ios.yml

test-android:
if: github.repository == 'wireapp/core-crypto'
runs-on: ubuntu-latest
Expand Down Expand Up @@ -88,62 +91,61 @@ jobs:
cd crypto-ffi/bindings
./gradlew jvm:build -x lint -x lintRelease

build-swift:
create-xcframework:
needs: build-ios
runs-on: macos-latest
strategy:
matrix:
task:
- ios-device
- ios-simulator-x86
- ios-simulator-arm
steps:
- uses: actions/checkout@v4

- name: determine rust target
id: rust-target
run: |
if [[ "${{ matrix.task }}" == "ios-device" ]]; then
echo "target=aarch64-apple-ios" >> $GITHUB_ENV
elif [[ "${{ matrix.task }}" == "ios-simulator-x86" ]]; then
echo "target=x86_64-apple-ios" >> $GITHUB_ENV
elif [[ "${{ matrix.task }}" == "ios-simulator-arm" ]]; then
echo "target=aarch64-apple-ios-sim" >> $GITHUB_ENV
fi

- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ env.target }}

- name: setup cargo-make
uses: davidB/rust-cargo-make@v1

- name: build ${{ matrix.task }}
run: |
cd crypto-ffi
cargo make ${{ matrix.task }}

- name: upload artifact
uses: actions/upload-artifact@v4
- name: download artifacts for ios
uses: actions/download-artifact@v4
with:
name: ${{github.event.number}}-${{ matrix.task }}
path: target
retention-days: 1
overwrite: 'true'
# Only needs to be uploaded once, this step finishes fastest.
- name: upload ffi artifact
if: startsWith(matrix.task, 'ios-simulator-arm')
uses: actions/upload-artifact@v4
pattern: ${{github.event.number}}-ios-*
merge-multiple: 'true'
- name: download ffi artifacts
uses: actions/download-artifact@v4
with:
name: ${{github.event.number}}-swift-ffi
path: crypto-ffi/bindings/swift/WireCoreCrypto
retention-days: 1
overwrite: 'true'
- name: create xcframework
run: |
cd crypto-ffi/bindings/swift
./build-xcframework.sh

create-xcframework:
needs: build-swift
e2e-interop-test:
runs-on: macos-latest
needs: build-ios
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1 # this implicitly caches Rust tools and build artifacts
with:
target: "wasm32-unknown-unknown,aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim"
rustflags: ''
- uses: davidB/rust-cargo-make@v1
- name: setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '16.1.0'
- name: setup wasm-pack
uses: taiki-e/install-action@v2
with:
tool: wasm-pack
- uses: browser-actions/setup-chrome@latest
id: setup-chrome
with:
chrome-version: latest
- run: |
echo "CHROME_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> $GITHUB_ENV
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- uses: actions/setup-node@v4
with:
node-version: 18
- name: build wasm artifacts
run: |
cd crypto-ffi
cargo make wasm
- name: download artifacts for ios
uses: actions/download-artifact@v4
with:
Expand All @@ -155,11 +157,14 @@ jobs:
with:
name: ${{github.event.number}}-swift-ffi
path: crypto-ffi/bindings/swift/WireCoreCrypto
- name: create xcframework
- name: build & install iOS Interop client
run: |
cd crypto-ffi/bindings/swift
./build-xcframework.sh

cd interop/src/clients/InteropClient
xcodebuild -scheme InteropClient -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15' clean build install DSTROOT=./Products
./install_app.sh "iPhone 16"
./grant_permissions.sh "iPhone 16"
- name: run e2e interop test
run: cargo run --bin interop

build-and-test-wasm:
runs-on: ubuntu-latest
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}-build-ios"
cancel-in-progress: true

on:
workflow_call:

env:
CARGO_TERM_COLOR: always
CARGO_NET_GIT_FETCH_WITH_CLI: true
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse

jobs:
build-ios:
runs-on: macos-latest
strategy:
matrix:
task:
- ios-device
- ios-simulator-x86
- ios-simulator-arm
steps:
- uses: actions/checkout@v4

- name: determine rust target
id: rust-target
run: |
if [[ "${{ matrix.task }}" == "ios-device" ]]; then
echo "target=aarch64-apple-ios" >> $GITHUB_ENV
elif [[ "${{ matrix.task }}" == "ios-simulator-x86" ]]; then
echo "target=x86_64-apple-ios" >> $GITHUB_ENV
elif [[ "${{ matrix.task }}" == "ios-simulator-arm" ]]; then
echo "target=aarch64-apple-ios-sim" >> $GITHUB_ENV
fi

- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ env.target }}

- name: setup cargo-make
uses: davidB/rust-cargo-make@v1

- name: build ${{ matrix.task }}
run: |
cd crypto-ffi
cargo make ${{ matrix.task }}

- name: upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{github.event.number}}-${{ matrix.task }}
path: target
retention-days: 1
overwrite: 'true'
# Only needs to be uploaded once, this step finishes fastest.
- name: upload ffi artifact
if: startsWith(matrix.task, 'ios-simulator-arm')
uses: actions/upload-artifact@v4
with:
name: ${{github.event.number}}-swift-ffi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we're using github.event.number, elsewhere we're using github.run_id to uniquely name artifacts. I think we should be consistent, and use github.run_id everywhere, unless there is a good reason to prefer github.event.number here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just moved the job into separate file maybe @coriolinus can give a reason.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't touch that actually; it appears to come from 1ce7d95, which is @SimonThormeyer.

I don't think there's a strong reason here to prefer either one here. TBH we'd probably be fine without a distinguishing number in either case; looking deeper into the download artifact action, it automatically partitions by run id anyway. Adding an event number or run id just helps us keep track of things if we happen to download some artifacts for manual inspection.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking deeper into the download artifact action, it automatically partitions by run id anyway

Ah, didn't know that, thanks!

path: crypto-ffi/bindings/swift/WireCoreCrypto
retention-days: 1
overwrite: 'true'
32 changes: 0 additions & 32 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,38 +155,6 @@ jobs:
wasm-pack test --headless --chrome ./keystore -F "proteus-keystore" -- proteus
wasm-pack test --headless --chrome ./crypto -F "proteus,cryptobox-migrate" -- proteus

e2e-interop-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1 # this implicitly caches Rust tools and build artifacts
with:
target: wasm32-unknown-unknown
rustflags: ''
- uses: davidB/rust-cargo-make@v1
- name: setup wasm-pack
uses: taiki-e/install-action@v2
with:
tool: wasm-pack
- uses: browser-actions/setup-chrome@latest
id: setup-chrome
with:
chrome-version: stable
- run: |
echo "CHROME_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> $GITHUB_ENV
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- uses: actions/setup-node@v4
with:
node-version: 18
- name: build wasm artifacts
run: |
cd crypto-ffi
cargo make wasm
- name: run e2e interop test
run: cargo run --bin interop

hack:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion extras/webdriver-installation/src/webdriver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl WebdriverKind {
.take()
.unwrap()
.channels
.remove(&ChromeDriverReleaseDetailsChannel::Stable)
.remove(&ChromeDriverReleaseDetailsChannel::Canary)
.unwrap();

let download_url = channel
Expand Down
2 changes: 2 additions & 0 deletions interop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ tempfile = { version = "3.15" }
# Terminal support
xshell = "0.2"
spinoff = { version = "0.8", features = ["aesthetic"], default-features = false }
serde = { workspace = true, features = ["derive"] }
thiserror = { workspace = true }

[target.'cfg(not(target_family = "wasm"))'.dependencies]
async-fs = "2.1"
Expand Down
Loading
Loading