Skip to content

Commit

Permalink
Merge branch 'develop' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
GuidoMaggio authored Sep 22, 2023
2 parents cac5311 + c1d68ff commit fbb6ad8
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 31 deletions.
2 changes: 0 additions & 2 deletions .Rprofile
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# renv::settings$ignored.packages(c("devtools", "Covid19Mirai"), persist = FALSE)
source("renv/activate.R")

4 changes: 4 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ jobs:
- name: Activate renv and restore packages with cache
uses: r-lib/actions/setup-renv@v2

# - name: Install renv Development tools
# run: renv::install()
# shell: Rscript {0}

- name: Fetch and rebuild latest data
if: github.event_name == 'schedule'
run: |
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Imports:
scales,
COVID19,
grDevices,
pkgload,
rlang,
zoo
Encoding: UTF-8
Expand All @@ -47,6 +46,7 @@ RoxygenNote: 7.2.3
Suggests:
rsconnect,
spelling,
pkgload,
testthat (>= 3.0.0),
sf,
packrat
5 changes: 2 additions & 3 deletions deploy/deploy-shinyapps.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ rsconnect::setAccountInfo(
)

# to be added since rsconnect >1
options(rsconnect.packrat = FALSE)
options(rsconnect.packrat = TRUE)

rsconnect::deployApp(
account = "miraisolutions",
appName = "covid19",
forceUpdate = TRUE, # to be added since rsconnect >1
quarto = FALSE # to be added since rsconnect >1
forceUpdate = TRUE # to be added since rsconnect >1
# exclude hidden files and renv directory (if present)
# appFiles = setdiff(list.files(), "renv")
)
70 changes: 45 additions & 25 deletions renv/activate.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,27 @@
local({

# the requested version of renv
version <- "1.0.0"
version <- "1.0.2"
attr(version, "sha") <- NULL

# the project directory
project <- getwd()

# use start-up diagnostics if enabled
diagnostics <- Sys.getenv("RENV_STARTUP_DIAGNOSTICS", unset = "FALSE")
if (diagnostics) {
start <- Sys.time()
profile <- tempfile("renv-startup-", fileext = ".Rprof")
utils::Rprof(profile)
on.exit({
utils::Rprof(NULL)
elapsed <- signif(difftime(Sys.time(), start, units = "auto"), digits = 2L)
writeLines(sprintf("- renv took %s to run the autoloader.", format(elapsed)))
writeLines(sprintf("- Profile: %s", profile))
print(utils::summaryRprof(profile))
}, add = TRUE)
}

# figure out whether the autoloader is enabled
enabled <- local({

Expand Down Expand Up @@ -504,7 +519,7 @@ local({

# open the bundle for reading
# We use gzcon for everything because (from ?gzcon)
# > Reading from a connection which does not supply a gzip magic
# > Reading from a connection which does not supply a 'gzip' magic
# > header is equivalent to reading from the original connection
conn <- gzcon(file(bundle, open = "rb", raw = TRUE))
on.exit(close(conn))
Expand Down Expand Up @@ -767,10 +782,12 @@ local({
renv_bootstrap_validate_version <- function(version, description = NULL) {

# resolve description file
description <- description %||% {
path <- getNamespaceInfo("renv", "path")
packageDescription("renv", lib.loc = dirname(path))
}
#
# avoid passing lib.loc to `packageDescription()` below, since R will
# use the loaded version of the package by default anyhow. note that
# this function should only be called after 'renv' is loaded
# https://github.com/rstudio/renv/issues/1625
description <- description %||% packageDescription("renv")

# check whether requested version 'version' matches loaded version of renv
sha <- attr(version, "sha", exact = TRUE)
Expand Down Expand Up @@ -841,7 +858,7 @@ local({
hooks <- getHook("renv::autoload")
for (hook in hooks)
if (is.function(hook))
tryCatch(hook(), error = warning)
tryCatch(hook(), error = warnify)

# load the project
renv::load(project)
Expand Down Expand Up @@ -982,10 +999,15 @@ local({

}

renv_bootstrap_version_friendly <- function(version, sha = NULL) {
renv_bootstrap_version_friendly <- function(version, shafmt = NULL, sha = NULL) {
sha <- sha %||% attr(version, "sha", exact = TRUE)
parts <- c(version, sprintf("[sha: %s]", substring(sha, 1L, 7L)))
paste(parts, collapse = " ")
parts <- c(version, sprintf(shafmt %||% " [sha: %s]", substring(sha, 1L, 7L)))
paste(parts, collapse = "")
}

renv_bootstrap_exec <- function(project, libpath, version) {
if (!renv_bootstrap_load(project, libpath, version))
renv_bootstrap_run(version, libpath)
}

renv_bootstrap_run <- function(version, libpath) {
Expand Down Expand Up @@ -1017,6 +1039,14 @@ local({
commandArgs()[[1]] == "RStudio"
}

# Used to work around buglet in RStudio if hook uses readline
renv_bootstrap_flush_console <- function() {
tryCatch({
tools <- as.environment("tools:rstudio")
tools$.rs.api.sendToConsole("", echo = FALSE, focus = FALSE)
}, error = function(cnd) {})
}

renv_json_read <- function(file = NULL, text = NULL) {

jlerr <- NULL
Expand Down Expand Up @@ -1155,25 +1185,15 @@ local({
# construct full libpath
libpath <- file.path(root, prefix)

# attempt to load
if (renv_bootstrap_load(project, libpath, version))
return(TRUE)

if (renv_bootstrap_in_rstudio()) {
# RStudio only updates console once .Rprofile is finished, so
# instead run code on sessionInit
setHook("rstudio.sessionInit", function(...) {
renv_bootstrap_run(version, libpath)

# Work around buglet in RStudio if hook uses readline
tryCatch(
{
tools <- as.environment("tools:rstudio")
tools$.rs.api.sendToConsole("", echo = FALSE, focus = FALSE)
},
error = function(cnd) {}
)
renv_bootstrap_exec(project, libpath, version)
renv_bootstrap_flush_console()
})
} else {
renv_bootstrap_run(version, libpath)
renv_bootstrap_exec(project, libpath, version)
}

invisible()
Expand Down

0 comments on commit fbb6ad8

Please sign in to comment.