embedded-io-cursor 0.1.0

A no_std-compatible Cursor implementation designed for use with embedded-io.
Documentation
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  release:
    types: [created]
env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    name: Test (all feature combinations)
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rust:
          - stable
          - beta
          - nightly

    steps:
      - uses: actions/checkout@v5

      - name: Install Rust
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.rust }}

      - name: Install cargo-hack
        run: cargo install cargo-hack

      - name: Cache dependencies
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}

      - name: Run tests with all feature combinations
        run: cargo hack test --feature-powerset

  test-embedded:
    name: Test embedded targets
    runs-on: ubuntu-latest
    strategy:
      matrix:
        target:
          - thumbv7em-none-eabi
          - thumbv7m-none-eabi
          - riscv32imac-unknown-none-elf

    steps:
      - uses: actions/checkout@v5

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Cache dependencies
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-nostd-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}

      - name: Build (no_std)
        run: cargo build --target ${{ matrix.target }} --no-default-features

      - name: Build (no_std + alloc)
        run: cargo build --target ${{ matrix.target }} --no-default-features --features alloc

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy

      - name: Install cargo-hack
        run: cargo install cargo-hack

      - name: Cache dependencies
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}

      - name: Run clippy with all feature combinations
        run: cargo hack clippy --feature-powerset -- -D warnings

  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt

      - name: Run rustfmt
        run: cargo fmt --all -- --check

  docs:
    name: Docs
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

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

      - name: Install cargo-hack
        run: cargo install cargo-hack

      - name: Cache dependencies
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-docs-${{ hashFiles('**/Cargo.lock') }}

      - name: Check documentation with all feature combinations
        run: cargo hack doc --feature-powerset --no-deps --document-private-items
        env:
          RUSTDOCFLAGS: -D warnings

  msrv:
    name: MSRV
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - name: Install Rust 1.66
        uses: dtolnay/rust-toolchain@1.66.0

      - name: Cache dependencies
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-msrv-${{ hashFiles('**/Cargo.lock') }}

      - name: Check MSRV
        run: cargo check --no-default-features

      - name: Check MSRV (with alloc)
        run: cargo check --no-default-features --features alloc

  coverage:
    name: Coverage
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

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

      - name: Install cargo-tarpaulin
        run: cargo install cargo-tarpaulin

      - name: Cache dependencies
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}

      - name: Generate coverage report
        run: |
          cargo tarpaulin --verbose --features std --workspace --timeout 120 --out xml

      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v5
        with:
          fail_ci_if_error: false
          token: ${{ secrets.CODECOV_TOKEN }}

  publish:
    name: Publish to crates.io
    runs-on: ubuntu-latest
    if: github.event_name == 'release'
    needs: [test, test-embedded, clippy, fmt, docs, msrv]
    steps:
      - uses: actions/checkout@v5

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

      - name: Publish to crates.io
        run: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_API_TOKEN }}