const-cbor 0.3.0

A const-first, no_std, allocation-free CBOR (RFC 8949) codec with no dependencies and no unsafe.
Documentation
name: CI

on:
  push:
    branches: [main]
  pull_request:

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: "-D warnings"

jobs:
  test:
    strategy:
      matrix:
        include:
          - crate: .
            features: ""
          - crate: .
            features: "--features float"
          - crate: .
            features: "--features std"
          - crate: .
            features: "--features bignum"
          - crate: .
            features: "--features deterministic"
          - crate: .
            features: "--all-features"
          - crate: serde
            features: ""
          - crate: serde
            features: "--features bignum --all-features"
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: cargo test ${{ matrix.features }} --manifest-path ${{ matrix.crate == 'serde' && 'serde/Cargo.toml' || 'Cargo.toml' }}
      - if: matrix.crate != 'serde'
        run: cargo bench --no-run

  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: cargo fmt --check
      - run: cargo clippy --all-features --all-targets --manifest-path Cargo.toml -- -D warnings
      - run: cargo clippy --all-features --all-targets --manifest-path serde/Cargo.toml -- -D warnings

  coverage:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: rustup component add llvm-tools-preview
      - run: cargo install cargo-llvm-cov --locked
      # Gate: line coverage must stay at or above 90%.
      - run: cargo llvm-cov --all-features --fail-under-lines 90

  fuzz:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4
      - run: cargo install cargo-fuzz --locked
      - run: cargo fuzz build
      - run: cargo fuzz run decode -- -runs=100000

  no_std:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        target: [thumbv7m-none-eabi, aarch64-unknown-none]
    steps:
      - uses: actions/checkout@v4
      - run: rustup target add ${{ matrix.target }}
      - run: cargo build --target ${{ matrix.target }} --all-features
      - run: cargo build --target ${{ matrix.target }} --release

  size:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: rustup target add thumbv7m-none-eabi
      - name: Build Cortex-M3 size probe
        run: cargo build --profile size --target thumbv7m-none-eabi --example cbor-size --all-features
      - name: Gate linked size (.text + .rodata)
        run: |
          SIZE=$(size target/thumbv7m-none-eabi/size/examples/cbor-size | awk 'NR==2{print $1+$2}')
          echo "probe .text+.rodata: $SIZE bytes"
          test "$SIZE" -lt 26000