Skip to content

feat(trajectory): Trajectories.endpoints() for boundary/background sampling #77

feat(trajectory): Trajectories.endpoints() for boundary/background sampling

feat(trajectory): Trajectories.endpoints() for boundary/background sampling #77

Workflow file for this run

name: Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
unit:
name: Unit tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --group dev --python ${{ matrix.python-version }}
- name: Run unit tests
run: |
uv run --python ${{ matrix.python-version }} pytest tests/ --ignore=tests/r_stilt -m "not integration" -v --cov=src/stilt --cov-report=term-missing --cov-report=xml:coverage.xml --junitxml=junit.xml -o junit_family=legacy
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' && !cancelled() }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
- name: Upload test results to Codecov
uses: codecov/codecov-action@v5
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' && !cancelled() }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: junit.xml
report_type: test_results
integration:
name: Integration + R-STILT tests
runs-on: ubuntu-latest # HYSPLIT binary is linux_x64 only
env:
# Pinned uataq/stilt commit used for R-STILT fidelity comparison.
#
# HOW TO UPDATE:
# 1. Bump STILT_R_SHA to the new commit.
# 2. Run the fidelity tests locally:
# STILT_R_DIR=stilt-r-src uv run pytest tests/r_stilt/ -v -m integration
# 3. If tests pass → commit the new SHA.
# If tests diverge → read the diff; determine whether PYSTILT or R-STILT
# changed and update whichever is wrong before committing the SHA bump.
#
# WHAT TO WATCH in uataq/stilt git log:
# r/src/calc_footprint.r — gridding, interpolation, kernel bandwidth
# r/src/calc_trajectory.r — HNF plume dilution (calc_plume_dilution)
# r/src/permute.f90 — inner Gaussian scatter loop
# r/src/write_footprint.r — output format / precision (float32 assumption)
#
# IGNORE: run_stilt.r, stilt_cli.r, docs, R package scaffolding.
STILT_R_SHA: e2feb358b62337cbe27ed7958ab3334016ba2de1
steps:
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install dependencies
run: uv sync --group dev
- name: Restore HRRR met cache
id: met-cache
uses: actions/cache/restore@v4
with:
path: tests/met_cache
# Bump the version suffix when _MET_BLOCKS changes in conftest.py
key: met-hrrr-2021-v1
- name: Prewarm HRRR met cache
if: steps.met-cache.outputs.cache-hit != 'true'
env:
STILT_TEST_FETCH_MET: "1"
run: |
uv run pytest \
tests/test_hysplit_release_assignment.py::test_hysplit_multipoint_release_points_follow_control_order \
--setup-only -q
- name: Save HRRR met cache
if: steps.met-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: tests/met_cache
key: ${{ steps.met-cache.outputs.cache-primary-key }}
- name: Set up R
uses: r-lib/actions/setup-r@v2
with:
r-version: 'release'
- name: Install system dependencies for R packages
run: sudo apt-get install -y libnetcdf-dev libgdal-dev libgeos-dev libproj-dev libssl-dev libxml2-dev
- name: Clone uataq/stilt R source at pinned commit
run: |
git init stilt-r-src
git -C stilt-r-src fetch --depth 1 https://github.com/uataq/stilt "$STILT_R_SHA"
git -C stilt-r-src checkout FETCH_HEAD
- name: Populate R-STILT exe directory from bundled binaries
run: |
mkdir -p stilt-r-src/exe
cp stilt-r-src/bin/linux_x64/hycs_std stilt-r-src/exe/hycs_std
chmod +x stilt-r-src/exe/hycs_std
- name: Build permute.so
run: |
cd stilt-r-src/r/src
R CMD SHLIB permute.f90
- name: Run integration tests (includes R fidelity tests)
env:
STILT_R_DIR: ${{ github.workspace }}/stilt-r-src
STILT_TEST_MET_DIR: ${{ github.workspace }}/tests/met_cache
run: uv run pytest tests/ -v -m integration
- name: Run R-STILT synthetic footprint tests
env:
STILT_R_DIR: ${{ github.workspace }}/stilt-r-src
STILT_TEST_MET_DIR: ${{ github.workspace }}/tests/met_cache
run: uv run pytest tests/r_stilt/test_footprint_synth.py -v
package:
name: Package smoke test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install dependencies
run: uv sync --group dev
- name: Install build tools
run: python -m pip install --upgrade pip build twine
- name: Build distributions
run: python -m build
- name: Check distributions
run: twine check dist/*
- name: Install wheel in clean environment
run: |
python -m venv .pkgtest
.pkgtest/bin/pip install --upgrade pip
.pkgtest/bin/pip install dist/*.whl
- name: Smoke test installed package
run: |
.pkgtest/bin/python -c "import stilt; print(stilt.__version__)"
.pkgtest/bin/python -m stilt --help
.pkgtest/bin/stilt --help