name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
FORCE_COLOR: 3
CARGO_TERM_COLOR: always
MIRIAD_CACHE_VERSION: v1
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
- name: Build extension and install deps
run: uv sync --extra test --extra dev
- name: prek (lint, format, type check)
run: uvx prek run --all-files --show-diff-on-failure
rust-test:
name: Rust tests (vs MIRIAD)
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: Cache MIRIAD install
id: miriad-cache
uses: actions/cache@v4
with:
path: ~/miriad-install
key: miriad-${{ runner.os }}-${{ env.MIRIAD_CACHE_VERSION }}
- name: Install MIRIAD build dependencies
if: steps.miriad-cache.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
gfortran libx11-dev libpng-dev libreadline-dev cmake
- name: Build MIRIAD from source
if: steps.miriad-cache.outputs.cache-hit != 'true'
run: |
git clone --depth 1 https://github.com/csiro/miriad.git /tmp/miriad-src
cmake -S /tmp/miriad-src -B /tmp/miriad-build \
-DCMAKE_INSTALL_PREFIX="$HOME/miriad-install"
cmake --build /tmp/miriad-build --target install -j"$(nproc)"
- name: Run Rust tests
run: |
# The MIRIAD comparison test reads MIRIAD_BIN and derives the rest of
# the runtime environment (catalogs, etc.) from the install prefix.
export MIRIAD_BIN="$HOME/miriad-install/bin"
# The integration tests exercise the pure-Rust API; no Python features.
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 }}
- name: Build extension and install test dependencies
run: uv sync --extra test
- name: Run pytest
run: uv run --no-sync pytest -ra --durations=20