Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 14 additions & 49 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ permissions:

jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 60
env:
COVERAGE_PROCESS_START: "${{ github.workspace }}/.coveragerc"
defaults:
run:
shell: bash
strategy:
matrix:
julia-version: ['1']
Expand All @@ -45,48 +38,20 @@ jobs:
python-version: '3.8'
os: ubuntu-latest
test-id: include

steps:
- uses: actions/checkout@v4
- name: "Set up Julia"
uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.julia-version }}
- name: "Cache Julia"
uses: julia-actions/cache@v2
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 '.[dev]'
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: "Set up coverage for subprocesses"
run: echo 'import coverage; coverage.process_startup()' > "${{ github.workspace }}/sitecustomize.py"
- name: "Run tests"
run: coverage run -m pysr test main,cli,startup
- name: "Run JAX tests"
run: coverage run --append -m pysr test jax
if: ${{ matrix.test-id == 'main' }}
- name: "Run Torch tests"
run: coverage run --append -m pysr test torch
if: ${{ matrix.test-id == 'main' }}
- name: "Build coverage report"
run: coverage xml
- name: "Upload results to Codecov"
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: MilesCranmer/PySR
uses: ./.github/workflows/reusable.yml
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
julia-version: ${{ matrix.julia-version }}
run-coverage: true
extra-tests: |
echo 'import coverage; coverage.process_startup()' > "${{ github.workspace }}/sitecustomize.py"
if [[ "${{ matrix.test-id }}" == "main" ]]; then
coverage run --append -m pysr test jax
coverage run --append -m pysr test torch
fi
coverage xml
secrets: inherit

dev_install:
runs-on: ${{ matrix.os }}
Expand Down
47 changes: 8 additions & 39 deletions .github/workflows/CI_Windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,11 @@ on:

jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 60
defaults:
run:
shell: bash
strategy:
matrix:
julia-version: ['1']
python-version: ['3.13']
os: [windows-latest]

steps:
- uses: actions/checkout@v4
- name: "Set up Julia"
uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.julia-version }}
- name: "Cache Julia"
uses: julia-actions/cache@v2
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 '.[dev]'
python -c 'import pysr'
- name: "Run tests"
run: |
python -m pysr test main,cli,startup
- name: "Install Torch"
run: pip install torch # (optional import)
- name: "Run Torch tests"
run: python -m pysr test torch
uses: ./.github/workflows/reusable.yml
with:
os: windows-latest
python-version: '3.13'
julia-version: '1'
extra-tests: |
pip install torch
python -m pysr test torch
47 changes: 8 additions & 39 deletions .github/workflows/CI_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,11 @@ on:

jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 60
defaults:
run:
shell: bash
strategy:
matrix:
julia-version: ['1']
python-version: ['3.13']
os: [macos-latest]

steps:
- uses: actions/checkout@v4
- name: "Set up Julia"
uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.julia-version }}
- name: "Cache Julia"
uses: julia-actions/cache@v2
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 '.[dev]'
python -c 'import pysr'
- name: "Run tests"
run: |
python -m pysr test main,cli,startup
- name: "Run JAX tests"
run: python -m pysr test jax
- name: "Run Torch tests"
run: python -m pysr test torch
uses: ./.github/workflows/reusable.yml
with:
os: macos-latest
python-version: '3.13'
julia-version: '1'
extra-tests: |
python -m pysr test jax
python -m pysr test torch
93 changes: 93 additions & 0 deletions .github/workflows/reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Reusable PySR Test Workflow

on:
workflow_call:
inputs:
os:
required: true
type: string
python-version:
required: false
type: string
default: '3.13'
julia-version:
required: false
type: string
default: '1'
run-coverage:
required: false
type: boolean
default: false
extra-tests:
required: false
type: string
default: ''

jobs:
test:
runs-on: ${{ inputs.os }}
timeout-minutes: 60
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v4

- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: pip


- name: "Set up Julia"
uses: julia-actions/setup-julia@v2
with:
version: ${{ inputs.julia-version }}

- name: "Cache Julia"
uses: julia-actions/cache@v2

- name: "Install PySR"
run: |
python -m pip install --upgrade pip
pip install '.[dev]'
python -c 'import pysr'

- name: "Assert Julia version"
if: ${{ inputs.julia-version != '1' }}
run: python -c "from pysr import _get_julia_project; print(_get_julia_project().julia_version); assert _get_julia_project().julia_version.startswith('${{ inputs.julia-version }}')"

- name: "Set environment variables"
run: |
echo "PYSR_TEST_JULIA_VERSION=${{ inputs.julia-version }}" >> $GITHUB_ENV
echo "PYSR_TEST_PYTHON_VERSION=${{ inputs.python-version }}" >> $GITHUB_ENV
if [[ "${{ inputs.run-coverage }}" == "true" ]]; then
echo "COVERAGE_PROCESS_START=${{ github.workspace }}/.coveragerc" >> $GITHUB_ENV
fi

- name: "Run tests"
run: |
if [[ "${{ inputs.run-coverage }}" == "true" ]]; then
coverage run -m pysr test main,cli,startup
else
python -m pysr test main,cli,startup
fi

- name: "Run extra tests"
if: ${{ inputs.extra-tests != '' }}
run: ${{ inputs.extra-tests }}

- name: "Generate coverage report"
if: ${{ inputs.run-coverage }}
run: |
coverage combine
coverage report -m

- name: "Upload results to Codecov"
if: ${{ inputs.run-coverage }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: MilesCranmer/PySR
Loading