oxml-cli 0.0.7

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

on:
  push:
    branches: [main]
  # No `branches:` filter on `pull_request`. With one, a pull request
  # whose base is another branch -- a stacked PR, the natural shape for
  # a change that builds on an unmerged one -- matches nothing and gets
  # **no checks at all**. Not a red build: an empty one, which reads as
  # "nothing to report" rather than "nothing ran".
  #
  # `push` stays pinned to `main` so a branch does not build twice, once
  # for the push and once for its pull request.
  pull_request:
    branches: ['**']

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

  examples:
    name: Examples
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      # The README and doc/TESTING.md both say these run in CI. Until
      # 0.0.7 they did not, and two assertions in `inspect.sh` had
      # been failing against the published oxml for a release: the
      # sample document's node total moved when namespace nodes
      # entered the arena. A claim that a check runs is worth nothing
      # unless something runs it.
      - run: cargo build --release
      - name: Run every example, which asserts its own output
        run: OXML="$PWD/target/release/oxml" ./examples/run-all.sh

  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'