remove redundant variable, update gitignore - test for CI #2
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: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
pull_request: | |
env: | |
CARGO_TERM_COLOR: always | |
# Change to stable when features stabilize | |
CARGO_MAKE_TOOLCHAIN: nightly | |
CARGO_MAKE_CI: true | |
ANDROID_API: 34 | |
ANDROID_NDK_VERSION: 26.3.11579264 | |
HOMEBREW_NO_AUTO_UPDATE: 1 | |
# https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci | |
CARGO_CACHE_PATH: | | |
~/.cargo/.crates.toml | |
~/.cargo/.crates2.json | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
jobs: | |
fmt: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }} | |
components: rustfmt | |
- name: Cargo fmt | |
run: cargo fmt --all -- --check | |
typos: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: typos-cli | |
- name: run typos | |
run: typos | |
- name: Typos info | |
if: failure() | |
run: | | |
echo 'To fix typos, please run `typos -w`' | |
echo 'To check for a diff, run `typos`' | |
echo 'You can find typos here: https://crates.io/crates/typos' | |
wasm: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }} | |
targets: wasm32-unknown-unknown | |
- name: Builb wasm | |
run: cargo build --target wasm32-unknown-unknown -p liveview_native_core_wasm | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: wasm-pack | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: wasm-bindgen | |
- name: Builb wasm for nodesjs | |
working-directory: ./crates/wasm | |
run: ./build.sh nodejs | |
- name: Builb wasm for web | |
working-directory: ./crates/wasm | |
run: ./build.sh web | |
clippy: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }} | |
components: clippy | |
- name: Cargo fmt | |
run: cargo clippy -- -Dwarnings | |
kotiln_integration_tests: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [macos-15, ubuntu-24.04] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./tests/support/test_server/ | |
if: ${{ matrix.os == 'macos-15' }} | |
- name: Install Rust Nightly | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }} | |
targets: armv7-linux-androideabi | |
aarch64-linux-android | |
i686-linux-android | |
x86_64-linux-android | |
x86_64-unknown-linux-gnu | |
aarch64-apple-darwin | |
x86_64-apple-darwin | |
- name: Cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.CARGO_CACHE_PATH }} | |
key: cargo-${{ github.workflow }}-${{ github.job }}-${{runner.os}}-${{runner.arch}}-${{ hashFiles('**/Cargo.toml') }} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: "17" | |
distribution: "temurin" | |
- name: Install gradle | |
uses: gradle/actions/setup-gradle@v4 | |
# https://github.com/actions/runner-images/blob/5a9870800dc54127d22ee36c303b47314d231c69/images/macos/macos-15-arm64-Readme.md | |
# Python is required to build OpenSSL but there's no python in the m1 | |
# macos runners. | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Run build with Gradle wrapper | |
if: ${{ matrix.os == 'macos-15' }} | |
working-directory: ./crates/core/liveview-native-core-jetpack/ | |
env: | |
RANLIB: "${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ranlib" | |
run: ./gradlew build --scan | |
- name: Run build with Gradle wrapper | |
if: ${{ matrix.os == 'ubuntu-24.04' }} | |
working-directory: ./crates/core/liveview-native-core-jetpack/ | |
env: | |
RANLIB: "${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib" | |
run: ./gradlew build --scan -x test | |
swift_build_xcframework: | |
runs-on: macos-15 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust Nightly | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }} | |
components: rust-src | |
targets: aarch64-apple-ios-sim | |
aarch64-apple-ios | |
x86_64-apple-ios | |
aarch64-apple-darwin | |
x86_64-apple-darwin | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-make | |
- name: Cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.CARGO_CACHE_PATH }} | |
key: cargo-${{ github.workflow }}-${{ github.job }}-${{runner.os}}-${{runner.arch}}-${{ hashFiles('**/Cargo.toml') }} | |
- name: Generate the swift package | |
run: cargo make uniffi-swift-package | |
- uses: actions/upload-artifact@v4 | |
with: | |
retention-days: 2 | |
name: LiveViewNativeCore-Source | |
path: ./crates/core/liveview-native-core-swift/Sources/LiveViewNativeCore | |
- name: Test swift package | |
run: cargo make uniffi-xcframework | |
- uses: actions/upload-artifact@v4 | |
with: | |
retention-days: 2 | |
name: liveview_native_core.xcframework | |
path: ./target/uniffi/swift/liveview_native_core.xcframework | |
swift_integration_tests: | |
runs-on: macos-15 | |
needs: | |
- swift_build_xcframework | |
strategy: | |
matrix: | |
swift-test: ["package", "tvos", "watchos", "macos", "ios", "visionos"] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./tests/support/test_server/ | |
- uses: actions/download-artifact@v4 | |
with: | |
name: liveview_native_core.xcframework | |
path: ./target/uniffi/swift/liveview_native_core.xcframework | |
- uses: actions/download-artifact@v4 | |
with: | |
name: LiveViewNativeCore-Source | |
path: ./crates/core/liveview-native-core-swift/Sources/LiveViewNativeCore | |
- name: Check artifact downloads | |
run: | | |
ls ./target/uniffi/swift/ ./target/uniffi/swift/liveview_native_core.xcframework ./crates/core/liveview-native-core-swift/Sources/LiveViewNativeCore/ ./crates/core/liveview-native-core-swift/Sources/LiveViewNativeCore/* | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-make | |
- name: Cache xcode builds for ${{matrix.swift-test}} | |
uses: actions/cache@v4 | |
id: xcode-build-cache | |
with: | |
path: | | |
xcode-build/ | |
key: xcode-build-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}-${{runner.arch}}-${{matrix.swift-test}} | |
- name: Test swift package | |
run: cargo make uniffi-swift-test-${{matrix.swift-test}} | |
- name: Upload Test Results | |
if: ${{ failure() && matrix.swift-test != 'package' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: xcode-test-results-${{ matrix.swift-test }} | |
path: xcode-build/Logs/Test/ | |
- name: Phx server logs | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: phx-server-stdout-${{ matrix.swift-test }} | |
path: | | |
tests/support/test_server/server.stdout.txt | |
tests/support/test_server/server.stderr.txt | |
- name: Show Test Coverage | |
if: ${{ matrix.swift-test == 'package' }} | |
run: | | |
xcrun llvm-cov report -instr-profile .build/arm64-apple-macosx/debug/codecov/default.profdata .build/arm64-apple-macosx/debug/LiveViewNativeCorePackageTests.xctest/Contents/MacOS/LiveViewNativeCorePackageTests | |
xcrun llvm-cov export -instr-profile .build/arm64-apple-macosx/debug/codecov/default.profdata .build/arm64-apple-macosx/debug/LiveViewNativeCorePackageTests.xctest/Contents/MacOS/LiveViewNativeCorePackageTests --format lcov > ./swift-lcov.info | |
- uses: actions/upload-artifact@v4 | |
if: ${{ matrix.swift-test == 'package' }} | |
with: | |
retention-days: 2 | |
name: swift-lcov.info | |
path: swift-lcov.info | |
coverage_report: | |
runs-on: ubuntu-24.04 | |
needs: | |
- swift_integration_tests | |
- integration_tests | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: LiveViewNativeCore-Source | |
path: ./crates/core/liveview-native-core-swift/Sources/LiveViewNativeCore | |
- uses: actions/download-artifact@v4 | |
with: | |
name: swift-lcov.info | |
- uses: actions/download-artifact@v4 | |
with: | |
name: rust-lcov.info | |
- name: Check artifact downloads | |
run: | | |
ls $PWD/crates/core/liveview-native-core-swift/Sources/LiveViewNativeCore/ $PWD/crates/core/liveview-native-core-swift/Sources/LiveViewNativeCore/* | |
- name: Install lcov | |
run: sudo apt-get -y install lcov | |
- name: Merge coverage files | |
run: lcov -a rust-lcov.info -a swift-lcov.info -o merged-lcov.info | |
- uses: livewing/lcov-job-summary@v1.1.0 | |
with: | |
lcov: merged-lcov.info | |
integration_tests: | |
runs-on: macos-15 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./tests/support/test_server/ | |
- name: Install Rust Nightly | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }} | |
- name: Cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.CARGO_CACHE_PATH }} | |
key: cargo-${{ github.workflow }}-${{ github.job }}-${{runner.os}}-${{runner.arch}}-${{ hashFiles('**/Cargo.toml') }} | |
- name: Get the JNA jar for testing kotlin. | |
run: wget 'https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.14.0/jna-5.14.0.jar' | |
- name: Build tests | |
run: cargo test --no-run | |
- name: Run Tests | |
timeout-minutes: 5 | |
run: cargo test | |
env: | |
# This is required for the kotlin uniffi tests | |
CLASSPATH: "/Users/runner/work/liveview-native-core/liveview-native-core/jna-5.14.0.jar:/opt/homebrew/opt/kotlin/libexec/lib/kotlinx-coroutines-core-jvm.jar" | |
- name: Install cargo-llvm-cov | |
uses: taiki-e/install-action@cargo-llvm-cov | |
- name: Test Coverage | |
timeout-minutes: 5 | |
run: | | |
cargo llvm-cov | |
cargo llvm-cov report --lcov --output-path ./rust-lcov.info | |
env: | |
# This is required for the kotlin uniffi tests | |
CLASSPATH: "/Users/runner/work/liveview-native-core/liveview-native-core/jna-5.14.0.jar:/opt/homebrew/opt/kotlin/libexec/lib/kotlinx-coroutines-core-jvm.jar" | |
- uses: actions/upload-artifact@v4 | |
with: | |
retention-days: 2 | |
name: rust-lcov.info | |
path: rust-lcov.info | |
- name: Phx server logs | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: phx-server-stdout-${{ github.job }}-${{ runner.os }} | |
path: | | |
tests/support/test_server/server.stdout.txt | |
tests/support/test_server/server.stderr.txt | |
apple_simulator_tests: | |
# rust cross-compilation | |
runs-on: macos-15 | |
strategy: | |
fail-fast: false | |
matrix: | |
rust-target: ["aarch64-apple-ios-sim"] | |
apple-sim: ["iPhone 16"] | |
build-std: [""] | |
include: | |
- rust-target: "aarch64-apple-tvos-sim" | |
apple-sim: "Apple TV 4K (3rd generation)" | |
build-std: "-Zbuild-std" | |
- rust-target: "aarch64-apple-watchos-sim" | |
apple-sim: "Apple Watch Ultra 2 (49mm)" | |
build-std: "-Zbuild-std" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Start Simulator | |
run: | | |
xcrun simctl list devices available | |
xcrun simctl boot "${{ matrix.apple-sim }}" | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }} | |
components: rust-src | |
targets: aarch64-apple-ios-sim | |
- name: Cargo Cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.CARGO_CACHE_PATH }} | |
key: cargo-${{ github.workflow }}-${{ runner.os }}-${{ runner.arch }}-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }} | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-dinghy@0.7.1 | |
- uses: ./tests/support/test_server/ | |
- name: Build tests | |
run: cargo ${{ matrix.build-std }} test --target ${{ matrix.rust-target }} --no-run | |
- name: Run Rust tests on simulator for ${{ matrix.rust-target }} | |
env: | |
DINGHY_LOG: debug | |
SIMCTL_CHILD_RUST_LOG: trace | |
SIMCTL_CHILD_RUST_BACKTRACE: full | |
timeout-minutes: 30 | |
run: | | |
cargo ${{ matrix.build-std }} test --target ${{ matrix.rust-target }} -- --test-threads 1 | |
- name: Phx server logs | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ github.job }}-${{ matrix.rust-target }} | |
path: | | |
tests/support/test_server/server.stdout.txt | |
tests/support/test_server/server.stderr.txt | |
/Users/runner/Library/Developer/CoreSimulator/Devices/*/data/Containers/Bundle/Application/*/Dinghy.app/stdout | |
android_simulator_tests: | |
# rust cross-compilation | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust Nightly | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }} | |
target: x86_64-linux-android | |
- name: Cargo Cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.CARGO_CACHE_PATH }} | |
key: cargo-${{ github.workflow }}-${{ runner.os }}-${{ runner.arch }}-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }} | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-dinghy@0.7.1 | |
- uses: ./tests/support/test_server/ | |
- 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 directory for avd | |
# This shouldn't be necesary but this is a work around for | |
# https://github.com/ReactiveCircus/android-emulator-runner/issues/197 | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
run: mkdir -p ~/.android/avd | |
- name: Create AVD and generate snapshot for caching | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: reactivecircus/android-emulator-runner@v2.32.0 | |
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.32.0 | |
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 | |
cargo dinghy -p auto-android-x86_64-api${ANDROID_API} test -- --test-threads 1 | |
- name: Phx server logs | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: phx-server-stdout-${{ github.job }}-${{ runner.os }} | |
path: | | |
tests/support/test_server/server.stdout.txt | |
tests/support/test_server/server.stderr.txt |