Skip to content

Commit 7ea95b0

Browse files
committed
Add .Rprofile
1 parent be9fdc6 commit 7ea95b0

23 files changed

+263
-41
lines changed

.Rprofile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
options(repos = BiocManager::repositories())

.github/workflows/rworkflows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ jobs:
5555
runner_os: ${{ runner.os }}
5656
cache_version: cache-v1
5757
free_diskspace: ${{ true }}
58-
miniforge_variant: "Mambaforge"
58+
miniforge_variant: false

.github/workflows/rworkflows_dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ jobs:
5757
runner_os: ${{ runner.os }}
5858
cache_version: cache-v1
5959
free_diskspace: ${{ true }}
60-
miniforge_variant: "Mambaforge"
60+
miniforge_variant: false

.github/workflows/rworkflows_static.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
if: runner.os == 'Linux'
9595
run: |
9696
mkdir -p /__w/_temp/Library
97-
echo ".libPaths('/__w/_temp/Library')" > ~/.Rprofile
97+
echo ".libPaths('/__w/_temp/Library')" >> ~/.Rprofile
9898
git config --global --add safe.directory '*'
9999
shell: bash {0}
100100
- name: ⏬ Checkout repository

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export(infer_biocviews)
1414
export(infer_deps)
1515
export(is_gha)
1616
export(use_badges)
17+
export(use_codespace)
1718
export(use_dockerfile)
1819
export(use_issue_template)
1920
export(use_readme)

NEWS.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,23 @@
33
## New features
44

55
* Add *.devcontainer/devcontainer.json*
6-
6+
* `use_vignette_docker`
7+
- New helper func: `infer_docker_org`
8+
9+
## Bug fixes
10+
11+
* `infer_deps`
12+
- Pass `infer_deps` the *DESCRIPTION* path directly
13+
within the `fill_description` func.
14+
- Fix unit tests.
15+
* `conda_*`
16+
- Try to get reticularte to find the path to conda
17+
installed by `setup-miniconda`.
18+
* New func: `use_codespace`
19+
- Create dev container config file.
20+
* *.Rprofile*
21+
- Added to avoid CRAN issues with bioc packages.
22+
723
# rworkflows 0.99.14
824

925
## New features

R/fill_description.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,11 @@ fill_description <- function(path = here::here("DESCRIPTION"),
9494
depth = 2)$r,
9595
")"
9696
),
97-
imports = infer_deps(which = "Imports",
97+
imports = infer_deps(path = path,
98+
which = "Imports",
9899
add_newlines = TRUE),
99-
suggests = infer_deps(which = "Suggests",
100+
suggests = infer_deps(path = path,
101+
which = "Suggests",
100102
add_newlines = TRUE),
101103
remotes = NULL,
102104
version = NULL,

R/infer_deps.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@
2020
#' @importFrom desc desc
2121
#' @importFrom renv dependencies
2222
#' @examples
23-
#' deps <- infer_deps()
24-
infer_deps <- function(path = here::here(),
23+
#' #### Get example DESCRIPTION file ####
24+
#' url <- "https://github.com/neurogenomics/templateR/raw/master/DESCRIPTION"
25+
#' path <- tempfile(fileext = "DESCRIPTION")
26+
#' utils::download.file(url,path)
27+
#'
28+
#' deps <- infer_deps(path = path)
29+
infer_deps <- function(path = here::here("DESCRIPTION"),
2530
which = c("Imports","Suggests"),
2631
imports_thresh = 2,
2732
imports = NULL,

R/infer_docker_org.R

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
infer_docker_org <- function(docker_org,
2+
docker_registry,
3+
verbose=TRUE){
4+
if(!is.null(docker_org)){
5+
return(docker_org)
6+
} else if(is.null(docker_org) &&
7+
grepl("ghcr.io",docker_registry)){
8+
## Infer docker_org from DESCRIPTION
9+
desc_file <- get_description(verbose = verbose)
10+
gh_url <- get_github_url_desc(desc_file = desc_file[[1]])
11+
if(!is.null(gh_url)){
12+
docker_org <- rev(strsplit(gh_url,"/")[[1]])[2]
13+
return(docker_org)
14+
} else {
15+
stopper("docker_org must be supplied.")
16+
}
17+
} else {
18+
stopper("docker_org must be supplied.")
19+
}
20+
}

R/use_codespace.R

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#' Use Codespace
2+
#'
3+
#' Generate a dev container config file to set up a
4+
#' \href{https://docs.github.com/en/codespaces}{GitHub Codespace}.
5+
#' @param template Dev container config template to use.
6+
#' @param image Base Docker image to use for the Codespace.
7+
#' @param features Named list of features to add to the Codespace.
8+
#' See \href{https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/configuring-dev-containers/adding-features-to-a-devcontainer-file}{here}
9+
#' for details.
10+
#' @param customizations Named list of customizations to add to the Codespace.
11+
#' See \href{https://containers.dev/supporting}{here}
12+
#' for details.
13+
#' @inheritParams use_vignette_docker
14+
#' @returns Path to dev container config file.
15+
#'
16+
#' @export
17+
#' @examples
18+
#' path <- use_codespace(save_dir=tempdir())
19+
use_codespace <- function(template="devcontainer.json",
20+
image="ghcr.io/neurogenomics/rworkflows:dev",
21+
features=list(
22+
"ghcr.io/devcontainers/features/conda:1"=list()
23+
),
24+
customizations=list(
25+
vscode=list(
26+
settings=list(),
27+
extensions=
28+
list("reditorsupport.r",
29+
"visualstudioexptteam.vscodeintellicode",
30+
"ionutvmi.path-autocomplete")
31+
)
32+
),
33+
save_dir=here::here(".devcontainer"),
34+
path=file.path(save_dir,
35+
template),
36+
force_new=FALSE,
37+
show=FALSE,
38+
verbose=TRUE){
39+
# devoptera::args2vars(use_codespace)
40+
41+
#### Create or use existing file ####
42+
if(file.exists(path) &&
43+
isFALSE(force_new)){
44+
messager("Using existing dev container config file ==>",path,v=verbose)
45+
} else {
46+
requireNamespace("jsonlite")
47+
messager("Creating new dev container config file ==>",path,v=verbose)
48+
tmp <- system.file("templates","devcontainer.json",package="rworkflows")
49+
jsn <- jsonlite::read_json(tmp)
50+
jsn$features <- features
51+
jsn$customizations <- customizations
52+
jsonlite::write_json(jsn,path)
53+
}
54+
#### Preview ####
55+
if(isTRUE(show)){
56+
messager("Config file preview:",v=verbose)
57+
cat(paste(readLines(path),collapse ="\n"))
58+
}
59+
return(path)
60+
}

0 commit comments

Comments
 (0)