codediff 0.0.11

Fast, robust, syntax-aware code diffing using tree-sitter ASTs
Documentation
name: CI

on:
  push:
    branches: [main]
  pull_request:

env:
  CARGO_TERM_COLOR: always

jobs:
  fmt:
    name: cargo fmt --check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

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

      - run: cargo fmt --check

  clippy:
    name: cargo clippy (${{ matrix.features == '' && 'default' || matrix.features }})
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        # Same reasoning as build-and-test's matrix below: each feature config is its own
        # compilation unit (see Cargo.toml's [features]), so each needs its own clippy pass, not
        # just a single default-feature run.
        features: ["", "test-fixtures", "stats"]
    steps:
      - uses: actions/checkout@v7

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

      - uses: Swatinem/rust-cache@v2
        with:
          key: clippy-${{ matrix.features }}

      - run: cargo clippy --tests --features "${{ matrix.features }}" -- -D warnings

  audit:
    name: cargo audit
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

      - uses: dtolnay/rust-toolchain@stable

      - uses: Swatinem/rust-cache@v2
        with:
          key: audit

      - run: cargo install cargo-audit --locked

      # RUSTSEC-2026-0195/-0194 (quick-xml, pulled in via syntect -> plist): both are DoS vectors
      # in untrusted-XML parsing. codediff only ever calls syntect's ThemeSet::load_defaults()
      # (bundled themes baked into the syntect binary - see src/tui/widgets/code_viewer.rs), never
      # feeds any external/user-supplied plist/XML into it, so this code path is unreachable here.
      # Can't fix directly: syntect 5.3.0 (latest as of this writing) pins plist ~1.9, which pins
      # the vulnerable quick-xml; blocked on syntect bumping its own plist dependency upstream.
      # Re-check by removing these --ignore flags occasionally.
      - run: cargo audit --ignore RUSTSEC-2026-0195 --ignore RUSTSEC-2026-0194

  mapping-site-js:
    name: human_mapping site JS tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

      - uses: actions/setup-node@v7
        with:
          node-version: 24

      # Both scripts. viewer.js is the larger of the two and went untested until 2026-08-27; see
      # the Makefile's `test-mapping-site-js` target for what these do and do not cover.
      - run: node assets/mapping_site/index.test.js
      - run: node assets/mapping_site/viewer.test.js

  # The analysis scripts under research/ compute the numbers that go into the papers, and until
  # 2026-08-27 nothing checked them at all while the Rust half had clippy -D warnings across three
  # feature configs. The ruff version is pinned for the same reason the rule set is pinned in
  # research/pyproject.toml: an unpinned linter turns CI red on a day nobody touched the code.
  python-lint:
    name: ruff (research/)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

      - uses: astral-sh/ruff-action@v3
        with:
          version: 0.16.4
          args: check
          src: research

      - uses: astral-sh/ruff-action@v3
        with:
          version: 0.16.4
          args: format --check
          src: research

  # The release gate, run on every push rather than only at deploy time - a regression is far
  # cheaper to find on the commit that caused it than in the middle of a release. Safe to gate in
  # CI because it is algorithm-only: mismatch counts against the human mapping do not vary by
  # machine (unlike the runtime figure, which `make check-quality` only warns on).
  quality:
    name: quality gate
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

      - uses: dtolnay/rust-toolchain@stable

      - uses: Swatinem/rust-cache@v2
        with:
          key: quality

      - run: make check-quality

  build-and-test:
    name: build + test (${{ matrix.features == '' && 'default' || matrix.features }})
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        # "" = default features (tui only). test-fixtures and stats are each their own
        # compilation unit - see Cargo.toml's [features] - so each needs its own build+test pass,
        # not just a single default-feature run.
        features: ["", "test-fixtures", "stats"]
    steps:
      - uses: actions/checkout@v7

      - uses: dtolnay/rust-toolchain@stable

      - uses: Swatinem/rust-cache@v2
        with:
          key: ${{ matrix.features }}

      - name: Build
        run: cargo build --release --features "${{ matrix.features }}"

      - name: Test
        run: cargo test --release --features "${{ matrix.features }}"