-
-
Notifications
You must be signed in to change notification settings - Fork 69
130 lines (112 loc) · 4.01 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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 (python)
run: |
python -m pip install --upgrade pip wheel build
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 -m build
- 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
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: 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