rustdns 0.7.0

A DNS parsing library
Documentation
name: Rust

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

env:
  CARGO_TERM_COLOR: always

jobs:
  lint:
    name: Lint & Docs
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy
      - uses: Swatinem/rust-cache@v2

      - name: Check formatting
        run: cargo fmt --check

      - name: Install cargo-readme
        if: ${{ !cancelled() }}
        uses: taiki-e/install-action@v2
        with:
          tool: cargo-readme

      - name: Check README.md is up to date
        if: ${{ !cancelled() }}
        run: |
          cargo readme -o README.md
          git diff --exit-code -- README.md \
            || (echo "README.md is stale, run 'cargo readme -o README.md'" >&2; exit 1)

      - name: Run clippy
        if: ${{ !cancelled() }}
        run: cargo clippy --workspace --all-targets --all-features -- -D warnings

      - name: Build documentation
        if: ${{ !cancelled() }}
        env:
          RUSTDOCFLAGS: "-D warnings"
        run: cargo doc --workspace --all-features --no-deps

      - name: Install cargo-semver-checks
        if: ${{ !cancelled() }}
        uses: taiki-e/install-action@v2
        with:
          tool: cargo-semver-checks

      - name: Check semver compatibility (advisory)
        if: ${{ !cancelled() }}
        continue-on-error: true
        run: cargo semver-checks check-release --baseline-version 0.6.0 --release-type minor

      - name: Security Audit
        if: ${{ !cancelled() }}
        uses: rustsec/audit-check@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}

  test:
    name: Build & Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: llvm-tools-preview
      - uses: Swatinem/rust-cache@v2

      - name: Run tests (default features)
        run: cargo test --workspace --verbose

      - name: Run tests (no default features)
        run: cargo test --workspace --no-default-features --verbose

      - name: Run tests (all features)
        run: cargo test --workspace --all-features --verbose

      - name: Check all targets and features
        run: cargo check --workspace --all-targets --all-features

      - name: Install cargo-llvm-cov
        uses: taiki-e/install-action@cargo-llvm-cov

      - name: Code Coverage
        run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info

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

  fuzz:
    name: Fuzz smoke test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@nightly
        with:
          components: llvm-tools-preview
      - uses: Swatinem/rust-cache@v2
      - name: Install cargo-fuzz
        run: cargo install cargo-fuzz --version 0.13.2 --locked
      - name: Run fuzz target
        run: cargo fuzz run from_slice -- -max_len=4096 -runs=1000
        working-directory: fuzz