tetra3 0.11.0

Rust implementation of Tetra3: Fast and robust star plate solver
Documentation
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

env:
  CARGO_TERM_COLOR: always

jobs:
  # Formatting + clippy, mirroring the .githooks/pre-push gate so every PR is
  # checked (the hook only runs locally, on pushes to main). Separate job: no
  # test data needed, runs in parallel with `test`.
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

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

      - name: Cache Cargo registry and build
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-lint-
            ${{ runner.os }}-cargo-

      - name: Check formatting
        run: cargo fmt --all -- --check

      - name: Clippy (all targets, all features, warnings as errors)
        run: cargo clippy --all-targets --all-features -- -D warnings

      - name: Rustdoc (warnings as errors)
        run: cargo doc --no-deps --all-features
        env:
          RUSTDOCFLAGS: "-D warnings"

      # The solver's clock is cfg-switched for browser wasm
      # (src/solver/clock.rs); nothing native ever compiles that branch, so
      # lint it explicitly. Library only — dev-deps (ureq, rand) are not
      # wasm-clean and aren't needed to check the crate itself.
      - name: Add wasm32 target
        run: rustup target add wasm32-unknown-unknown

      - name: Clippy (wasm32-unknown-unknown, all features)
        run: cargo clippy -p tetra3 --lib --target wasm32-unknown-unknown --all-features -- -D warnings

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

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache Cargo registry and build
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-

      - name: Cache test data
        id: cache-test-data
        uses: actions/cache@v4
        with:
          path: data
          key: test-data-v6

      - name: Download test data
        if: steps.cache-test-data.outputs.cache-hit != 'true'
        run: |
          mkdir -p data/skyview_10deg_test_images data/tess_test_images data/tess_same_ccd
          BASE=https://storage.googleapis.com/tetra3rs-testvecs
          curl --fail -o data/gaia_merged.bin "$BASE/gaia_merged.bin"
          for f in orion_region_10deg pleiades_region_10deg cygnus_region_10deg \
                   andromeda_m31_10deg north_pole_10deg sagittarius_10deg \
                   cassiopeia_10deg scorpius_antares_10deg south_pole_10deg \
                   virgo_cluster_10deg; do
            curl --fail -o "data/skyview_10deg_test_images/${f}.fits" "$BASE/skyview_10deg_test_images/${f}.fits"
          done
          for f in moderate_density_field sparse_field_north_ecliptic dense_galactic_plane; do
            curl --fail -o "data/tess_test_images/${f}.fits" "$BASE/tess_test_images/${f}.fits"
          done
          for s in 01 02 03 04 05 06 13 14 15 17; do
            curl --fail -o "data/tess_same_ccd/sector${s}_cam1_ccd1.fits" "$BASE/tess_same_ccd/sector${s}_cam1_ccd1.fits"
          done

      - name: Check notebooks have no outputs
        run: python3 scripts/check-notebook-outputs.py

      - name: Build
        run: cargo build --verbose

      - name: Run unit tests
        run: cargo test --verbose

      - name: Run SkyView integration test
        run: cargo test --test skyview_solve_test --features image -- --nocapture

      - name: Run TESS integration test
        run: cargo test --test tess_solve_test --features image -- --nocapture

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.12"

      - name: Install Python package
        run: pip install -e .[test]

      - name: Run Python tests
        run: pytest python/tests/ -v

  # SemVer compatibility of the published `tetra3` crate against its last
  # crates.io release. For 0.x, a breaking change requires a minor bump
  # (0.8 -> 0.9); this job fails a PR that breaks the public API without one,
  # catching the "forgot to bump" trap before publish. The PyO3 crate is
  # publish=false, so only `tetra3` is checked.
  semver:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Check semver (tetra3 crate)
        uses: obi1kenobi/cargo-semver-checks-action@v2
        with:
          package: tetra3
          feature-group: all-features

  # Dependency advisories (RUSTSEC), license allow-list, and source checks
  # for the whole tree. Configured by deny.toml at the repo root.
  deny:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: cargo-deny
        uses: EmbarkStudios/cargo-deny-action@v2
        with:
          command: check

  # Verify the hand-written .pyi stub matches the compiled extension.
  # mypy is PINNED: stubtest's error set is mypy-version-sensitive, and the
  # allowlist (python/stubtest-allowlist.txt) is calibrated to this version.
  # Bumping mypy is a deliberate step — change the pin, re-run, and update the
  # allowlist if the error set moved. `--ignore-unused-allowlist` keeps a
  # now-stale entry from failing CI on its own.
  stubtest:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache Cargo registry and build
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-stubtest-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-stubtest-
            ${{ runner.os }}-cargo-

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.12"

      - name: Install package + pinned mypy
        run: |
          pip install -e .
          pip install 'mypy==2.1.0'

      - name: stubtest
        run: >
          python -m mypy.stubtest tetra3rs
          --allowlist python/stubtest-allowlist.txt
          --ignore-unused-allowlist