siderust-py 0.2.0

Python bindings for siderust astrometry and astrodynamics
Documentation
name: Siderust Python CI

on:
  push:
    branches: [main, master]
  pull_request:
    types: [opened, synchronize, reopened, ready_for_review]

permissions:
  contents: read

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: always
  PACKAGE_NAME: siderust

jobs:
  fmt:
    name: Format
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
          cache: pip
      - name: Install formatter
        run: python -m pip install --upgrade pip ruff
      - name: Check Rust formatting
        run: |
          cargo fmt --all -- --check
          cargo fmt --manifest-path tests/interop_consumer/Cargo.toml -- --check
      - name: Check Python formatting
        run: python -m ruff format --check python tests examples scripts

  lint:
    name: Lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - uses: Swatinem/rust-cache@v2
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
          cache: pip
      - name: Install linters
        run: python -m pip install --upgrade pip ruff
      - name: Run clippy
        run: |
          cargo clippy --all-targets --all-features -- -D warnings
          cargo clippy --manifest-path tests/interop_consumer/Cargo.toml --all-targets -- -D warnings
      - name: Run ruff
        run: python -m ruff check python tests examples scripts

  rust-test:
    name: Rust Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - name: Run Rust tests
        run: cargo test --all-targets

  release-package:
    name: Release package validation
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy
      - uses: Swatinem/rust-cache@v2
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - name: Test release policy guards
        run: bash scripts/test-publish-release-policy.sh
      - name: Validate packaged release
        run: bash scripts/publish-release.sh --dry-run

  bridge-contract:
    name: Bridge Contract (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
          cache: pip
      - name: Build extensions and run bridge contract
        run: python scripts/test_interop_contract.py

  python-test:
    name: Python Test (3.${{ matrix.python-minor }})
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-minor: ["8", "9", "10", "11", "12"]
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - name: Set up Python 3.${{ matrix.python-minor }}
        uses: actions/setup-python@v5
        with:
          python-version: "3.${{ matrix.python-minor }}"
          cache: pip
      - name: Install test dependencies
        run: |
          python -m pip install --upgrade pip
          python -m pip install pytest maturin
          python -m pip install .
          python -m pip install ./tests/interop_consumer
      - name: Run Python tests
        run: |
          tmpdir="$(mktemp -d)"
          cd "$tmpdir"
          python -m pytest --rootdir "$GITHUB_WORKSPACE" "$GITHUB_WORKSPACE/tests"

  coverage:
    name: Coverage
    if: ${{ github.event_name == 'push' || github.event.pull_request.draft == false }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
          cache: pip
      - name: Install coverage dependencies
        run: |
          python -m pip install --upgrade pip
          python -m pip install pytest pytest-cov maturin
          python -m pip install .
          python -m pip install ./tests/interop_consumer
      - name: Run coverage
        run: |
          rm -f coverage.xml
          rm -rf htmlcov
          tmpdir="$(mktemp -d)"
          cd "$tmpdir"
          python -m pytest \
            --rootdir "$GITHUB_WORKSPACE" \
            --cov="${PACKAGE_NAME}" \
            --cov-branch \
            --cov-report=term-missing \
            --cov-report=xml:"$GITHUB_WORKSPACE/coverage.xml" \
            --cov-report=html:"$GITHUB_WORKSPACE/htmlcov" \
            "$GITHUB_WORKSPACE/tests"
      - name: Upload coverage artifacts
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: siderust-coverage
          path: |
            coverage.xml
            htmlcov
          retention-days: 7