diff --git a/DESCRIPTION b/DESCRIPTION index 439c2056a..73acdeacf 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: orderly Title: Lightweight Reproducible Reporting -Version: 1.2.23 +Version: 1.2.24 Description: Order, create and store reports from R. By defining a lightweight interface around the inputs and outputs of an analysis, a lot of the repetitive work for reproducible research @@ -31,6 +31,7 @@ Imports: digest, docopt, fs (>= 1.2.7), + gert, ids, withr, yaml, diff --git a/NEWS.md b/NEWS.md index ac8f39bf3..7d73b054e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# orderly 1.2.24 + +* `orderly_run_remote` checks that ref exists before running (VIMC-4574) + # orderly 1.2.23 * `orderly_run` with non-boolean `use_draft` and fixed ID dependency works (#259) diff --git a/R/remote.R b/R/remote.R index 944724bd2..a512405b6 100644 --- a/R/remote.R +++ b/R/remote.R @@ -247,7 +247,11 @@ orderly_run_remote <- function(name, parameters = NULL, ref = NULL, progress = TRUE, root = NULL, locate = TRUE, instance = NULL, remote = NULL) { - remote <- get_remote(remote, orderly_config(root, locate)) + cfg <- orderly_config(root, locate) + if (!is.null(ref)) { + ref <- gert::git_commit_id(ref, cfg$root) + } + remote <- get_remote(remote, cfg) invisible(remote$run( name, parameters = parameters, ref = ref, timeout = timeout, wait = wait, poll = poll, diff --git a/docker/Dockerfile b/docker/Dockerfile index a0982b7a4..b7ece047e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -22,6 +22,7 @@ RUN install2.r \ digest \ docopt \ fs \ + gert \ ids \ jsonlite \ knitr \ diff --git a/tests/testthat/test-remote.R b/tests/testthat/test-remote.R index a51385c83..6be984219 100644 --- a/tests/testthat/test-remote.R +++ b/tests/testthat/test-remote.R @@ -321,3 +321,37 @@ test_that("orderly_bundle_(pack|import)_remote do not use root/locate", { expect_equal(remote$list_versions("example"), ans$id) }) + + +test_that("orderly run remote passes ref to run", { + path <- prepare_orderly_git_example() + + ## Create a minimal remote class which will satisfy implements_remote + mock_remote <- R6::R6Class( + "orderly_mock_remote", + lock_objects = FALSE, + public = list( + list_reports = function() TRUE, + list_versions = function() TRUE, + pull = function() TRUE, + url_report = function() TRUE + ) + ) + + ## Bit of awkwardness with adding run function here. We want to mock out new + ## function but can't do that inside the class. + remote <- mock_remote$new() + remote$run <- mockery::mock(TRUE, cycle = TRUE) + orderly_run_remote("minimal", remote = remote, root = path[["local"]]) + + mockery::expect_called(remote$run, 1) + args <- mockery::mock_args(remote$run)[[1]] + expect_null(args$ref) + + orderly_run_remote("minimal", remote = remote, root = path[["local"]], + ref = "master") + + mockery::expect_called(remote$run, 2) + args <- mockery::mock_args(remote$run)[[2]] + expect_match(args$ref, "[0-9a-f]{40}") +})