Skip to content

Commit

Permalink
Propagate renv.lock from pharmaverse/admiralci (#310)
Browse files Browse the repository at this point in the history
* renv / codespaces update from pharmaverse/admiralci

---------

Co-authored-by: galachad <[email protected]>
Co-authored-by: Adam Foryś <[email protected]>
  • Loading branch information
3 people authored Aug 4, 2023
1 parent c8eec9e commit 64c6618
Show file tree
Hide file tree
Showing 20 changed files with 1,043 additions and 245 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
^admiraldev.*\.tgz$
^staged_dependencies.yaml$
^README.Rmd$
^\.devcontainer$
52 changes: 42 additions & 10 deletions .Rprofile
Original file line number Diff line number Diff line change
@@ -1,16 +1,48 @@
# Set renv profile base on R version.
renv_profile <- paste(R.version$major, substr(R.version$minor, 1, 1), sep = ".")
if (file.exists("./renv/profile")) {
message("Using renv profile from `renv/profile` file.")
} else if (renv_profile %in% c("4.1", "4.2", "4.3")) {
message("Set renv profile to `", renv_profile, "`")
Sys.setenv("RENV_PROFILE" = renv_profile)
.get_dependencies <- function(project_dir) {

admdev_loc <- find.package("admiraldev", lib.loc = .libPaths(), quiet = TRUE)
adm_dev_suggests <- if(length(admdev_loc) != 0) {
renv:::renv_dependencies_discover_description(admdev_loc, fields = c("Depends", "Imports", "LinkingTo", "Suggests"))
} else {
data.frame(Packages = character(0))
}
suggests_packages <- renv:::renv_dependencies_discover_description(project_dir, fields = "Suggests")

packages <- names(
renv:::renv_package_dependencies(
unique(c(
project_dir,
adm_dev_suggests[["Package"]],
suggests_packages[["Package"]],
c("staged.dependencies", "renv", "styler")
))
)
)
packages[!(packages %in% c("admiral", "admiraldev", "admiralci", "admiral.test", getwd()))]
}

options(renv.snapshot.filter = .get_dependencies)

.renv_profile <- paste(R.version$major, substr(R.version$minor, 1, 1), sep = ".")
if (!file.exists("./renv/profile")) {
if (.renv_profile %in% c("4.1", "4.2", "4.3")) {
message("Set renv profile to `", .renv_profile, "`")
Sys.setenv("RENV_PROFILE" = .renv_profile)
} else {
message("This repository do not contains the renv profile for your R version.")
}
} else {
message("This repository do not contains the renv profile for your R version.")
message(
"Using renv profile from `renv/profile` file.\n",
"The `", readLines("./renv/profile"), "` profile will be used."
)
}

if ((Sys.getenv("GITHUB_ACTIONS") != "") || (Sys.getenv("DOCKER_CONTAINER_CONTEXT") != "")) {
options(repos = c(CRAN = "https://cran.rstudio.com"))
Sys.setenv(RENV_AUTOLOADER_ENABLED=FALSE)
if (Sys.getenv("GITHUB_ACTIONS") != "") {
options(repos = c(CRAN = "https://packagemanager.posit.co/cran/latest"))
Sys.setenv("RENV_AUTOLOADER_ENABLED" = FALSE)
}
Sys.setenv("RENV_CONFIG_SANDBOX_ENABLED" = FALSE)
Sys.setenv("RENV_CONFIG_AUTO_SNAPSHOT" = FALSE)
source("renv/activate.R")
75 changes: 75 additions & 0 deletions .devcontainer/4.1/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
// https://containers.dev/implementors/json_reference/
"name": "Admiral R-4.1 (RStudio) container",
"image": "ghcr.io/pharmaverse/admiralci-4.1:latest",
// Install Dev Container Features. More info: https://containers.dev/features
"containerEnv": {
"ROOT": "true",
"PASSWORD": "rstudio",
"DISABLE_AUTH": "true"
},
"features": {
"ghcr.io/rocker-org/devcontainer-features/r-rig:1": {
"version": "none",
"vscodeRSupport": "full",
"installRadian": true,
"installVscDebugger": true
},
"ghcr.io/rocker-org/devcontainer-features/renv-cache:latest": {},
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"configureZshAsDefaultShell": false,
"installOhMyZsh": true,
"username": "rstudio",
"upgradePackages": false
},
"ghcr.io/mikaello/devcontainer-features/modern-shell-utils:1": {}
},
"init": true,
"overrideCommand": false,

"postCreateCommand": "bash ./.devcontainer/postCreateCommand.sh",

"postAttachCommand": "$BROWSER \"https://${CODESPACE_NAME}-8787.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}/\"",

"customizations": {
"vscode": {
"settings": {
"r.rterm.linux": "/usr/local/bin/radian",
"r.bracketedPaste": true,
"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": "active"
},
"extensions": [
"vsls-contrib.codetour",
"GitHub.copilot",
"GitHub.copilot-chat",
// R extensions
"ikuyadeu.r",
"REditorSupport.r-lsp",
// Extra extension
"streetsidesoftware.code-spell-checker",
"eamodio.gitlens",
"cweijan.vscode-office",
"donjayamanne.githistory",
"GitHub.vscode-github-actions",
"GitHub.vscode-pull-request-github",
"GitHub.remotehub",
"alefragnani.Bookmarks",
"vscode-icons-team.vscode-icons"
]
}
},

// RStudio ports
"forwardPorts": [8787],
"portsAttributes": {
"8787": {
"label": "Rstudio",
"requireLocalPort": true,
"onAutoForward": "openBrowser"
}
},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root
"remoteUser": "rstudio"
}
75 changes: 75 additions & 0 deletions .devcontainer/4.2/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
// https://containers.dev/implementors/json_reference/
"name": "Admiral R-4.2 (RStudio) container",
"image": "ghcr.io/pharmaverse/admiralci-4.2:latest",
// Install Dev Container Features. More info: https://containers.dev/features
"containerEnv": {
"ROOT": "true",
"PASSWORD": "rstudio",
"DISABLE_AUTH": "true"
},
"features": {
"ghcr.io/rocker-org/devcontainer-features/r-rig:1": {
"version": "none",
"vscodeRSupport": "full",
"installRadian": true,
"installVscDebugger": true
},
"ghcr.io/rocker-org/devcontainer-features/renv-cache:latest": {},
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"configureZshAsDefaultShell": false,
"installOhMyZsh": true,
"username": "rstudio",
"upgradePackages": false
},
"ghcr.io/mikaello/devcontainer-features/modern-shell-utils:1": {}
},
"init": true,
"overrideCommand": false,

