uagent 0.1.0

Browser user agents with matching navigation headers and deterministic profile selection.
Documentation
name: Build

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

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1
  RUST_TOOLCHAIN: "1.95.0"
  RUST_MSRV: "1.90.0"

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

permissions:
  contents: read

jobs:
  fmt:
    name: Format
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v7

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

      - name: Check formatting
        run: cargo +nightly fmt --all -- --check

      - name: Check generated browser data
        run: python3 tools/update.py --check

  check:
    name: Check
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v7

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

      - name: Cache cargo registry and build
        uses: Swatinem/rust-cache@v2

      - name: Check
        run: cargo check --workspace

      - name: Check (no default features)
        run: cargo check --workspace --no-default-features

      - name: Check (all features)
        run: cargo check --workspace --all-features

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

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

      - name: Cache cargo registry and build
        uses: Swatinem/rust-cache@v2

      - name: Check (all features)
        run: cargo check --workspace --all-features

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

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ env.RUST_TOOLCHAIN }}
          components: clippy

      - name: Cache cargo registry and build
        uses: Swatinem/rust-cache@v2

      - name: Clippy
        run: cargo clippy --workspace -- -D warnings

      - name: Clippy (all features)
        run: cargo clippy --workspace --all-features --all-targets -- -D warnings

  test:
    name: Test (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    needs: check
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
      - name: Checkout
        uses: actions/checkout@v7

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

      - name: Cache cargo registry and build
        uses: Swatinem/rust-cache@v2

      - name: Run tests
        run: cargo test --workspace --all-features

  docs:
    name: Docs
    runs-on: ubuntu-latest
    needs: check
    steps:
      - name: Checkout
        uses: actions/checkout@v7

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

      - name: Cache cargo registry and build
        uses: Swatinem/rust-cache@v2

      - name: Build docs
        run: cargo +nightly doc --no-deps --all-features --workspace
        env:
          RUSTDOCFLAGS: "--cfg docsrs -D warnings"

  semver:
    name: Semver
    runs-on: ubuntu-latest
    if: github.event_name == 'pull_request'
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          fetch-depth: 0

      - name: Find baseline crate
        id: baseline
        env:
          BASE_REV: ${{ github.event.pull_request.base.sha }}
        run: |
          if git cat-file -e "$BASE_REV:Cargo.toml" 2>/dev/null; then
            echo "exists=true" >> "$GITHUB_OUTPUT"
          else
            echo "exists=false" >> "$GITHUB_OUTPUT"
            echo "No baseline crate exists yet; skipping the initial API comparison."
          fi

      - name: Check semver
        if: steps.baseline.outputs.exists == 'true'
        uses: obi1kenobi/cargo-semver-checks-action@v2
        with:
          feature-group: all-features
          baseline-rev: ${{ github.event.pull_request.base.sha }}

  machete:
    name: Machete
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v7

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

      - name: Install cargo-binstall
        uses: cargo-bins/cargo-binstall@main

      - name: Install cargo-machete
        run: cargo binstall cargo-machete --no-confirm --no-symlinks

      - name: Run machete
        run: cargo machete