Skip to content

Add estimate_dist() with primarycensored support #407

Add estimate_dist() with primarycensored support

Add estimate_dist() with primarycensored support #407

name: stan model benchmark
on:
workflow_dispatch:
pull_request:
branches: main
paths:
- inst/stan/**
- .github/workflows/stan-model-benchmark.yaml
- inst/dev/benchmark*.R
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}
cancel-in-progress: true
jobs:
stan-model-benchmark:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout PR branch
uses: actions/checkout@v6
with:
path: branch
- name: Checkout main branch
uses: actions/checkout@v6
with:
ref: main
path: main
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
extra-repositories: https://production.r-multiverse.org/2025-12-15
- name: Install cmdstan
uses: epinowcast/actions/install-cmdstan@v1
with:
cmdstan-version: 'latest'
num-cores: 2
# Install dependencies for both versions into separate libraries
- name: Install main branch dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
working-directory: main
packages: |
local::.
here
purrr
any::cmdstanr
- name: Benchmark main branch
id: benchmark-main
continue-on-error: true
working-directory: main
run: |
# Use benchmark-single.R from PR branch (main may not have it yet)
Rscript ../branch/inst/dev/benchmark-single.R main
- name: Install PR branch dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
working-directory: branch
packages: |
local::.
any::cmdstanr
- name: Benchmark PR branch
working-directory: branch
run: |
Rscript inst/dev/benchmark-single.R branch
# Compare results
- name: Compare benchmarks
id: compare
if: steps.benchmark-main.outcome == 'success'
working-directory: branch
run: |
Rscript inst/dev/benchmark-compare.R \
../main/main-profiles.csv \
branch-profiles.csv \
benchmark-results.md
- name: Note if main benchmark failed
if: steps.benchmark-main.outcome == 'failure'
working-directory: branch
run: |
echo "Main branch benchmark failed (likely due to interface changes)." > benchmark-results.md
echo "PR branch benchmark completed successfully." >> benchmark-results.md
echo "" >> benchmark-results.md
echo "Comparison not available - only PR branch results collected." >> benchmark-results.md
- id: output
name: Output to environment variable
if: ${{ hashFiles('branch/benchmark-results.md') != '' }}
run: |
echo 'BENCHMARK<<EOF' >> $GITHUB_OUTPUT
cat branch/benchmark-results.md >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Post comment
if: ${{ hashFiles('branch/benchmark-results.md') != '' }}
uses: actions/github-script@v8
env:
BENCHMARK: ${{ steps.output.outputs.BENCHMARK }}
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: process.env.BENCHMARK
})