fitscube-rs 1.1.0

Combine single-frequency/single-time FITS images into a FITS cube (Rust port of fitscube)
Documentation
name: CI

on:
  workflow_dispatch:
  pull_request:
  push:
    branches:
      - main

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

env:
  # Many color libraries just need this variable to be set to any value.
  FORCE_COLOR: 3
  CARGO_TERM_COLOR: always

jobs:
  lint:
    name: Lint & format
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

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

      - uses: Swatinem/rust-cache@v2

      - uses: astral-sh/setup-uv@v7

      # ty type-checks against installed deps (numpy, astropy, ...), so build
      # the extension and populate .venv first; ty auto-discovers ./.venv.
      - name: Build extension and install deps
        run: uv sync --extra test --extra dev

      # Single source of truth: the same hooks developers run locally
      # (.pre-commit-config.yaml) — ruff, ty, cargo fmt, clippy. prek exits
      # nonzero if any autofix hook had to change a file, so this fails CI
      # exactly like the `--check` variants did.
      - name: prek (lint, format, type check)
        run: uvx prek run --all-files --show-diff-on-failure

  docs:
    name: Docs build
    runs-on: ubuntu-latest
    needs: [lint]
    steps:
      - uses: actions/checkout@v6

      # Rust is needed twice: maturin builds the extension during `uv sync`,
      # and sphinxcontrib-programoutput runs `cargo run -- --help` to embed
      # the CLI help text.
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - uses: Swatinem/rust-cache@v2

      - uses: astral-sh/setup-uv@v7

      - name: Build extension and install docs dependencies
        run: uv sync --group docs

      # -W makes warnings fatal. The quickstart notebook is re-executed and
      # the CLI help regenerated on every build, so stale or broken examples
      # fail here.
      - name: Build docs
        run: uv run --no-sync sphinx-build -W -b html docs docs/_build/html

  rust-test:
    name: Rust tests
    runs-on: ubuntu-latest
    needs: [lint]
    steps:
      - uses: actions/checkout@v6

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

      - uses: Swatinem/rust-cache@v2

      - name: Run Rust tests
        # The integration tests exercise the pure-Rust API; no Python features.
        run: cargo test

  python-test:
    name: Python ${{ matrix.python-version }}
    runs-on: ubuntu-latest
    needs: [lint]
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.10", "3.12", "3.13", "3.14"]
    steps:
      - uses: actions/checkout@v6

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

      - uses: Swatinem/rust-cache@v2

      - uses: astral-sh/setup-uv@v7
        with:
          python-version: ${{ matrix.python-version }}

      # Builds the maturin extension module and installs the `test` extra
      # (pytest, radio-beam, astropy). cfitsio is compiled from source via the
      # crate's `fitsio-src` feature, so no system library is needed.
      - name: Build extension and install test dependencies
        run: uv sync --extra test

      - name: Run pytest
        run: uv run --no-sync pytest -ra --durations=20