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

Add additional CI checks #4

Merged
merged 18 commits into from
Nov 20, 2024
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
220 changes: 218 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: CI
on:
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
on:
push:
branches:
- main
Expand All @@ -12,7 +14,6 @@ jobs:
strategy:
matrix:
target: [x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl, wasm32-unknown-unknown, wasm32-wasi, aarch64-unknown-linux-musl, aarch64-unknown-linux-gnu]
#target: [x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl, wasm32-unknown-unknown, wasm32-wasi, aarch64-unknown-linux-musl, aarch64-unknown-linux-gnu, x86_64-unknown-freebsd, x86_64-unknown-openbsd, x86_64-pc-windows-msvc]
steps:
- name: Git checkout
uses: actions/checkout@v3
Expand All @@ -38,3 +39,218 @@ jobs:
- name: Run tests
working-directory: ssip
run: cargo test
find-msrv:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.step2.outputs.version }}
steps:
- uses: actions/checkout@v4
- id: step2
run: echo "version=`cat ssip-client-async/Cargo.toml | sed -n 's/rust-version = "\(.*\)"/\1/p'`" >> "$GITHUB_OUTPUT"
benchmarks-compile:
runs-on: ubuntu-latest
needs: [clippy,no-unused-dependencies]
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Cache cargo home
uses: actions/cache@v3
env:
cache-name: cache-cargo-home
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: ${{ runner.os }}-x86_64-unknown-linux-gnu-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-x86_64-unknown-linux-gnu-build-${{ env.cache-name }}-
- name: Compile benchmarks
run: cargo bench --no-run
clippy:
runs-on: ubuntu-latest
needs: [rustfmt,no-unused-dependencies]
name: clippy (nightly)
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Cache cargo home
uses: actions/cache@v3
env:
cache-name: cache-cargo-home
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: ${{ runner.os }}-x86_64-unknown-linux-gnu-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-x86_64-unknown-linux-gnu-build-${{ env.cache-name }}-
- name: Install ${{ matrix.toolchain }}
uses: dtolnay/rust-toolchain@master
with:
components: clippy
toolchain: nightly
- name: Clippy
run: cargo clippy --tests --workspace --no-deps -- -D warnings
tests:
runs-on: ubuntu-latest
needs: [clippy,no-unused-dependencies]
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Cache cargo home
uses: actions/cache@v3
env:
cache-name: cache-cargo-home
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: ${{ runner.os }}-x86_64-unknown-linux-gnu-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-x86_64-unknown-linux-gnu-build-${{ env.cache-name }}-
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Run Tests (tokio)
run: cargo test --workspace --no-default-features --features=tokio -- --nocapture
#- name: Run Tests (async-std)
# run: cargo test --workspace --no-default-features --features=async-std -- --nocapture
rustfmt:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt
- name: Run formatter
run: cargo fmt --all --check
rustdoc:
runs-on: ubuntu-latest
needs: [clippy,no-unused-dependencies]
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Cache cargo home
uses: actions/cache@v3
env:
cache-name: cache-cargo-home
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: ${{ runner.os }}-x86_64-unknown-linux-gnu-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-x86_64-unknown-linux-gnu-build-${{ env.cache-name }}-
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
- name: Generate Documentation
run: cargo doc --workspace --no-deps --document-private-items
no-unused-dependencies:
runs-on: ubuntu-latest
needs: [rustfmt]
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Cache cargo home
uses: actions/cache@v3
env:
cache-name: cache-cargo-home
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: ${{ runner.os }}-x86_64-unknown-linux-gnu-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-x86_64-unknown-linux-gnu-build-${{ env.cache-name }}-
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Install Cargo Machete
uses: taiki-e/install-action@cargo-machete
- name: Check For Unused Dependencies
run: cargo machete
semver-compliance:
runs-on: ubuntu-latest
needs: [clippy,no-unused-dependencies]
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Cache cargo home
uses: actions/cache@v3
env:
cache-name: cache-cargo-home
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: ${{ runner.os }}-x86_64-unknown-linux-gnu-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-x86_64-unknown-linux-gnu-build-${{ env.cache-name }}-
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Install Semver Checks
# no default features so that it uses native Rust TLS instead of trying to link with system TLS.
uses: taiki-e/install-action@main
with:
tool: cargo-semver-checks
- name: Check Semver Compliance (ssip)
run: cargo semver-checks check-release -p ssip --default-features
- name: Check Semver Compliance (ssip-client-async)
run: cargo semver-checks check-release -p ssip-client-async --default-features
msrv-compliance:
runs-on: ubuntu-latest
needs: [clippy,no-unused-dependencies,find-msrv]
steps:
- name: install stable toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ needs.find-msrv.outputs.version }}
- name: Git checkout
uses: actions/checkout@v3
- name: Check MSRV Compliance (tokio)
run: cargo test --workspace --no-run --features=tokio
#- name: Check MSRV Compliance (async-std)
# run: cargo test --workspace --no-run --features=async-std
coverage:
runs-on: ubuntu-latest
needs: [clippy,no-unused-dependencies]
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Install nightly
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: llvm-tools-preview
- name: cargo install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: cargo generate-lockfile
if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile
- name: cargo llvm-cov
run: cargo llvm-cov --workspace --locked --lcov --output-path lcov.info
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
47 changes: 32 additions & 15 deletions examples/async_tokio.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
extern crate tokio;
use ssip_client::{fifo::asynchronous_tokio::Builder, ClientName, ClientResult, types::ClientScope};
use ssip_client::{
fifo::asynchronous_tokio::Builder, types::ClientScope, ClientName, ClientResult,
};

