language-text-analysis 0.1.3

Small, deterministic multilingual text-analysis pipeline for search and document processing
Documentation
name: CI/CD

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

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  # Check code formatting (nightly rustfmt, matching the dataroad house style).
  fmt:
    name: Format
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@nightly
        with:
          components: rustfmt
      - name: Check formatting
        run: cargo +nightly fmt --all -- --check

  # Lint.
  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          components: clippy
          rustflags: "" # don't override RUSTFLAGS; clippy sets its own
      - name: Run clippy
        run: cargo clippy --all-targets --all-features -- -D warnings

  # Test on the unix platforms the transport targets today (the Windows
  # message-pipe backend is a future milestone).
  test:
    name: Test
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
    steps:
      - uses: actions/checkout@v7
      - uses: actions-rust-lang/setup-rust-toolchain@v1
      - name: Run tests
        run: cargo test
      - name: Run doc tests
        run: cargo test --doc

  # Publish the current Cargo.toml version to crates.io on push to main.
  # Idempotent: an already-published version is treated as success, so this
  # only ever uploads a version bump (see also auto-version-bump.yml). Uses the
  # legra-ai org-level CRATES_IO secret.
  publish:
    name: Publish to crates.io
    runs-on: ubuntu-latest
    needs: [fmt, clippy, test]
    if: github.ref == 'refs/heads/main' && github.event_name == 'push'
    steps:
      - uses: actions/checkout@v7
      - uses: actions-rust-lang/setup-rust-toolchain@v1
      - name: cargo publish (treat "already published" as success)
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
        run: |
          rc=0
          LOG=$(cargo publish 2>&1) || rc=$?
          echo "$LOG"
          if [ "$rc" -eq 0 ]; then exit 0; fi
          if echo "$LOG" | grep -q "already exists on crates.io"; then
            echo "already on crates.io, skipping"
            exit 0
          fi
          exit "$rc"