oxml-cli 0.0.5

Command-line XML querying, validation and formatting, powered by oxml
name: CI

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

permissions:
  contents: read

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

jobs:
  test:
    name: Test (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo test --all-features

  lint:
    name: Lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy
      - uses: Swatinem/rust-cache@v2
      - run: cargo fmt --all --check
      - run: cargo clippy --all-targets --all-features -- -D warnings
      - run: cargo doc --no-deps --all-features
        env:
          RUSTDOCFLAGS: "-D warnings"

  unsafe:
    name: Forbid unsafe
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: The crate must forbid unsafe code
        run: |
          if ! grep -rq '#!\[forbid(unsafe_code)\]' src/; then
            echo "::error::#![forbid(unsafe_code)] is missing"
            exit 1
          fi
          echo "unsafe_code is forbidden"

  coverage:
    name: Coverage
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: llvm-tools-preview
      - uses: taiki-e/install-action@cargo-llvm-cov
      - uses: Swatinem/rust-cache@v2
      # Every defect fixed in 0.0.3 was found by raising coverage, not
      # by reading the code. The floor keeps that from eroding: a new
      # branch nothing exercises fails here rather than shipping.
      - run: >
          cargo llvm-cov --all-features --fail-under-lines 95
          --ignore-filename-regex 'builds/cargo/package'