"postCreateCommand": "bash ./.devcontainer/postCreateCommand.sh",

"postAttachCommand": "$BROWSER \"https://${CODESPACE_NAME}-8787.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}/\"",

"customizations": {
"vscode": {
"settings": {
"r.rterm.linux": "/usr/local/bin/radian",
"r.bracketedPaste": true,
"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": "active"
},
"extensions": [
"vsls-contrib.codetour",
"GitHub.copilot",
"GitHub.copilot-chat",
// R extensions
"ikuyadeu.r",
"REditorSupport.r-lsp",
// Extra extension
"streetsidesoftware.code-spell-checker",
"eamodio.gitlens",
"cweijan.vscode-office",
"donjayamanne.githistory",
"GitHub.vscode-github-actions",
"GitHub.vscode-pull-request-github",
"GitHub.remotehub",
"alefragnani.Bookmarks",
"vscode-icons-team.vscode-icons"
]
}
},

// RStudio ports
"forwardPorts": [8787],
"portsAttributes": {
"8787": {
"label": "Rstudio",
"requireLocalPort": true,
"onAutoForward": "openBrowser"
}
},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root
"remoteUser": "rstudio"
}
75 changes: 75 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
// https://containers.dev/implementors/json_reference/
"name": "Admiral R-4.3 (RStudio) container",
"image": "ghcr.io/pharmaverse/admiralci-4.3:latest",
// Install Dev Container Features. More info: https://containers.dev/features
"containerEnv": {
"ROOT": "true",
"PASSWORD": "rstudio",
"DISABLE_AUTH": "true"
},
"features": {
"ghcr.io/rocker-org/devcontainer-features/r-rig:1": {
"version": "none",
"vscodeRSupport": "full",
"installRadian": true,
"installVscDebugger": true
},
"ghcr.io/rocker-org/devcontainer-features/renv-cache:latest": {},
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"configureZshAsDefaultShell": false,
"installOhMyZsh": true,
"username": "rstudio",
"upgradePackages": false
},
"ghcr.io/mikaello/devcontainer-features/modern-shell-utils:1": {}
},
"init": true,
"overrideCommand": false,

"postCreateCommand": "bash ./.devcontainer/postCreateCommand.sh",

"postAttachCommand": "$BROWSER \"https://${CODESPACE_NAME}-8787.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}/\"",

"customizations": {
"vscode": {
"settings": {
"r.rterm.linux": "/usr/local/bin/radian",
"r.bracketedPaste": true,
"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": "active"
},
"extensions": [
"vsls-contrib.codetour",
"GitHub.copilot",
"GitHub.copilot-chat",
// R extensions
"ikuyadeu.r",
"REditorSupport.r-lsp",
// Extra extension
"streetsidesoftware.code-spell-checker",
"eamodio.gitlens",
"cweijan.vscode-office",
"donjayamanne.githistory",
"GitHub.vscode-github-actions",
"GitHub.vscode-pull-request-github",
"GitHub.remotehub",
"alefragnani.Bookmarks",
"vscode-icons-team.vscode-icons"
]
}
},

// RStudio ports
"forwardPorts": [8787],
"portsAttributes": {
"8787": {
"label": "Rstudio",
"requireLocalPort": true,
"onAutoForward": "openBrowser"
}
},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root
"remoteUser": "rstudio"
}
5 changes: 5 additions & 0 deletions .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

R -q -e 'renv::activate(profile = paste(R.version$major, substr(R.version$minor, 1, 1), sep = ".")); renv::restore(); staged.dependencies::install_deps(staged.dependencies::dependency_table(project = ".", verbose = 1), verbose = 1);'

jq --arg folder "$(pwd)/" '. + { "initial_working_directory": $folder }' .devcontainer/rstudio-prefs.json > ~/.config/rstudio/rstudio-prefs.json
8 changes: 8 additions & 0 deletions .devcontainer/rstudio-prefs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"save_workspace": "never",
"always_save_history": false,
"reuse_sessions_for_project_links": true,
"posix_terminal_shell": "bash",
"initial_working_directory": "/workspaces",
"show_hidden_files": true
}
Loading

0 comments on commit 64c6618

Please sign in to comment.