Skip to content

Commit

Permalink
ci: run on Android API Level 25
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Dec 12, 2024
1 parent 204b147 commit 8f75d25
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 231 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust-android-run-tests-on-emulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ any_failures=0
for test in $(find target/$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
adb shell API_LEVEL=$API_LEVEL /data/local/tmp/$(basename "$test") || any_failures=1
done

exit $any_failures
238 changes: 9 additions & 229 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,235 +2,30 @@ 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
run: |
export PATH="$HOME/.cargo/bin:$PATH"
echo "===== rustc --version ====="
rustc --version
echo "===== freebsd-version ====="
freebsd-version
cargo build --all-targets && cargo test && cargo test --manifest-path fuzz/Cargo.toml && cargo test -p quinn-udp --benches
test-netbsd:
name: test on netbsd
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: test on netbsd
uses: vmactions/netbsd-vm@v1
with:
usesh: true
mem: 4096
copyback: false
prepare: |
export PATH="/usr/sbin:/sbin:$PATH"
pkg_add curl
curl https://sh.rustup.rs -sSf --output rustup.sh
sh rustup.sh -y --profile minimal --default-toolchain stable
run: |
export PATH="$HOME/.cargo/bin:$PATH"
echo "===== rustc --version ====="
rustc --version
echo "===== uname -a ====="
uname -a
cargo build --all-targets && cargo test && cargo test --manifest-path fuzz/Cargo.toml && cargo test -p quinn-udp --benches
test-solaris:
name: test on solaris
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: test on Solaris
uses: vmactions/solaris-vm@v1
with:
release: "11.4-gcc"
usesh: true
mem: 4096
copyback: false
prepare: |
source <(curl -s https://raw.githubusercontent.com/psumbera/solaris-rust/refs/heads/main/sh.rust-web-install)
echo "~~~~ rustc --version ~~~~"
rustc --version
echo "~~~~ Solaris-version ~~~~"
uname -a
run: |
export PATH=$HOME/.rust_solaris/bin:$PATH
cargo build --all-targets && cargo test && cargo test --manifest-path fuzz/Cargo.toml && cargo test -p quinn-udp --benches
test-illumos:
name: test on illumos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: test on Illumos
uses: vmactions/omnios-vm@v1
with:
usesh: true
mem: 4096
copyback: false
prepare: |
pkg install gcc14 curl pkg-config glib2
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
run: |
. "$HOME/.cargo/env"
cargo build --all-targets && cargo test && cargo test --manifest-path fuzz/Cargo.toml && cargo test -p quinn-udp --benches
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"
- run: cargo test -p quinn-udp --benches

test-aws-lc-rs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
# Prevent feature unification from selecting *ring* as the crypto provider
- run: RUST_BACKTRACE=1 cargo test --manifest-path quinn-proto/Cargo.toml --no-default-features --features rustls-aws-lc-rs
- run: RUST_BACKTRACE=1 cargo test --manifest-path quinn/Cargo.toml --no-default-features --features rustls-aws-lc-rs,runtime-tokio
# FIPS
- run: RUST_BACKTRACE=1 cargo test --manifest-path quinn-proto/Cargo.toml --no-default-features --features rustls-aws-lc-rs-fips
- run: RUST_BACKTRACE=1 cargo test --manifest-path quinn/Cargo.toml --no-default-features --features rustls-aws-lc-rs-fips,runtime-tokio

wasm_test:
name: test wasm32-unknown-unknown
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable

- name: Add wasm target
run: rustup target add wasm32-unknown-unknown

- name: Install nodejs v20
uses: actions/setup-node@v4
with:
node-version: 20

- name: Setup `wasm-tools`
uses: bytecodealliance/actions/wasm-tools/setup@v1

- name: Install cargo binstall
uses: cargo-bins/cargo-binstall@main

- name: build wasm32 tests (quinn-proto)
run: cargo test -p quinn-proto --target wasm32-unknown-unknown --no-run

# If the Wasm file contains any 'import "env"' declarations, then
# some non-Wasm-compatible code made it into the final code.
- name: Check for 'import "env"' in Wasm
run: |
! wasm-tools print --skeleton target/wasm32-unknown-unknown/debug/deps/quinn_proto-*.wasm | grep 'import "env"'
- name: Install wasm-bindgen-test-runner
run: cargo binstall wasm-bindgen-cli --locked --no-confirm

- name: wasm32 test (quinn-proto)
run: cargo test -p quinn-proto --target wasm32-unknown-unknown

msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Note that we must also update the README when changing the MSRV
- 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@v2

test-android:
runs-on: ubuntu-latest

strategy:
matrix:
include:
target: [x86_64-linux-android, i686-linux-android]
emulator-arch: [x86_64, x86]
api-level: [26, 25]
exclude:
- target: x86_64-linux-android
emulator-arch: x86_64
# Note that x86_64 image is only available for API 21+. See
# https://github.com/ReactiveCircus/android-emulator-runner?tab=readme-ov-file#configurations.
api-level: 26
- target: i686-linux-android
emulator-arch: x86
api-level: 26
- target: i686-linux-android
emulator-arch: x86_64

steps:
- name: Set API level environment variable
run: echo "API_LEVEL=${{ matrix.api-level }}" >> $GITHUB_ENV

- name: Checkout code
uses: actions/checkout@v4

Expand Down Expand Up @@ -274,18 +69,3 @@ jobs:
api-level: ${{ matrix.api-level }}
arch: ${{ matrix.emulator-arch }}
script: .github/workflows/rust-android-run-tests-on-emulator.sh

features:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
env:
RUSTFLAGS: -Dwarnings
# skip FIPS features outside of Linux
SKIP_FEATURES: ${{ matrix.os != 'ubuntu-latest' && 'rustls-aws-lc-rs-fips,aws-lc-rs-fips' || '' }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@cargo-hack
- run: cargo hack check --feature-powerset --optional-deps --no-dev-deps --ignore-unknown-features --ignore-private --group-features runtime-async-std,async-io,async-std --group-features runtime-smol,async-io,smol --skip "${{env.SKIP_FEATURES}}"
19 changes: 18 additions & 1 deletion quinn-udp/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ fn basic() {
);
}

#[test]
fn test_api_level_panics() {
let api_level = std::env::var("API_LEVEL").unwrap_or_else(|_| "unknown".to_string());
panic!("Test is panicking with API_LEVEL: {}", api_level);
}

#[test]
fn ecn_v6() {
let send = Socket::from(UdpSocket::bind((Ipv6Addr::LOCALHOST, 0)).unwrap());
Expand Down Expand Up @@ -240,7 +246,18 @@ fn test_send_recv(send: &Socket, recv: &Socket, transmit: Transmit) {
),
}
}
assert_eq!(meta.ecn, transmit.ecn);

if cfg!(target_os = "android")
&& std::env::var("API_LEVEL")
.ok()
.and_then(|v| v.parse::<u32>().ok())
.expect("API_LEVEL environment variable to be set on Android")
<= 25
{
assert_eq!(meta.ecn, None);
} else {
assert_eq!(meta.ecn, transmit.ecn);
}
}
assert_eq!(datagrams, expected_datagrams);
}
Expand Down

0 comments on commit 8f75d25

Please sign in to comment.