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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
218 changes: 216 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,216 @@ jobs:
- name: Run tests
working-directory: ssip-common
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 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 (1k)
run: cargo bench --no-run --bench event_parsing
- name: Compile benchmarks (100k)
run: cargo bench --no-run --bench event_parsing_100k
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
run: LOCKSTEP_XML_PATH="../xml" cargo semver-checks check-release -p atspi --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
run: cargo test --workspace --no-run --all-features
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
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ dirs = "4"
log = { version = "0.4", features = ["max_level_debug", "release_max_level_info"] }
mio = { version = "0.8", optional = true }
thiserror = "1"
strum = "0.24"
strum_macros = "0.24"
tokio = { version = "^1.21.2", features = ["io-util", "rt", "macros", "net"] }
async-std = { version = "1.12.0", default_features = true }

Expand Down
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
Loading
Loading