Skip to content

Commit

Permalink
commit before switch
Browse files Browse the repository at this point in the history
  • Loading branch information
bschilder committed Sep 12, 2023
1 parent 3a45873 commit b56467e
Show file tree
Hide file tree
Showing 39 changed files with 720 additions and 189 deletions.
7 changes: 7 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@ rworkflows-merged
^pkgdown$
^Dockerfile$
^LICENSE
# Sweave vignette outputs
vignettes/*.bbl
vignettes/*.log
vignettes/*.pdf
vignettes/*.gz
vignettes/*.toc
vignettes/*.tex
12 changes: 7 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,24 @@ Imports:
desc,
badger,
renv,
biocViews,
tools,
methods,
BiocPkgTools,
BiocManager,
data.table
Suggests:
markdown,
rmarkdown,
remotes,
knitr,
BiocStyle,
knitr,
covr,
testthat (>= 3.0.0),
htmltools
htmltools,
jsonlite,
BiocStyle,
BiocPkgTools,
biocViews
RoxygenNote: 7.2.3
VignetteBuilder: knitr
License: GPL-3
Config/testthat/edition: 3
LazyData: true
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export(bioc_r_versions)
export(construct_authors)
export(construct_cont)
export(construct_runners)
export(dt_to_desc)
export(fill_description)
Expand All @@ -17,11 +18,9 @@ export(use_readme)
export(use_vignette_docker)
export(use_vignette_getstarted)
export(use_workflow)
import(BiocPkgTools)
import(badger)
import(desc)
importFrom(BiocManager,version)
importFrom(biocViews,recommendBiocViews)
importFrom(data.table,":=")
importFrom(data.table,as.data.table)
importFrom(desc,desc)
Expand All @@ -32,6 +31,7 @@ importFrom(methods,is)
importFrom(renv,dependencies)
importFrom(stats,setNames)
importFrom(tools,R_user_dir)
importFrom(utils,data)
importFrom(utils,download.file)
importFrom(utils,person)
importFrom(yaml,as.yaml)
Expand Down
25 changes: 25 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,36 @@
## New features

* Merge PR #66 by @js2264 to eliminate the PAT_GITHUB secret setup step.
* Merge PR #71 by @js2264 to skip vignettes when building if `run_vignettes`.
* Add fun emojis to action.
* Add vignette for checking Sweave (.Rnw) files can be rendered.
* *action.yml*
- Add new args to control latex: `tinytex_installer`, `tinytex_version`
- Install extra latex deps using one step for all OS via `tinytex` R package.
* `construct_runners`
- Simplify arguments so that user doesn't have to pass OS names.
- When an arg like `bioc` is of length one, the same value is automatically
applied across all 3 OS.
* *bioconductor.Rmd*
- Add vignette specifically for Bioconductor packages.
* `use_workflow`
- Split `name` arg into two args: `name` + `template`,
so that you can create multiple separate workflow files
using the same template.
- Add new args to control latex: `tinytex_installer`, `tinytex_version`
- New internal subfunctions:
- `save_yaml`
- `check_bioc_version`
- New exported subfunction: `construct_cont`
* Transition `BiocPkgTools` + `biocViews` to Suggests
- Based on recc from CRAN maintainers, as they do not consistently
install/update Bioc packages on the CRAN server.

## Bug fixes

* Add "devel" as trigger branch in all 3 workflows.
* Harmonise `github_token` parameter docs between
*action.yml* and `use_workflow`.

# rworkflows 0.99.12

Expand Down
11 changes: 8 additions & 3 deletions R/bioc_r_versions.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@
#' \item{\code{depth=2}: }{"4.2"}
#' \item{\code{depth=3}: }{"4.2.0"}
#' }
#' @param return_opts Return a character vector of all valid Bioc version names.
#' @returns Named list of Bioc/R versions
#'
#' @export
#' @importFrom yaml read_yaml
#' @examples
#' ver <- bioc_r_versions(bioc_version="devel")
bioc_r_versions <- function(bioc_version = NULL,
depth = NULL){
depth = NULL,
return_opts = FALSE){
# devoptera::args2vars(bioc_r_versions)

yml <- yaml::read_yaml("https://bioconductor.org/config.yaml")
Expand All @@ -46,7 +48,10 @@ bioc_r_versions <- function(bioc_version = NULL,
parse_version(v, depth=depth)
})
#### Handler ####
if(is.null(bioc_version)){
if(isTRUE(return_opts)){
opts <- c(names(info)[seq(2)], rev(names(info$r_ver_for_bioc_ver)))
return(opts)
} else if(is.null(bioc_version)){
return(info)
} else if (bioc_version=="devel") {
return(info$devel)
Expand All @@ -68,5 +73,5 @@ bioc_r_versions <- function(bioc_version = NULL,
}
# info[["r_latest"]] <- package_version(rversions::r_release()$version)
# info[["r_devel"]] <- package_version(rversions::r_release()$version)
return(info)
return(info)
}
19 changes: 19 additions & 0 deletions R/check_bioc_version.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
check_bioc_version <- function(bioc){

opts <- bioc_r_versions(return_opts = TRUE)
bioc <- tolower(as.character(bioc))
if(bioc %in% c("release_*",
"release*",
"release")){
bioc <- "release"
} else {
bioc <- gsub("_",".",gsub("RELEASE_","",bioc, ignore.case = TRUE))
}
if(!bioc %in% opts){
stopper(paste0("bioc=",shQuote(bioc)),
"bioc version must be one of:",
paste("\n -",shQuote(opts),collapse = ""))
} else {
return(bioc)
}
}
44 changes: 44 additions & 0 deletions R/check_cont.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#' Check containers exist
#'
#' Check that a list of containers are valid.
#' @inheritParams construct_runners
#' @param domain Container repository API domain.
#' @returns NUll
#'
#' @keywords internal
check_cont <- function(cont,
domain = "https://hub.docker.com/v2/repositories/",
verbose = TRUE){

requireNamespace("jsonlite")
for(co in cont){
if(is.null(co)) next()
if(isFALSE(grepl("/",co))){
stopper("Container must be specificied in the following format:",
"'owner/repo:tag'")
}
splt <- strsplit(co,":")[[1]]
URL <- paste(domain, splt[1],
"tags?page_size=1000",sep="/"
)
#### Check repo exists ####
messager("Checking public container repository exists:",shQuote(splt[1]),
v=verbose)
js <- tryCatch({
jsonlite::read_json(URL)
}, error=function(e){
stopper("Unable to find public container:",co)
}
)
#### Check tag exists ####
if(length(splt)==2){
messager("Checking tag exists:",shQuote(splt[2]),
v=verbose)
tags <- sapply(js$results ,function(x){x$name})
if(!splt[2] %in% tags){
stopper("The tag", shQuote(splt[2]),
"does not exist in the repo",shQuote(splt[1]))
}
}
}
}
67 changes: 67 additions & 0 deletions R/construct_cont.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#' Construct containers list
#'
#' @param run_check_cont Check whether the requested container repo
#' (and the tag, if specified) exist using \link[rworkflows]{check_cont}.
#' @param default_cont The DockerHub container to default to.
#' Used when it's detected that only the tag has been given in one or more
#' \code{cont} entry.
#' @param default_tag The DockerHub container tag to default to.
#' @inheritParams construct_runners
#' @returns Named list of containers
#'
#' @export
#' @importFrom stats setNames
#' @examples
#' cont <- construct_cont()
construct_cont <- function(default_cont = "bioconductor/bioconductor_docker",
default_tag = "devel",
cont = list(
paste(default_cont,default_tag,sep=":"),
NULL,
NULL),
versions_explicit = FALSE,
run_check_cont = FALSE,
verbose = TRUE){
# devoptera::args2vars(construct_cont)

#### Remove any trailing : (e.g. when default_tag=NULL) ####
cont <- lapply(cont, function(x){
if(is.null(x)) NULL else trimws(x,whitespace = ":")
})
#### Run QC ####
cont2 <- lapply(cont,function(co){
if(is.null(co)){
return(NULL)
} else if(!grepl("/",co) &&
!is.null(default_cont)){
messager("Only tag name supplied to 'cont'.",
"Assuming default=",shQuote(default_cont),v=verbose)
co <- paste(default_cont,co,sep=":")
} else if(!grepl(":",co) |
!grepl(default_cont,co)) {
return(co)
}
splt <- strsplit(co,":")[[1]]
bioc_version <- rev(splt)[1]
if(isTRUE(versions_explicit)){
if(grepl(":",co)){
info <- bioc_r_versions(bioc_version = bioc_version)
return(
paste0(splt[[1]],":RELEASE_",gsub("[.]","_",info$bioc))
)
} else {
return(co)
}
} else if(tolower(bioc_version)=="release"){
co <- gsub(":release",":latest",co, ignore.case = TRUE)
}
return(co)
})
#### Check that the Dockerhub repo exists ####
if(isTRUE(run_check_cont)){
check_cont(cont = cont,
verbose = verbose)
}
#### Return ####
return(cont2)
}
71 changes: 27 additions & 44 deletions R/construct_runners.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#' @param versions_explicit Specify R/Bioc versions explicitly
#' (e.g. \code{r: 4.2.0, bioc: 3.16})
#' as opposed to flexibly (e.g. \code{r: "latest", bioc: "release"}).
#' @param verbose Print messages.
#' @returns Named list of configurations for each runner OS.
#'
#' @export
Expand All @@ -25,60 +26,42 @@
construct_runners <- function(os=c("ubuntu-latest",
"macOS-latest",
"windows-latest"),
bioc = stats::setNames(
list("devel",
"release",
"release"),
os
),
r = stats::setNames(
list("auto",
"auto",
"auto"),
os
bioc = list("devel",
"release",
"release"),
r = list("auto",
"auto",
"auto"),
versions_explicit = FALSE,
cont = construct_cont(default_tag = bioc[[1]]),
rspm = list(paste0(
"https://packagemanager.rstudio.com/",
"cran/__linux__/focal/release"
),
cont = stats::setNames(
list(paste0("bioconductor/bioconductor_docker:",
bioc[[1]]),
NULL,
NULL),
os
),
rspm = stats::setNames(
list(paste0(
"https://packagemanager.rstudio.com/",
"cran/__linux__/focal/release"
),
NULL,
NULL),
os
),
versions_explicit=FALSE
NULL,
NULL),
verbose = TRUE
){

# devoptera::args2varssource_all()
# devoptera::args2vars(construct_runners)
# devoptera::args2vars(construct_runners, reassign = TRUE)

#### Check args ####
construct_runners_check_args(os = os,
bioc = bioc,
r = r,
cont = cont)
cont <- construct_runners_check_cont(cont = cont,
versions_explicit = versions_explicit)
#### Set runners
args <- construct_runners_check_args(os = os,
bioc = bioc,
r = r,
cont = cont)
#### Set runners ####
runners <- lapply(os, function(o){
if(isTRUE(versions_explicit)){
info <- bioc_r_versions(bioc_version = bioc[[o]])
} else {
info <- list(bioc=bioc[[o]],
r=r[[o]])
info <- bioc_r_versions(bioc_version = args$bioc[[o]])
} else {
info <- list(bioc=check_bioc_version(bioc=args$bioc[[o]]),
r=args$r[[o]])
}
list(os = o,
bioc=info$bioc,
r=info$r,
cont=cont[[o]],
rspm=rspm[[o]]
cont=args$cont[[o]],
rspm=args$rspm[[o]]
)
})
return(runners)
Expand Down
Loading

0 comments on commit b56467e

Please sign in to comment.