Stan 2.33: Move IO munging to external package, refactors #894
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"] | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Check out github | |
uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies (python) | |
run: | | |
python -m pip install --upgrade pip wheel | |
pip install -r requirements.txt | |
pip install -r requirements-test.txt | |
pip install codecov | |
- name: Run flake8, pylint, mypy | |
if: matrix.python-version == '3.11' | |
run: | | |
flake8 cmdstanpy test | |
pylint -v cmdstanpy test | |
mypy cmdstanpy | |
- name: Build wheel | |
run: python setup.py bdist_wheel | |
- name: Install wheel (Linux, macOS) | |
if: matrix.os != 'windows-latest' | |
run: pip install dist/*.whl | |
- name: Install wheel (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
$whl = Get-ChildItem -Path dist -Filter *.whl | Select-Object -First 1 | |
pip install "$whl" | |
- name: Show libraries | |
run: python -m pip freeze | |
- name: CmdStan installation cacheing | |
if: ${{ !startswith(needs.get-cmdstan-version.outputs.version, 'git:') }} | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cmdstan | |
key: ${{ runner.os }}-cmdstan-${{ needs.get-cmdstan-version.outputs.version }}-${{ hashFiles('**/install_cmdstan.py') }} | |
- 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=2)" | |
- name: Install CmdStan (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
install_cmdstan -h | |
install_cxx_toolchain -h | |
python -m cmdstanpy.install_cmdstan --compiler --version ${{ needs.get-cmdstan-version.outputs.version }} --cores 2 | |
- name: Run tests | |
run: | | |
mkdir run_tests | |
cd run_tests | |
pytest -v ../test --cov=../cmdstanpy | |
- name: Run model with requirements-optional.txt | |
run: | | |
cd run_tests | |
python -m pip install -r ../requirements-optional.txt | |
python ../test/example_script.py | |
- name: Submit codecov | |
run: | | |
cd run_tests | |
codecov |