polyzonotope 0.2.0

Sparse polynomial zonotopes, zonotopes and interval boxes for set-based reachability analysis
Documentation
# https://taskfile.dev
# Keep `ci` in sync with .github/workflows/ci.yml: same checks, same flags.
# Keep an existing Taskfile's file name (Taskfile.yml etc.); merge these tasks into it.
version: '3'

vars:
  # Prefer cargo-nextest when installed; fall back to cargo test.
  NEXTEST:
    sh: cargo nextest --version >/dev/null 2>&1 && echo yes || echo no
  # Doctests need a library target; binary-only crates have none.
  HAS_LIB:
    sh: cargo metadata --no-deps --format-version 1 | grep -qE '"kind":\[[^]]*"(lib|rlib|proc-macro)"' && echo yes || echo no
  # Branching model checked by lint:branch: github (main + feature/) or gitflow.
  BRANCH_FLOW: github

env:
  # Newer nextest fails when a crate has no tests; warn instead (ignored by older versions).
  NEXTEST_NO_TESTS: warn

tasks:
  default:
    cmds:
      - task --list --sort=none
    silent: true

  build:
    desc: Build all targets in the workspace
    cmds:
      - cargo build --workspace --all-targets --all-features {{.CLI_ARGS}}

  test:
    desc: Run tests (nextest if installed, cargo test otherwise), then doctests
    cmds:
      - cmd: cargo nextest run --workspace --all-features {{.CLI_ARGS}}
        if: '[ "{{.NEXTEST}}" = "yes" ]'
      - cmd: cargo test --workspace --all-targets --all-features {{.CLI_ARGS}}
        if: '[ "{{.NEXTEST}}" = "no" ]'
      - task: test:doc

  test:doc:
    desc: Run doctests (nextest does not run them; skipped for binary-only crates)
    aliases: [test:docs]
    cmds:
      - cmd: cargo test --workspace --all-features --doc
        if: '[ "{{.HAS_LIB}}" = "yes" ]'

  test:prop:
    desc: Run property tests with a high case count (PROPTEST_CASES, default 10000)
    env:
      PROPTEST_CASES: '{{.PROPTEST_CASES | default "10000"}}'
    cmds:
      # A nested `task` process inherits env; `task: test` would not.
      - task test

  fmt:
    desc: Format all Rust sources
    cmds:
      - cargo fmt --all

  fmt:check:
    desc: Check formatting without modifying files
    cmds:
      - cargo fmt --all --check

  lint:
    desc: Run all linters
    cmds:
      - task: lint:clippy
      - task: lint:separators
      - task: lint:readme
      - task: lint:typos
      - task: lint:mermaid
      - task: lint:actions

  lint:clippy:
    desc: Clippy (pedantic, warnings as errors)
    cmds:
      - cargo clippy --workspace --all-targets --all-features -- -D warnings

  lint:fix:
    desc: Auto-fix clippy findings and typos, then format (review the diff)
    cmds:
      - cargo clippy --workspace --all-targets --all-features --fix --allow-dirty --allow-staged
      - typos --write-changes
      - task: fmt

  lint:separators:
    desc: Fail on `// ----` style separator comments (split the file into modules instead)
    cmds:
      - "! grep -rnE --include='*.rs' --exclude-dir=target --exclude-dir=.git '^[[:space:]]*//+[[:space:]]*[-=*#~_/]{4,}' ."

  lint:readme:
    desc: Fail on relative links or images in README files (crates.io needs absolute URLs)
    cmds:
      # `if` instead of `! a | b`: Task's shell does not negate pipelines like bash does.
      - |
        # docs/review/README.md is a GitHub-only index with generated relative links.
        if grep -rnoE --include='README.md' --exclude-dir=target --exclude-dir=.git --exclude-dir=review '(\]\(|src=")[^)"]*' . \
          | grep -vE ':(\]\(|src=")(https?://|#|mailto:)'; then
          echo "use absolute URLs for these links (docs/readme.md)"
          exit 1
        fi

  lint:typos:
    desc: Spell-check code and docs
    preconditions:
      - sh: command -v typos
        msg: "typos not found - cargo install --locked typos-cli"
    cmds:
      - typos

  lint:mermaid:
    desc: Render every mermaid diagram (Markdown and doc comments) to catch broken ones
    cmds:
      # Passes without mermaid-cli when there are no diagrams; set MMDC to override the command.
      - python3 scripts/lint-mermaid.py

  lint:branch:
    desc: Check the branch name against the branching model (BRANCH=..., default current)
    cmds:
      - sh scripts/check-branch.sh "{{.BRANCH}}" "{{.BRANCH_FLOW}}"

  lint:actions:
    desc: Lint GitHub Actions workflows (actionlint + zizmor)
    preconditions:
      - sh: command -v actionlint
        msg: "actionlint not found - https://github.com/rhysd/actionlint/blob/main/docs/install.md"
      - sh: command -v zizmor
        msg: "zizmor not found - https://docs.zizmor.sh/installation/"
    cmds:
      - actionlint
      - zizmor .github/

  doc:
    desc: Build docs including private items, warnings as errors (mermaid diagrams rendered)
    aliases: [docs]
    env:
      RUSTDOCFLAGS: -D warnings --html-in-header {{.ROOT_DIR}}/docs/mermaid.html
    cmds:
      - cargo doc --workspace --all-features --no-deps --document-private-items

  deny:
    desc: Check advisories, licenses, bans and sources
    preconditions:
      - sh: cargo deny --version
        msg: "cargo-deny not found - cargo install --locked cargo-deny"
    cmds:
      - cargo deny --all-features check

  no-std:
    desc: Test without std and build for Cortex-M4 and Cortex-M0 (mirrors the no_std CI job)
    cmds:
      - cargo test --workspace --no-default-features
      - cargo build --no-default-features --target thumbv7em-none-eabihf
      - cargo build --no-default-features --features portable-atomic/critical-section --target thumbv6m-none-eabi

  msrv:
    desc: Check every crate on its declared rust-version
    preconditions:
      - sh: cargo hack --version
        msg: "cargo-hack not found - cargo install --locked cargo-hack"
    cmds:
      - cargo hack check --rust-version --workspace --all-targets --ignore-private

  semver:
    desc: Check published library crates for semver violations
    preconditions:
      - sh: cargo semver-checks --version
        msg: "cargo-semver-checks not found - cargo install --locked cargo-semver-checks"
    cmds:
      - cargo semver-checks --workspace

  coverage:
    desc: Coverage report (lcov.info, gitignored; HTML with -- --html)
    preconditions:
      - sh: cargo llvm-cov --version
        msg: "cargo-llvm-cov not found - cargo install --locked cargo-llvm-cov"
    cmds:
      - cmd: cargo llvm-cov nextest --workspace --all-features --lcov --output-path lcov.info {{.CLI_ARGS}}
        if: '[ "{{.NEXTEST}}" = "yes" ]'
      - cmd: cargo llvm-cov --workspace --all-features --lcov --output-path lcov.info {{.CLI_ARGS}}
        if: '[ "{{.NEXTEST}}" = "no" ]'

  bench:
    desc: "Run benchmarks (criterion flags after --: task bench -- --quick)"
    cmds:
      # --bench '*': only [[bench]] targets (--benches would include lib harnesses that reject criterion flags).
      - cargo bench --workspace --bench '*' -- {{.CLI_ARGS}}

  ci:
    desc: Run the CI checks locally (mirrors .github/workflows/ci.yml)
    cmds:
      - task: lint:branch
      - task: fmt:check
      - task: lint
      - task: doc
      - task: test
      - task: deny
      - task: no-std
      - task: msrv
      - task: semver

  clean:
    desc: Remove build output and coverage reports
    cmds:
      - cargo clean
      - rm -f lcov.info