From 94e0afb67ae1b451e2073a31ebb93c9958425b56 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Wed, 25 Mar 2026 13:48:35 -0500 Subject: [PATCH] ci: add GitHub Actions CI and release workflows Add ci.yml running fmt, clippy, build, and test on stable + nightly Rust for PRs and pushes to main. Add release.yml for automated crate publishing to crates.io on version tag pushes. Remove dead_code allow and add crate-level doc comment with usage example. --- .github/workflows/ci.yml | 47 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 39 +++++++++++++++++++++++++++++ src/lib.rs | 20 +++++++++++++-- 3 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..374acf7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,47 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +env: + CARGO_TERM_COLOR: always + +jobs: + check: + name: Check (${{ matrix.toolchain }}) + runs-on: ubuntu-latest + strategy: + matrix: + toolchain: [stable, nightly] + steps: + - uses: actions/checkout@v4 + + - name: Install Rust ${{ matrix.toolchain }} + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.toolchain }} + components: rustfmt, clippy + + - name: Cache cargo registry and build + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.toml') }} + + - name: Check formatting + run: cargo fmt --check + + - name: Run clippy + run: cargo clippy -- -D warnings + + - name: Build + run: cargo build + + - name: Run tests + run: cargo test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..795bd35 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,39 @@ +name: Release + +on: + push: + tags: + - "v*.*.*" + +env: + CARGO_TERM_COLOR: always + +jobs: + publish: + name: Publish to crates.io + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Rust stable + uses: dtolnay/rust-toolchain@stable + + - name: Cache cargo registry and build + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.toml') }} + + - name: Build release + run: cargo build --release + + - name: Run tests + run: cargo test + + - name: Publish to crates.io + run: cargo publish + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/src/lib.rs b/src/lib.rs index 04be470..053d117 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,21 @@ -#![allow(dead_code)] - +/// Rust SDK for the Onspring API v2. +/// +/// # Example +/// +/// ```no_run +/// use onspring::{OnspringClient, PagingRequest}; +/// +/// # async fn example() -> onspring::Result<()> { +/// let client = OnspringClient::builder("your-api-key").build(); +/// +/// // Check connectivity +/// client.ping().await?; +/// +/// // List apps +/// let apps = client.list_apps(None).await?; +/// # Ok(()) +/// # } +/// ``` pub mod client; mod endpoints; pub mod error;