ggplot-rs 0.16.0

A Rust implementation of ggplot2's Grammar of Graphics
Documentation
name: CI

on:
  push:
    branches: [main]
  pull_request:

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install system dependencies
        run: sudo apt-get update && sudo apt-get install -y libfontconfig1-dev

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

      - uses: Swatinem/rust-cache@v2

      - name: Format check
        run: cargo fmt --all -- --check

      # The minimal, plotters-free configuration downstream renderers use must
      # stay tiny: ggplot-rs + indexmap (+ equivalent, hashbrown).
      - name: Minimal dependency tree (sf, no defaults)
        run: |
          cargo tree --no-default-features --features sf -e normal --prefix none \
            | sed 's/ (.*//' | sort -u | tee /dev/stderr \
            | grep -Eqv '^(ggplot-rs|indexmap|equivalent|hashbrown) ' \
            && { echo "::error::unexpected dependency in the minimal tree"; exit 1; } || true

      - name: Clippy (default)
        run: cargo clippy --all-targets -- -D warnings

      - name: Clippy (no default features)
        run: cargo clippy --all-targets --no-default-features -- -D warnings

      - name: Clippy (arrow only)
        run: cargo clippy --all-targets --no-default-features --features arrow -- -D warnings

      - name: Tests (default)
        run: cargo test

      - name: Tests (no default features)
        run: cargo test --no-default-features

      - name: Tests (arrow)
        run: cargo test --no-default-features --features arrow

      - name: Clippy (regression)
        run: cargo clippy --all-targets --features regression -- -D warnings

      - name: Tests (regression)
        run: cargo test --features regression

      # sf tests use the core DataFrame (no polars), so run without default
      # features — a lighter link that avoids the polars-heavy OOM; the coverage
      # job still exercises `sf` together with polars.
      - name: Clippy (sf)
        run: cargo clippy --all-targets --no-default-features --features sf -- -D warnings

      # Target the lib (spatial unit tests) + the sf integration test only:
      # skips the polars-using doctests and trims the link footprint.
      - name: Tests (sf)
        run: cargo test --no-default-features --features sf --lib --test sf --test native_svg

      - name: Clippy (geojson)
        run: cargo clippy --no-default-features --features geojson --lib -- -D warnings

      - name: Tests (geojson)
        run: cargo test --no-default-features --features geojson --lib spatial::geojson

      - name: Clippy (canvas)
        run: cargo clippy --all-targets --no-default-features --features canvas -- -D warnings

      - name: Tests (canvas)
        run: cargo test --no-default-features --features canvas --lib --test canvas

      - name: Clippy (ggpubr)
        run: cargo clippy --all-targets --no-default-features --features ggpubr -- -D warnings

      - name: Tests (ggpubr)
        run: cargo test --no-default-features --features ggpubr --lib --test ggpubr_basics --test ggpubr_stat_cor --test ggpubr_compare_means

      - name: Add wasm target
        run: rustup target add wasm32-unknown-unknown

      - name: Build library for wasm32 (sf + canvas, no defaults)
        run: cargo build --target wasm32-unknown-unknown --no-default-features --features sf,canvas

      - name: Clippy (wasm bindings crate)
        run: cargo clippy -p ggplot-rs-wasm --target wasm32-unknown-unknown -- -D warnings

      - name: Build (wasm bindings crate)
        run: cargo build -p ggplot-rs-wasm --target wasm32-unknown-unknown

      - name: Build examples
        run: cargo build --examples

  coverage:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install system dependencies
        run: sudo apt-get update && sudo apt-get install -y libfontconfig1-dev

      - uses: dtolnay/rust-toolchain@stable
        with:
          components: llvm-tools-preview

      - uses: Swatinem/rust-cache@v2

      - name: Install cargo-llvm-cov
        uses: taiki-e/install-action@cargo-llvm-cov

      - name: Generate coverage
        # Explicit features (not --all-features) to skip the `cli` feature, whose
        # bundled DuckDB is a slow C++ build and is exercised outside CI.
        run: cargo llvm-cov --features polars,arrow,regression,serde,sf,geojson,ggpubr --workspace --lcov --output-path lcov.info

      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v4
        with:
          files: lcov.info
          fail_ci_if_error: false
        env:
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}