Skip to content

Commit 34ccd06

Browse files
authored
Merge pull request #1132 from stan-dev/custom-tarball-url-in-r-cmd-check
Enable optional custom tarball URL in unit tests (and remove separate custom tarball yaml file)
2 parents fc0d2cf + 236a8da commit 34ccd06

3 files changed

Lines changed: 37 additions & 117 deletions

File tree

.github/workflows/R-CMD-check.yaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ name: Unit tests
1111
pull_request:
1212
branches:
1313
- master
14+
workflow_dispatch:
15+
inputs:
16+
tarball_url:
17+
description: 'CmdStan tarball URL to test with.'
18+
required: false
19+
default: ''
1420

1521
jobs:
1622
R-CMD-check:
@@ -36,6 +42,7 @@ jobs:
3642
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
3743
NOT_CRAN: true
3844
CMDSTANR_OPENCL_TESTS: ${{ matrix.config.opencl }}
45+
CMDSTAN_TEST_TARBALL_URL: ${{ github.event.inputs.tarball_url }}
3946
PKG_SYSREQS_DB_UPDATE_TIMEOUT: 30s
4047

4148
steps:
@@ -86,7 +93,16 @@ jobs:
8693
- name: Install cmdstan
8794
run: |
8895
cmdstanr::check_cmdstan_toolchain(fix = TRUE)
89-
cmdstanr::install_cmdstan(cores = 2)
96+
tarball_url <- Sys.getenv("CMDSTAN_TEST_TARBALL_URL")
97+
if (nzchar(tarball_url)) {
98+
cmdstanr::install_cmdstan(
99+
cores = 2,
100+
overwrite = TRUE,
101+
release_url = tarball_url
102+
)
103+
} else {
104+
cmdstanr::install_cmdstan(cores = 2)
105+
}
90106
shell: Rscript {0}
91107

92108
- name: Session info

.github/workflows/cmdstan-tarball-check.yaml

Lines changed: 0 additions & 101 deletions
This file was deleted.

tests/testthat/test-install.R

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
context("install")
22

