CI: Run against Numpy 2.0 nightlies #1003
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CmdStanPy | |
on: | |
push: | |
branches: | |
- 'develop' | |
- 'master' | |
tags: | |
- '**' | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
cmdstan-version: | |
description: 'Version to test' | |
required: false | |
default: '' | |
# only run one copy per PR | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
get-cmdstan-version: | |
# get the latest cmdstan version to use as part of the cache key | |
name: grab version | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get CmdStan version | |
id: check-cmdstan | |
run: | | |
if [[ "${{ github.event.inputs.cmdstan-version }}" != "" ]]; then | |
echo "version=${{ github.event.inputs.cmdstan-version }}" >> $GITHUB_OUTPUT | |
else | |
python -c 'import requests;print("version="+requests.get("https://api.github.com/repos/stan-dev/cmdstan/releases/latest").json()["tag_name"][1:])' >> $GITHUB_OUTPUT | |
fi | |
outputs: | |
version: ${{ steps.check-cmdstan.outputs.version }} | |
cmdstanpy: | |
needs: get-cmdstan-version | |
name: tests | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Check out github | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: python -m pip install --upgrade pip wheel build | |
- name: Build package | |
run: | | |
python -m build | |
python -m pip install .[test] | |
- name: Show libraries | |
run: python -m pip freeze | |
- name: Install numpy, scipy nightlies | |
if: matrix.python-version == '3.11' && matrix.os != 'windows-latest' | |
run: | | |
pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple -U numpy scipy pandas | |
- name: Run flake8, pylint, mypy | |
if: matrix.python-version == '3.11' | |
run: | | |
flake8 cmdstanpy test | |
pylint -v cmdstanpy test | |
mypy cmdstanpy | |
- name: CmdStan installation cacheing | |
id: cache-cmdstan | |
if: ${{ !startswith(needs.get-cmdstan-version.outputs.version, 'git:') }} | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cmdstan | |
key: ${{ runner.os }}-cmdstan-${{ needs.get-cmdstan-version.outputs.version }}-${{ hashFiles('**/install_cmdstan.py') }} | |
- name: Delete precompiled header (MacOS) | |
if: matrix.os == 'macos-latest' && steps.cache-cmdstan.outputs.cache-hit == 'true' | |
run: rm -f ~/.cmdstan/cmdstan-${{ needs.get-cmdstan-version.outputs.version }}/stan/src/stan/model/*.hpp.gch | |
- name: Install CmdStan (Linux, macOS) | |
if: matrix.os != 'windows-latest' | |
run: | | |
install_cmdstan -h | |
install_cxx_toolchain -h | |
python -c "import cmdstanpy; cmdstanpy.install_cmdstan(version='${{ needs.get-cmdstan-version.outputs.version }}', cores=4)" | |
- name: Install CmdStan (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
install_cmdstan -h | |
install_cxx_toolchain -h | |
python -m cmdstanpy.install_cmdstan --version ${{ needs.get-cmdstan-version.outputs.version }} --cores 4 | |
- name: Run tests | |
run: | | |
mkdir run_tests | |
cd run_tests | |
pytest -v ../test --cov=../cmdstanpy | |
- name: Submit codecov | |
run: | | |
pip install codecov | |
cd run_tests | |
codecov |