ci: add Android job #4569
Workflow file for this run
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: | |
push: | |
branches: ['main', '0.8.x'] | |
pull_request: | |
merge_group: | |
schedule: | |
- cron: "21 3 * * 5" | |
jobs: | |
test-freebsd: | |
# see https://github.com/actions/runner/issues/385 | |
# use https://github.com/vmactions/freebsd-vm for now | |
name: test on freebsd | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: test on freebsd | |
uses: vmactions/freebsd-vm@v1 | |
with: | |
usesh: true | |
mem: 4096 | |
copyback: false | |
prepare: | | |
pkg install -y curl | |
curl https://sh.rustup.rs -sSf --output rustup.sh | |
sh rustup.sh -y --profile minimal --default-toolchain stable | |
echo "~~~~ rustc --version ~~~~" | |
$HOME/.cargo/bin/rustc --version | |
echo "~~~~ freebsd-version ~~~~" | |
freebsd-version | |
run: $HOME/.cargo/bin/cargo build --all-targets && $HOME/.cargo/bin/cargo test && $HOME/.cargo/bin/cargo test --manifest-path fuzz/Cargo.toml | |
test: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
rust: [stable, beta] | |
exclude: | |
- os: macos-latest | |
rust: beta | |
- os: windows-latest | |
rust: beta | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust }} | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo build --all-targets | |
- run: cargo test | |
- run: cargo test --manifest-path fuzz/Cargo.toml | |
if: ${{ matrix.rust }} == "stable" | |
msrv: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/[email protected] | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo check --lib --all-features -p quinn-udp -p quinn-proto -p quinn | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt, clippy | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo fmt --all -- --check | |
- run: cargo check --manifest-path quinn/Cargo.toml --all-targets --no-default-features | |
- run: cargo clippy --all-targets -- -D warnings | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
components: clippy | |
- name: doc | |
run: cargo doc --no-deps --document-private-items | |
env: | |
RUSTDOCFLAGS: -Dwarnings | |
- name: lint fuzz | |
run: | | |
cd fuzz | |
cargo clippy -- -D warnings | |
audit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: EmbarkStudios/cargo-deny-action@v1 | |
test-android: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- target: x86_64-linux-android | |
emulator-arch: x86_64 | |
- target: i686-linux-android | |
emulator-arch: x86 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '21' | |
- name: Install Android SDK | |
uses: android-actions/setup-android@v2 | |
- name: Install Android NDK | |
run: sdkmanager --install "ndk;25.2.9519653" | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
target: ${{ matrix.target }} | |
- uses: Swatinem/rust-cache@v2 | |
- name: Install cargo-ndk | |
run: cargo install cargo-ndk | |
- name: Build unit tests for Android | |
run: cargo ndk -t ${{ matrix.target }} test --no-run | |
- name: Enable KVM group perms | |
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: Create emulator script | |
run: | | |
echo '#!/bin/bash | |
set -e | |
adb wait-for-device | |
while [[ -z "$(adb shell getprop sys.boot_completed | tr -d '\r')" ]]; do sleep 1; done | |
any_failures=0 | |
for test in $(find target/${{ matrix.target }}/debug/deps/ -type f -executable ! -name "*.so" -name "*-*"); do | |
adb push "$test" /data/local/tmp/ | |
adb shell chmod +x /data/local/tmp/$(basename "$test") | |
adb shell /data/local/tmp/$(basename "$test") || any_failures=1 | |
done | |
exit $any_failures' > run_tests_on_emulator.sh && chmod +x run_tests_on_emulator.sh | |
- name: Set up Android Emulator and run tests | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: 29 | |
arch: ${{ matrix.emulator-arch }} | |
profile: pixel_2 | |
script: ./run_tests_on_emulator.sh |