MilesCranmer's picture
Add Python 3.12 to test suite
62ecf50 unverified
raw
history blame
5.56 kB
name: Linux
on:
push:
branches:
- '**'
paths:
- 'test/**'
- 'pysr/**'
- '.github/workflows/CI.yml'
- 'setup.py'
tags:
- 'v*.*.*'
pull_request:
branches:
- '*'
paths:
- 'test/**'
- 'pysr/**'
- '.github/workflows/CI.yml'
- 'setup.py'
jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 60
defaults:
run:
shell: bash
strategy:
matrix:
julia-version: ['1']
python-version: ['3.11']
os: [ubuntu-latest]
test-id: [main]
include:
- julia-version: '1.6'
python-version: '3.7'
os: ubuntu-latest
test-id: include
- julia-version: '1'
python-version: '3.12'
os: ubuntu-latest
test-id: include
steps:
- uses: actions/checkout@v4
- name: "Set up Julia"
uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
- name: "Cache Julia"
uses: julia-actions/cache@v1
with:
cache-name: ${{ matrix.os }}-test-${{ matrix.julia-version }}-${{ matrix.python-version }}
cache-packages: false
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: "Install PySR"
run: |
python -m pip install --upgrade pip
pip install .
python -c 'import pysr'
- name: "Assert Julia version"
if: ${{ matrix.julia-version != '1'}}
run: python3 -c "from pysr import jl; assert jl.VERSION.major == jl.seval('v\"${{ matrix.julia-version }}\"').major; assert jl.VERSION.minor == jl.seval('v\"${{ matrix.julia-version }}\"').minor"
- name: "Install Coverage tool"
run: pip install coverage coveralls
- name: "Run tests"
run: |
coverage run --source=pysr --omit='*/test/*' -m pysr test main
coverage run --append --source=pysr --omit='*/test/*' -m pysr test cli
- name: "Install JAX"
run: pip install jax jaxlib # (optional import)
if: ${{ matrix.test-id == 'main' }}
- name: "Run JAX tests"
run: coverage run --append --source=pysr --omit='*/test/*' -m pysr test jax
if: ${{ matrix.test-id == 'main' }}
- name: "Install Torch"
run: pip install torch # (optional import)
if: ${{ matrix.test-id == 'main' }}
- name: "Run Torch tests"
run: coverage run --append --source=pysr --omit='*/test/*' -m pysr test torch
if: ${{ matrix.test-id == 'main' }}
- name: "Coveralls"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: test-${{ matrix.julia-version }}-${{ matrix.python-version }}
COVERALLS_PARALLEL: true
run: coveralls --service=github
conda_test:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
python-version: ['3.11']
os: ['ubuntu-latest']
steps:
- uses: actions/checkout@v4
- name: "Cache conda"
uses: actions/cache@v4
env:
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }}
- name: "Set up Conda"
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
auto-activate-base: true
python-version: ${{ matrix.python-version }}
activate-environment: pysr-test
environment-file: environment.yml
- name: "Cache Julia"
uses: julia-actions/cache@v1
with:
cache-name: ${{ matrix.os }}-conda-${{ matrix.python-version }}
cache-packages: false
- name: "Install PySR"
run: |
python3 -m pip install .
python3 -c 'import pysr'
- name: "Run tests"
run: cd /tmp && python -m pysr test main
coveralls:
name: Indicate completion to coveralls.io
needs:
- test
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
container: python:3-slim
steps:
- name: Finished
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pip install coveralls
coveralls --finish
types:
name: Check types
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
python-version:
- '3.11'
- '3.7'
os: ['ubuntu-latest']
steps:
- uses: actions/checkout@v4
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: "Install PySR and all dependencies"
run: |
python -m pip install --upgrade pip
pip install .
pip install mypy
- name: "Install additional dependencies"
run: python -m pip install jax jaxlib torch
if: ${{ matrix.python-version != '3.7' }}
- name: "Run mypy"
run: python -m mypy --install-types --non-interactive pysr
if: ${{ matrix.python-version != '3.7' }}
- name: "Run compatible mypy"
run: python -m mypy --ignore-missing-imports pysr
if: ${{ matrix.python-version == '3.7' }}