diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 6664d79f..5037ed1b 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -11,6 +11,12 @@ name: Unit tests pull_request: branches: - master + workflow_dispatch: + inputs: + tarball_url: + description: 'CmdStan tarball URL to test with (optional, uses latest if not provided)' + required: false + default: '' jobs: R-CMD-check: @@ -37,6 +43,7 @@ jobs: NOT_CRAN: true CMDSTANR_OPENCL_TESTS: ${{ matrix.config.opencl }} PKG_SYSREQS_DB_UPDATE_TIMEOUT: 30s + CMDSTAN_TEST_TARBALL_URL: ${{ github.event.inputs.tarball_url }} steps: - name: cmdstan env vars @@ -86,7 +93,12 @@ jobs: - name: Install cmdstan run: | cmdstanr::check_cmdstan_toolchain(fix = TRUE) - cmdstanr::install_cmdstan(cores = 2) + tarball_url <- Sys.getenv("CMDSTAN_TEST_TARBALL_URL") + if (nzchar(tarball_url) && tarball_url != "latest") { + cmdstanr::install_cmdstan(cores = 2, release_url = tarball_url) + } else { + cmdstanr::install_cmdstan(cores = 2) + } shell: Rscript {0} - name: Session info diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 00000000..ef4b793f --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,24 @@ +# GitHub Actions Workflows + +This directory contains GitHub Actions workflows for testing and maintaining cmdstanr. + +## Testing with Custom CmdStan Tarballs + +To test cmdstanr with a custom CmdStan tarball (e.g., during CmdStan releases): + +1. Go to the [Actions tab](https://github.com/stan-dev/cmdstanr/actions) +2. Select the "Unit tests" workflow +3. Click "Run workflow" +4. Enter the CmdStan tarball URL in the `tarball_url` input field (or leave empty/enter "latest" for the latest release) +5. Click "Run workflow" + +Example tarball URL: +``` +https://github.com/stan-dev/cmdstan/releases/download/v2.35.0/cmdstan-2.35.0.tar.gz +``` + +If you leave the `tarball_url` field empty or enter "latest", the workflow will use the latest CmdStan release. + +### Legacy Workflow + +The `cmdstan-tarball-check.yaml` workflow is maintained for backwards compatibility but is deprecated. Please use the main `R-CMD-check.yaml` workflow instead as described above. diff --git a/.github/workflows/cmdstan-tarball-check.yaml b/.github/workflows/cmdstan-tarball-check.yaml index 056e37f6..50195528 100644 --- a/.github/workflows/cmdstan-tarball-check.yaml +++ b/.github/workflows/cmdstan-tarball-check.yaml @@ -1,6 +1,10 @@ --- # Github Actions workflow to check CmdStanR tarball # yamllint disable rule:line-length +# +# DEPRECATED: This workflow is maintained for backwards compatibility. +# Please use the main R-CMD-check.yaml workflow instead, which now accepts +# an optional tarball_url input via workflow_dispatch. name: Custom CmdStan tarball unit tests @@ -9,8 +13,8 @@ name: Custom CmdStan tarball unit tests inputs: tarball_url: description: 'CmdStan tarball URL to test with.' - required: true - default: 'latest' + required: false + default: '' jobs: tarball-check: @@ -22,9 +26,9 @@ jobs: fail-fast: false matrix: config: - - {os: macOS-latest, r: 'release', rtools: ''} - - {os: windows-latest, r: 'release', rtools: '44'} - - {os: ubuntu-20.04, r: 'release', rtools: ''} + - {os: macOS-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'release'} env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} @@ -32,46 +36,38 @@ jobs: NOT_CRAN: true steps: - - uses: actions/checkout@v6 - - name: Install system dependencies - if: runner.os == 'Linux' + - name: cmdstan env vars run: | - sudo apt-get update - sudo apt-get install -y libcurl4-openssl-dev || true - sudo apt-get install -y openmpi-bin openmpi-common libopenmpi-dev || true + echo "CMDSTAN_PATH=${HOME}/.cmdstan" >> $GITHUB_ENV + shell: bash + + - uses: actions/checkout@v6 - - uses: r-lib/actions/setup-r@v2.11.3 + - uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} - rtools-version: ${{ matrix.config.rtools }} - - uses: r-lib/actions/setup-pandoc@v2.11.3 + - name: Install R Package Build Dependencies on MacOS + if: ${{ runner.os == 'macOS' }} + uses: r-hub/actions/setup-r-sysreqs@v1 + with: + type: 'minimal' - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} + - uses: r-lib/actions/setup-pandoc@v2 - - name: Cache R packages - if: runner.os != 'Windows' - uses: actions/cache@v5 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + cache: "always" + extra-packages: any::rcmdcheck, local::. - - name: Install dependencies + - name: Install cmdstan run: | - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("rcmdcheck") - remotes::install_local(path = ".", INSTALL_opts = "--no-test-load") cmdstanr::check_cmdstan_toolchain(fix = TRUE) - if (Sys.getenv("CMDSTAN_TEST_TARBALL_URL") == "latest") { - cmdstanr::install_cmdstan(cores = 2, overwrite = TRUE) + tarball_url <- Sys.getenv("CMDSTAN_TEST_TARBALL_URL") + if (nzchar(tarball_url) && tarball_url != "latest") { + cmdstanr::install_cmdstan(cores = 2, release_url = tarball_url) } else { - cmdstanr::install_cmdstan(cores = 2, overwrite = TRUE, release_url = "${{ github.event.inputs.tarball_url }}") + cmdstanr::install_cmdstan(cores = 2) } shell: Rscript {0} @@ -82,11 +78,9 @@ jobs: sessioninfo::session_info(pkgs, include_base = TRUE) shell: Rscript {0} - - name: Check + - uses: r-lib/actions/check-r-package@v2 env: _R_CHECK_CRAN_INCOMING_: false - run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran", "--ignore-vignettes"), build_args = c("--no-build-vignettes"), error_on = "warning", check_dir = "check") - shell: Rscript {0} - name: Show testthat output if: always()