name: CI

on:
  pull_request:
  push:
    branches: [main]

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

jobs:
  test:
    name: test + lint + coverage
    runs-on: ubuntu-latest
    timeout-minutes: 6
    steps:
      - uses: actions/checkout@v5

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy, rustfmt

      - uses: Swatinem/rust-cache@v2

      - name: Install cargo-tarpaulin
        uses: taiki-e/install-action@v2
        with:
          tool: cargo-tarpaulin

      - name: cargo test
        run: cargo test --all-targets

      - name: cargo clippy
        run: cargo clippy --all-targets -- -D warnings

      - name: line-length check
        run: bash scripts/check-line-lengths.sh

      - name: coverage (100%)
        run: bash scripts/check-coverage.sh

      - name: cargo publish --dry-run
        run: cargo publish --dry-run
