bridgestan tests #690
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: bridgestan tests | |
on: | |
push: | |
branches: | |
- "main" | |
pull_request: | |
workflow_dispatch: {} | |
env: | |
CACHE_VERSION: 0 | |
# only run one copy per PR | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ${{matrix.os}} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [windows-latest, ubuntu-latest, macos-latest] | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Check out github | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Stan build caching | |
uses: actions/cache@v4 | |
id: stan-cache | |
with: | |
path: ./stan/ | |
key: ${{ runner.os }}-stan-${{ hashFiles('stan/src/stan/version.hpp') }}-v${{ env.CACHE_VERSION }} | |
- name: Build C example (Unix) | |
if: matrix.os != 'windows-latest' | |
run: | | |
cd c-example/ | |
make example -j4 | |
make example_static | |
rm ../src/bridgestan.o | |
rm ../test_models/full/full_model.a | |
./example | |
./example_static | |
shell: bash | |
# we use the cache here to build the Stan models once for multiple interfaces | |
- name: Set up test model cache | |
uses: actions/cache@v4 | |
id: test-models | |
with: | |
path: ./test_models/ | |
key: ${{ hashFiles('**/*.stan', 'src/*', 'stan/src/stan/version.hpp', 'Makefile') }}-${{ matrix.os }}-v${{ env.CACHE_VERSION }} | |
- name: Build test models | |
if: steps.test-models.outputs.cache-hit != 'true' | |
run: | | |
make STAN_THREADS=true O=0 test_models -j4 | |
python: | |
needs: [build] | |
runs-on: ${{matrix.os}} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
python-version: ["3.9", "3.12"] | |
fail-fast: false | |
steps: | |
- name: Check out github | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Restore Stan | |
uses: actions/cache@v4 | |
id: stan-cache | |
with: | |
path: ./stan/ | |
key: ${{ runner.os }}-stan-${{ hashFiles('stan/src/stan/version.hpp') }}-v${{ env.CACHE_VERSION }} | |
- name: Restore built models | |
uses: actions/cache@v4 | |
id: test-models | |
with: | |
path: ./test_models/ | |
key: ${{ hashFiles('**/*.stan', 'src/*', 'stan/src/stan/version.hpp', 'Makefile') }}-${{ matrix.os }}-v${{ env.CACHE_VERSION }} | |
- name: Install package | |
run: | | |
cd python/ | |
pip install pytest | |
pip install . | |
- name: Test import | |
run: | | |
python -c "import bridgestan" | |
- name: Run tests | |
run: | | |
pytest -v python/ | |
cd python/ | |
python example.py | |
env: | |
BRIDGESTAN: ${{ github.workspace }} | |
- name: Run tests (Unix-specific) | |
if: matrix.os != 'windows-latest' | |
run: | | |
pytest -v python/ --run-type=ad_hessian | |
env: | |
BRIDGESTAN: ${{ github.workspace }} | |
julia: | |
needs: [build] | |
runs-on: ${{matrix.os}} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
julia-version: ["1"] | |
include: | |
- julia-version: "1.6" | |
os: ubuntu-latest | |
fail-fast: false | |
steps: | |
- name: Check out github | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Set up Julia | |
uses: julia-actions/setup-julia@v2 | |
with: | |
version: ${{ matrix.julia-version }} | |
- name: Restore Stan | |
uses: actions/cache@v4 | |
id: stan-cache | |
with: | |
path: ./stan/ | |
key: ${{ runner.os }}-stan-${{ hashFiles('stan/src/stan/version.hpp') }}-v${{ env.CACHE_VERSION }} | |
- name: Restore built models | |
uses: actions/cache@v4 | |
id: test-models | |
with: | |
path: ./test_models/ | |
key: ${{ hashFiles('**/*.stan', 'src/*', 'stan/src/stan/version.hpp', 'Makefile') }}-${{ matrix.os }}-v${{ env.CACHE_VERSION }} | |
- name: Check import | |
run: | | |
cd julia/ | |
julia --project=. -e "using Pkg; Pkg.instantiate()" | |
julia --project=. -e "using BridgeStan" | |
- name: Run tests | |
run: | | |
cd julia/ | |
julia --project=. -t 2 -e "using Pkg; Pkg.test()" | |
julia --project=. example.jl | |
env: | |
BRIDGESTAN: ${{ github.workspace }} | |
Rlang: | |
needs: [build] | |
runs-on: ${{matrix.os}} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
fail-fast: false | |
steps: | |
- name: Check out github | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install R | |
uses: r-lib/actions/setup-r@v2.10.1 | |
- name: Install R dependencies | |
uses: r-lib/actions/setup-r-dependencies@v2.10.1 | |
with: | |
packages: | | |
any::R6 | |
any::testthat | |
any::devtools | |
- name: Restore Stan | |
uses: actions/cache@v4 | |
with: | |
path: ./stan/ | |
key: ${{ runner.os }}-stan-${{ hashFiles('stan/src/stan/version.hpp') }}-v${{ env.CACHE_VERSION }} | |
- name: Restore built models | |
uses: actions/cache@v4 | |
id: test-models | |
with: | |
path: ./test_models/ | |
key: ${{ hashFiles('**/*.stan', 'src/*', 'stan/src/stan/version.hpp', 'Makefile') }}-${{ matrix.os }}-v${{ env.CACHE_VERSION }} | |
- name: Run tests | |
if: matrix.os != 'windows-latest' | |
run: | | |
cd R/tests/testthat | |
gcc -fpic -shared -o test_collisions.so test_collisions.c | |
cd ../.. | |
Rscript -e "devtools::test(reporter = c(\"summary\", \"fail\"))" | |
Rscript -e "install.packages(getwd(), repos=NULL, type=\"source\")" | |
Rscript example.R | |
env: | |
BRIDGESTAN: ${{ github.workspace }} | |
- name: Run tests (windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
cd R/tests/testthat | |
gcc -fpic -shared -o test_collisions.dll test_collisions.c | |
if (!$LASTEXITCODE.Equals(0)) {exit $LASTEXITCODE} | |
cd ../.. | |
Rscript -e 'devtools::test(reporter = c("summary", "fail"))' | |
if (!$LASTEXITCODE.Equals(0)) {exit $LASTEXITCODE} | |
Rscript -e 'install.packages(getwd(), repos=NULL, type="source")' | |
if (!$LASTEXITCODE.Equals(0)) {exit $LASTEXITCODE} | |
Rscript example.R | |
if (!$LASTEXITCODE.Equals(0)) {exit $LASTEXITCODE} | |
env: | |
BRIDGESTAN: ${{ github.workspace }} | |
rust: | |
needs: [build] | |
runs-on: ${{matrix.os}} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
fail-fast: false | |
steps: | |
- name: Check out github | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Restore Stan | |
uses: actions/cache@v4 | |
with: | |
path: ./stan/ | |
key: ${{ runner.os }}-stan-${{ hashFiles('stan/src/stan/version.hpp') }}-v${{ env.CACHE_VERSION }} | |
- name: Restore built models | |
uses: actions/cache@v4 | |
id: test-models | |
with: | |
path: ./test_models/ | |
key: ${{ hashFiles('**/*.stan', 'src/*', 'stan/src/stan/version.hpp', 'Makefile') }}-${{ matrix.os }}-v${{ env.CACHE_VERSION }} | |
- name: Set up TBB | |
if: matrix.os == 'windows-latest' | |
run: | | |
Add-Content $env:GITHUB_PATH "$(pwd)/stan/lib/stan_math/lib/tbb" | |
- name: Run rust tests | |
working-directory: ./rust | |
timeout-minutes: 60 | |
run: | | |
cargo clippy | |
cargo fmt --check | |
cargo run --example=example | |
# run all tests with feature download-bridgestan-src | |
cargo test --verbose --all-features | |
cargo test --verbose model_compiling -- --ignored |