Initial support for webassembly #51
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: pull_request | |
env: | |
TOOLCHAIN: nightly | |
CARGO_TERM_COLOR: always | |
ANDROID_API: 33 | |
ANDROID_NDK_VERSION: 25.2.9519653 | |
ANDROID_SYSTEM_IMAGE_PACKAGE: system-images;android-33;google_apis_playstore;arm64-v8a | |
OPENSSL_VERSION: 1.1.1s | |
HOMEBREW_NO_AUTO_UPDATE: 1 | |
jobs: | |
fmt: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.TOOLCHAIN }} | |
components: rustfmt | |
- name: Cargo fmt | |
run: cargo fmt --all -- --check | |
clippy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.TOOLCHAIN }} | |
components: clippy | |
- name: Cargo fmt | |
run: cargo clippy -- -Dwarnings | |
wasm: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./tests/support/test_server/ | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.TOOLCHAIN }} | |
targets: wasm32-unknown-unknown | |
- name: Builb wasm | |
run: cargo build --target wasm32-unknown-unknown --no-default-features --features browser | |
apple_simulator_integration_tests: | |
runs-on: macos-14 | |
strategy: | |
matrix: | |
rust-target: ["aarch64-apple-ios-sim"] | |
apple-target-os: [ "iOS" ] | |
include: | |
- rust-target: "aarch64-apple-tvos-sim" | |
apple-target-os: "tvOS" | |
- rust-target: "aarch64-apple-watchos-sim" | |
apple-target-os: "watchOS" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./tests/support/test_server/ | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.TOOLCHAIN }} | |
components: rust-src | |
targets: aarch64-apple-ios-sim | |
- name: Cache Cargo | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin | |
~/.cargo/git | |
~/.cargo/registry | |
key: cargo-${{ github.workflow }}-${{ github.job}}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/Cargo.lock') }} | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-dinghy@0.7.1 | |
- name: Start Simulator | |
uses: futureware-tech/simulator-action@v3 | |
with: | |
os: ${{ matrix.apple-target-os }} | |
- name: Build tests for ${{ matrix.rust-target }} | |
if: ${{ matrix.apple-target-os == 'tvOS' || matrix.apple-target-os == 'watchOS' }} | |
run: cargo -Zbuild-std test --target ${{ matrix.rust-target }} --no-run | |
- name: Build tests for ${{ matrix.rust-target }} | |
if: ${{ matrix.apple-target-os == 'iOS' }} | |
run: cargo test --target ${{ matrix.rust-target }} --no-run | |
- name: Dinghy devices and platforms for ${{ matrix.rust-target }} | |
env: | |
DINGHY_LOG: debug | |
run: | | |
cargo dinghy all-platforms | |
cargo dinghy all-devices | |
- name: Test for for ${{ matrix.rust-target }} | |
env: | |
DINGHY_LOG: debug | |
timeout-minutes: 30 | |
if: ${{ matrix.apple-target-os == 'tvOS' || matrix.apple-target-os == 'watchOS' }} | |
run: | | |
cargo -Zbuild-std test --target ${{ matrix.rust-target }} | |
- name: Test for for ${{ matrix.rust-target }} | |
env: | |
DINGHY_LOG: debug | |
timeout-minutes: 30 | |
if: ${{ matrix.apple-target-os == 'iOS' }} | |
run: | | |
cargo test --target ${{ matrix.rust-target }} | |
- name: Build phoenix_channel_clients with tls | |
if: ${{ matrix.apple-target-os == 'tvOS' || matrix.apple-target-os == 'watchOS' }} | |
run: | |
cargo build -Zbuild-std --target ${{ matrix.rust-target }} --features native-tls | |
uniffi-check: | |
runs-on: macos-14 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.TOOLCHAIN }} | |
- name: Cache Cargo | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin | |
~/.cargo/git | |
~/.cargo/registry | |
key: cargo-${{ github.workflow }}-${{ github.job}}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/Cargo.lock') }} | |
- name: Build static library | |
run: cargo build --lib --release # For some unclear reason, the release build has better errors. | |
- name: Generate swift bindings | |
run: | | |
cargo run --bin uniffi-bindgen -- generate --library ./target/release/libphoenix_channels_client.dylib --out-dir ./binding-swift/ --language swift | |
- name: Generate kotlin bindings | |
run: | | |
cargo run --bin uniffi-bindgen -- generate --library ./target/release/libphoenix_channels_client.dylib --out-dir ./binding-kotlin/ --language kotlin | |
integration_tests: | |
# rust cross-compilation | |
runs-on: macos-14 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./tests/support/test_server/ | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.TOOLCHAIN }} | |
- name: Cache Cargo | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin | |
~/.cargo/git | |
~/.cargo/registry | |
key: cargo-${{ github.workflow }}-${{ github.job}}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/Cargo.lock') }} | |
- name: Build phoenix_channels_client | |
run: cargo build --all-targets | |
- name: Generate docs for phoenix_channel_clients | |
run: cargo doc | |
- name: Get JNA jar | |
run: wget 'https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.14.0/jna-5.14.0.jar' | |
- name: Set up Elixir, kotlin and ktlint | |
if: ${{ runner.os == 'macOS' }} | |
run: brew install ktlint | |
- name: Test phoenix_channel_clients | |
env: | |
# This is required for the kotlin uniffi tests | |
CLASSPATH: "/opt/homebrew/opt/kotlin/libexec/lib/kotlinx-coroutines-core-jvm.jar:./jna-5.14.0.jar" | |
run: cargo test | |
android_simulator_integration_tests: | |
# rust cross-compilation | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./tests/support/test_server/ | |
- name: Install Rust Nightly | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.TOOLCHAIN }} | |
target: x86_64-linux-android | |
- name: Cache Cargo | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin | |
~/.cargo/git | |
~/.cargo/registry | |
key: cargo-${{ github.workflow }}-${{ github.job }}-${{runner.os}}-${{runner.arch}}-${{ hashFiles('**/Cargo.lock') }} | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-dinghy@0.7.1 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: 'temurin' | |
- name: Enable KVM | |
run: | | |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
sudo udevadm control --reload-rules | |
sudo udevadm trigger --name-match=kvm | |
- name: Gradle cache | |
uses: gradle/actions/setup-gradle@v4 | |
- name: AVD cache | |
uses: actions/cache@v4 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-${{ env.ANDROID_API }}-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}-${{runner.arch}} | |
- name: Create AVD and generate snapshot for caching | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ env.ANDROID_API }} | |
ndk: ${{ env.ANDROID_NDK_VERSION }} | |
force-avd-creation: false | |
target: google_apis | |
arch: x86_64 | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: false | |
script: echo "Generated AVD snapshot for caching." | |
- name: Run tests in android emulator | |
uses: reactivecircus/android-emulator-runner@v2 | |
env: | |
RANLIB: "${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib" | |
with: | |
api-level: ${{ env.ANDROID_API }} | |
ndk: ${{ env.ANDROID_NDK_VERSION }} | |
target: google_apis | |
arch: x86_64 | |
force-avd-creation: false | |
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: true | |
script: | | |
cargo dinghy all-platforms | |
cargo dinghy all-devices | |
export RUSTFLAGS="--cfg tokio_unstable" | |
cargo dinghy -p auto-android-x86_64-api${ANDROID_API} test |