chartlet 0.21.0

Compile structured data into deterministic, accessible static charts
Documentation
name: CI

on:
  push:
    branches: [main]
    tags: ["v*"]
  pull_request:

permissions:
  contents: read

concurrency:
  group: ci-${{ github.ref }}
  cancel-in-progress: true

jobs:
  test:
    name: ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    timeout-minutes: 30
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest]
    steps:
      - uses: actions/checkout@v7

      # The version, components and targets come from rust-toolchain.toml.
      - name: Rust toolchain
        run: rustup toolchain install

      - uses: Swatinem/rust-cache@v2

      - name: Format
        run: cargo fmt --check

      - name: Lint
        run: |
          cargo clippy --all-targets -- -D warnings
          cargo clippy --all-targets --features png -- -D warnings
          cargo clippy -p chartlet-wasm --target wasm32-unknown-unknown -- -D warnings

      # The golden tests compare every example (SVG, HTML and their variants) against the
      # committed files, and fail for a file they do not know, so this also checks that the
      # examples are up to date and the output is byte-identical on every platform.
      - name: Test
        run: |
          cargo test
          cargo test --features png --test png --test cli

      - uses: actions/setup-node@v7
        with:
          node-version: 22
          cache: npm
          cache-dependency-path: packages/chartlet/package-lock.json

      # wasm-opt, so the size budget applies to the module as it ships; the same version as the
      # local builds.
      - name: Install wasm-opt
        env:
          BINARYEN: version_133
        run: |
          case "$RUNNER_OS-$RUNNER_ARCH" in
            Linux-X64) platform=x86_64-linux ;;
            macOS-ARM64) platform=arm64-macos ;;
            macOS-X64) platform=x86_64-macos ;;
            *) echo "no binaryen build for $RUNNER_OS-$RUNNER_ARCH"; exit 1 ;;
          esac
          curl -sSfL "https://github.com/WebAssembly/binaryen/releases/download/$BINARYEN/binaryen-$BINARYEN-$platform.tar.gz" | tar -xz -C "$RUNNER_TEMP"
          echo "$RUNNER_TEMP/binaryen-$BINARYEN/bin" >> "$GITHUB_PATH"

      # The tests render through the WebAssembly build and, with an explicit binary, the CLI.
      - name: npm package and Astro integration
        working-directory: packages/chartlet
        run: |
          npm ci
          npm run build:wasm
          npm test

      # Runs against packages/chartlet as built above, so the server is tested with the compiler
      # of the same commit; the view test needs a browser.
      - name: MCP server
        if: matrix.os == 'ubuntu-latest'
        working-directory: packages/chartlet-mcp
        run: |
          npm ci
          npm install --no-save ../chartlet
          npx playwright install --with-deps chromium
          npm test

      - uses: pnpm/action-setup@v6
        if: matrix.os == 'ubuntu-latest'
        with:
          version: 10

      - name: Install site browser
        if: matrix.os == 'ubuntu-latest'
        working-directory: site
        run: |
          pnpm install --frozen-lockfile
          pnpm exec playwright install --with-deps chromium

      - name: Site build and accessibility
        if: matrix.os == 'ubuntu-latest'
        working-directory: site
        run: pnpm test