3+
# avoid parallel on Mac due to strange intermittent TBB errors on Github Actions
4+
CORES <- if (os_is_macos()) 1 else 2
5+
36
cmdstan_test_tarball_url <- Sys.getenv("CMDSTAN_TEST_TARBALL_URL")
47
if (!nzchar(cmdstan_test_tarball_url)) {
58
cmdstan_test_tarball_url <- NULL
@@ -13,7 +16,7 @@ test_that("install_cmdstan() successfully installs cmdstan", {
1316
}
1417
expect_message(
1518
expect_output(
16-
install_cmdstan(dir = dir, cores = 2, quiet = FALSE, overwrite = TRUE,
19+
install_cmdstan(dir = dir, cores = CORES, quiet = FALSE, overwrite = TRUE,
1720
release_url = cmdstan_test_tarball_url,
1821
wsl = os_is_wsl()),
1922
"Compiling C++ code",
@@ -52,7 +55,7 @@ test_that("install_cmdstan() errors if it times out", {
5255
expect_warning(
5356
expect_message(
5457
install_cmdstan(dir = dir, timeout = 1, quiet = TRUE, overwrite = dir_exists,
55-
release_url = cmdstan_test_tarball_url, wsl = os_is_wsl()),
58+
cores = CORES, wsl = os_is_wsl()),
5659
if (dir_exists) "* Removing the existing installation" else "* * Installing CmdStan from https://github.com",
5760
fixed = TRUE
5861
),
@@ -64,8 +67,7 @@ test_that("install_cmdstan() errors if it times out", {
6467
expect_warning(
6568
expect_message(
6669
install_cmdstan(dir = dir, timeout = 1, quiet = FALSE, overwrite = dir_exists,
67-
release_url = cmdstan_test_tarball_url,
68-
wsl = os_is_wsl()),
70+
cores = CORES, wsl = os_is_wsl()),
6971
if (dir_exists) "* Removing the existing installation" else "* * Installing CmdStan from https://github.com",
7072
fixed = TRUE
7173
),
@@ -91,6 +93,9 @@ test_that("install_cmdstan() errors if invalid version or URL", {
9193
})
9294

9395
test_that("install_cmdstan() works with version and release_url", {
96+
# this test is irrelevant if tests are using a release candidate tarball URL so skip
97+
skip_if(!is.null(cmdstan_test_tarball_url))
98+
9499
if (getRversion() < '3.5.0') {
95100
dir <- tempdir()
96101
} else {
@@ -99,8 +104,8 @@ test_that("install_cmdstan() works with version and release_url", {
99104

100105
expect_message(
101106
expect_output(
102-
install_cmdstan(dir = dir, overwrite = TRUE, cores = 4,
103-
release_url = "https://github.com/stan-dev/cmdstan/releases/download/v2.35.0/cmdstan-2.35.0.tar.gz",
107+
install_cmdstan(dir = dir, overwrite = TRUE, cores = CORES,
108+
release_url = "https://github.com/stan-dev/cmdstan/releases/download/v2.36.0/cmdstan-2.36.0.tar.gz",
104109
wsl = os_is_wsl()),
105110
"Compiling C++ code",
106111
fixed = TRUE
@@ -111,8 +116,8 @@ test_that("install_cmdstan() works with version and release_url", {
111116
expect_warning(
112117
expect_message(
113118
expect_output(
114-
install_cmdstan(dir = dir, overwrite = TRUE, cores = 4,
115-
version = "2.35.0",
119+
install_cmdstan(dir = dir, overwrite = TRUE, cores = CORES,
120+
version = "2.36.0",
116121
# the URL is intentionally invalid to test that the version has higher priority
117122
release_url = "https://github.com/stan-dev/cmdstan/releases/download/v2.27.3/cmdstan-2.27.3.tar.gz",
118123
wsl = os_is_wsl()),
@@ -125,7 +130,7 @@ test_that("install_cmdstan() works with version and release_url", {
125130
"version and release_url shouldn't both be specified",
126131
fixed = TRUE
127132
)
128-
expect_true(dir.exists(file.path(dir, "cmdstan-2.35.0")))
133+
expect_true(dir.exists(file.path(dir, "cmdstan-2.36.0")))
129134
set_cmdstan_path(cmdstan_default_path())
130135
})
131136

@@ -187,7 +192,7 @@ test_that("toolchain checks on Windows with RTools 3.5 work", {
187192

188193
test_that("clean and rebuild works", {
189194
expect_output(
190-
rebuild_cmdstan(),
195+
rebuild_cmdstan(cores = CORES),
191196
paste0("CmdStan v", cmdstan_version(), " built"),
192197
fixed = TRUE
193198
)
@@ -215,11 +220,11 @@ test_that("Downloads respect quiet argument", {
215220
# expect_message has trouble capturing the messages from download.file
216221
# so handle manually
217222
install_normal <- suppressWarnings(
218-
capture.output(install_cmdstan(dir = dir, overwrite = TRUE, quiet = FALSE),
223+
capture.output(install_cmdstan(dir = dir, overwrite = TRUE, quiet = FALSE, cores = CORES),
219224
type = "message")
220225
)
221226
install_quiet <- suppressWarnings(
222-
capture.output(install_cmdstan(dir = dir, overwrite = TRUE, quiet = TRUE),
227+
capture.output(install_cmdstan(dir = dir, overwrite = TRUE, quiet = TRUE, cores = CORES),
223228
type = "message")
224229
)
225230

@@ -256,15 +261,15 @@ test_that("Install from release file works", {
256261
dir <- tempdir(check = TRUE)
257262
}
258263

259-
destfile = file.path(dir, "cmdstan-2.35.0.tar.gz")
264+
destfile <- file.path(dir, "cmdstan-2.36.0.tar.gz")
260265

261266
download_with_retries(
262-
"https://github.com/stan-dev/cmdstan/releases/download/v2.35.0/cmdstan-2.35.0.tar.gz",
267+
"https://github.com/stan-dev/cmdstan/releases/download/v2.36.0/cmdstan-2.36.0.tar.gz",
263268
destfile)
264269

265270
expect_message(
266271
expect_output(
267-
install_cmdstan(dir = dir, cores = 2, quiet = FALSE, overwrite = TRUE,
272+
install_cmdstan(dir = dir, cores = CORES, quiet = FALSE, overwrite = TRUE,
268273
release_file = destfile,
269274
wsl = os_is_wsl()),
270275
"Compiling C++ code",

0 commit comments

Comments
 (0)