diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 6664d79f..aeedc01d 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.' + required: false + default: '' jobs: R-CMD-check: @@ -36,6 +42,7 @@ jobs: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} NOT_CRAN: true CMDSTANR_OPENCL_TESTS: ${{ matrix.config.opencl }} + CMDSTAN_TEST_TARBALL_URL: ${{ github.event.inputs.tarball_url }} PKG_SYSREQS_DB_UPDATE_TIMEOUT: 30s steps: @@ -86,7 +93,16 @@ 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)) { + cmdstanr::install_cmdstan( + cores = 2, + overwrite = TRUE, + release_url = tarball_url + ) + } else { + cmdstanr::install_cmdstan(cores = 2) + } shell: Rscript {0} - name: Session info diff --git a/.github/workflows/cmdstan-tarball-check.yaml b/.github/workflows/cmdstan-tarball-check.yaml deleted file mode 100644 index 056e37f6..00000000 --- a/.github/workflows/cmdstan-tarball-check.yaml +++ /dev/null @@ -1,101 +0,0 @@ ---- -# Github Actions workflow to check CmdStanR tarball -# yamllint disable rule:line-length - -name: Custom CmdStan tarball unit tests - -'on': - workflow_dispatch: - inputs: - tarball_url: - description: 'CmdStan tarball URL to test with.' - required: true - default: 'latest' - -jobs: - tarball-check: - runs-on: ${{ matrix.config.os }} - - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - - strategy: - 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: ''} - env: - R_REMOTES_NO_ERRORS_FROM_WARNINGS: true - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - CMDSTAN_TEST_TARBALL_URL: ${{ github.event.inputs.tarball_url }} - NOT_CRAN: true - - steps: - - uses: actions/checkout@v6 - - name: Install system dependencies - if: runner.os == 'Linux' - 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 - - - uses: r-lib/actions/setup-r@v2.11.3 - with: - r-version: ${{ matrix.config.r }} - rtools-version: ${{ matrix.config.rtools }} - - - uses: r-lib/actions/setup-pandoc@v2.11.3 - - - 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} - - - name: Cache R packages - if: runner.os != 'Windows' - uses: actions/cache@v5 - 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- - - - name: Install dependencies - 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) - } else { - cmdstanr::install_cmdstan(cores = 2, overwrite = TRUE, release_url = "${{ github.event.inputs.tarball_url }}") - } - shell: Rscript {0} - - - name: Session info - run: | - options(width = 100) - pkgs <- installed.packages()[, "Package"] - sessioninfo::session_info(pkgs, include_base = TRUE) - shell: Rscript {0} - - - name: Check - 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() - run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash - - - name: Upload check results - if: failure() - uses: actions/upload-artifact@v6 - with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check diff --git a/tests/testthat/test-install.R b/tests/testthat/test-install.R index a9c06482..ad7ad069 100644 --- a/tests/testthat/test-install.R +++ b/tests/testthat/test-install.R @@ -1,5 +1,8 @@ context("install") +# avoid parallel on Mac due to strange intermittent TBB errors on Github Actions +CORES <- if (os_is_macos()) 1 else 2 + cmdstan_test_tarball_url <- Sys.getenv("CMDSTAN_TEST_TARBALL_URL") if (!nzchar(cmdstan_test_tarball_url)) { cmdstan_test_tarball_url <- NULL @@ -13,7 +16,7 @@ test_that("install_cmdstan() successfully installs cmdstan", { } expect_message( expect_output( - install_cmdstan(dir = dir, cores = 2, quiet = FALSE, overwrite = TRUE, + install_cmdstan(dir = dir, cores = CORES, quiet = FALSE, overwrite = TRUE, release_url = cmdstan_test_tarball_url, wsl = os_is_wsl()), "Compiling C++ code", @@ -52,7 +55,7 @@ test_that("install_cmdstan() errors if it times out", { expect_warning( expect_message( install_cmdstan(dir = dir, timeout = 1, quiet = TRUE, overwrite = dir_exists, - release_url = cmdstan_test_tarball_url, wsl = os_is_wsl()), + cores = CORES, wsl = os_is_wsl()), if (dir_exists) "* Removing the existing installation" else "* * Installing CmdStan from https://github.com", fixed = TRUE ), @@ -64,8 +67,7 @@ test_that("install_cmdstan() errors if it times out", { expect_warning( expect_message( install_cmdstan(dir = dir, timeout = 1, quiet = FALSE, overwrite = dir_exists, - release_url = cmdstan_test_tarball_url, - wsl = os_is_wsl()), + cores = CORES, wsl = os_is_wsl()), if (dir_exists) "* Removing the existing installation" else "* * Installing CmdStan from https://github.com", fixed = TRUE ), @@ -91,6 +93,9 @@ test_that("install_cmdstan() errors if invalid version or URL", { }) test_that("install_cmdstan() works with version and release_url", { + # this test is irrelevant if tests are using a release candidate tarball URL so skip + skip_if(!is.null(cmdstan_test_tarball_url)) + if (getRversion() < '3.5.0') { dir <- tempdir() } else { @@ -99,8 +104,8 @@ test_that("install_cmdstan() works with version and release_url", { expect_message( expect_output( - install_cmdstan(dir = dir, overwrite = TRUE, cores = 4, - release_url = "https://github.com/stan-dev/cmdstan/releases/download/v2.35.0/cmdstan-2.35.0.tar.gz", + install_cmdstan(dir = dir, overwrite = TRUE, cores = CORES, + release_url = "https://github.com/stan-dev/cmdstan/releases/download/v2.36.0/cmdstan-2.36.0.tar.gz", wsl = os_is_wsl()), "Compiling C++ code", fixed = TRUE @@ -111,8 +116,8 @@ test_that("install_cmdstan() works with version and release_url", { expect_warning( expect_message( expect_output( - install_cmdstan(dir = dir, overwrite = TRUE, cores = 4, - version = "2.35.0", + install_cmdstan(dir = dir, overwrite = TRUE, cores = CORES, + version = "2.36.0", # the URL is intentionally invalid to test that the version has higher priority release_url = "https://github.com/stan-dev/cmdstan/releases/download/v2.27.3/cmdstan-2.27.3.tar.gz", wsl = os_is_wsl()), @@ -125,7 +130,7 @@ test_that("install_cmdstan() works with version and release_url", { "version and release_url shouldn't both be specified", fixed = TRUE ) - expect_true(dir.exists(file.path(dir, "cmdstan-2.35.0"))) + expect_true(dir.exists(file.path(dir, "cmdstan-2.36.0"))) set_cmdstan_path(cmdstan_default_path()) }) @@ -187,7 +192,7 @@ test_that("toolchain checks on Windows with RTools 3.5 work", { test_that("clean and rebuild works", { expect_output( - rebuild_cmdstan(), + rebuild_cmdstan(cores = CORES), paste0("CmdStan v", cmdstan_version(), " built"), fixed = TRUE ) @@ -215,11 +220,11 @@ test_that("Downloads respect quiet argument", { # expect_message has trouble capturing the messages from download.file # so handle manually install_normal <- suppressWarnings( - capture.output(install_cmdstan(dir = dir, overwrite = TRUE, quiet = FALSE), + capture.output(install_cmdstan(dir = dir, overwrite = TRUE, quiet = FALSE, cores = CORES), type = "message") ) install_quiet <- suppressWarnings( - capture.output(install_cmdstan(dir = dir, overwrite = TRUE, quiet = TRUE), + capture.output(install_cmdstan(dir = dir, overwrite = TRUE, quiet = TRUE, cores = CORES), type = "message") ) @@ -256,15 +261,15 @@ test_that("Install from release file works", { dir <- tempdir(check = TRUE) } - destfile = file.path(dir, "cmdstan-2.35.0.tar.gz") + destfile <- file.path(dir, "cmdstan-2.36.0.tar.gz") download_with_retries( - "https://github.com/stan-dev/cmdstan/releases/download/v2.35.0/cmdstan-2.35.0.tar.gz", + "https://github.com/stan-dev/cmdstan/releases/download/v2.36.0/cmdstan-2.36.0.tar.gz", destfile) expect_message( expect_output( - install_cmdstan(dir = dir, cores = 2, quiet = FALSE, overwrite = TRUE, + install_cmdstan(dir = dir, cores = CORES, quiet = FALSE, overwrite = TRUE, release_file = destfile, wsl = os_is_wsl()), "Compiling C++ code",