#[cfg(all(unix, feature = "tokio"))]
#[tokio::main(flavor = "current_thread")]
Expand All @@ -8,29 +10,44 @@ async fn main() -> ClientResult<()> {
let mut client = Builder::new().build().await?;
println!("Client created.");
client
.set_client_name(ClientName::new("test", "hello")).await?
.check_client_name_set().await?;
.set_client_name(ClientName::new("test", "hello"))
.await?
.check_client_name_set()
.await?;
println!("Client connected");
let msg_id = client
.speak().await?
.check_receiving_data().await?
.send_line("hello\r\n.").await?
.receive_message_id().await?;
.speak()
.await?
.check_receiving_data()
.await?
.send_line("hello\r\n.")
.await?
.receive_message_id()
.await?;
println!("message: {}", msg_id);
let volume = client.get_volume().await?.receive_u8().await?;
println!("volume: {}", volume);
match client.set_volume(ClientScope::Current, 1).await?.receive().await {
Ok(id) => println!("Volume change ID: {:?}", id),
Err(e) => println!("Error: {:?}", e),
match client
.set_volume(ClientScope::Current, 1)
.await?
.receive()
.await
{
Ok(id) => println!("Volume change ID: {:?}", id),
Err(e) => println!("Error: {:?}", e),
};
let volume = client.get_volume().await?.receive_u8().await?;
println!("volume: {}", volume);
let msg_id = client
.speak().await?
.check_receiving_data().await?
.send_line("hello\r\n.").await?
.receive_message_id().await?;
println!("id2: {}", msg_id);
.speak()
.await?
.check_receiving_data()
.await?
.send_line("hello\r\n.")
.await?
.receive_message_id()
.await?;
println!("id2: {}", msg_id);
client.quit().await?;
Ok(())
}
Expand Down
7 changes: 3 additions & 4 deletions ssip-client-async/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "ssip-client-async"
version = "0.13.0"
version = "0.14.0"
rust-version = "1.81.0"
authors = ["Laurent Pelecq <[email protected]>", "Tait Hoyem <[email protected]>"]
edition = "2021"
description = "Client API for Speech Dispatcher"
Expand All @@ -14,9 +15,6 @@ ssip = { version = "0.2.0", path = "../ssip" }
dirs = "4"
log = { version = "0.4", features = ["max_level_debug", "release_max_level_info"] }
mio = { version = "0.8", optional = true }
thiserror = "1"
strum = "0.26"
strum_macros = "0.26"
tokio = { version = "^1.21.2", features = ["io-util", "rt", "macros", "net"] }
async-std = { version = "1.12.0", default-features = true }

Expand All @@ -29,6 +27,7 @@ async-std = ["async-std/default"]
mio = { version = "0.8", features = ["os-poll", "os-ext"] }
tokio = { version = "^1.21.2", features = ["io-util", "rt"] }
async-std = { version = "1.12.0", default-features = true }
ssip-client = { version = "0.10.0" }
lazy_static = "1"
popol = "1"
tempfile = "3"
Expand Down
Loading
Loading