Skip to content

Commit

Permalink
Add docker_registry argument
Browse files Browse the repository at this point in the history
  • Loading branch information
bschilder committed Oct 27, 2023
1 parent 7e97279 commit 1eceb31
Show file tree
Hide file tree
Showing 15 changed files with 583 additions and 542 deletions.
972 changes: 486 additions & 486 deletions .Rhistory

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions .github/workflows/rworkflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ name: rworkflows
- RELEASE_**
jobs:
rworkflows:
permissions:
contents: write
permissions: write-all
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
container: ${{ matrix.config.cont }}
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/rworkflows_static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ env:
enable_act: ${{ false }}
jobs:
rworkflows_static:
permissions:
contents: write
permissions: write-all
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
container: ${{ matrix.config.cont }}
Expand Down
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
- Make registry explicit.
- New arg: `default_registry`
- New subfunction: `check_registry`
* Add `docker_registry` arg to let users choose which registry to push to.
Defaults to "ghcr.io" instead of "docker.io" so that no additional credentials
are needed.
- *actions.yml*
- `use_workflow`
* `get_github_url_desc`
- Improve logic to catch more GH URLs.
* *vignettes/depgraph.Rmd*
- Update plots with new data and resave PNG.

## Bug fixes

Expand Down
2 changes: 2 additions & 0 deletions R/fill_yaml.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fill_yaml <- function(## function-level args
tinytex_version,
pandoc_version,
run_docker,
docker_registry,
github_token,
docker_user,
docker_org,
Expand All @@ -43,6 +44,7 @@ fill_yaml <- function(## function-level args
channels){
# devoptera::args2vars(use_workflow)

docker_registry <- docker_registry[1]
#### name ####
yml$name <- name
#### on ####
Expand Down
42 changes: 28 additions & 14 deletions R/get_github_url_desc.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,41 @@ get_github_url_desc <- function(desc_file){
## These fields sometimes contain >1 link.
## Find the one that's actually for the GitHub repo.
if(is.null(desc_file)) return (desc_file)
check_gh_url <- function(URL){
if(sum(grepl("https://github.com",URL))==0) {
return(NULL)
} else {
return(URL)
}
}
get_gh <- function(URL){
urls <- trimws(strsplit(URL,",")[[1]])
(
grep("https://github.com", urls, value = TRUE)[1] |>
strsplit("#")
)[[1]][1]
strsplit("#") |>
gsub(pattern="issues$",replacement="") |>
trimws(whitespace = "/")
)[[1]][1] |>
check_gh_url()
}
#### Parse ####
## From URL field
if(desc_file$has_fields("URL")){
return(get_gh(desc_file$get_field("URL")))
} else if (desc_file$has_fields("BugReports")){
return(
trimws(gsub("issues$","",get_gh(desc_file$get_field("BugReports"))),
whitespace = "/")
)
} else if (desc_file$has_fields("git_url")){
return(
paste("https://github.com",
strsplit(desc_file$get_field("git_url"),"[.]")[[1]][[2]],
basename(desc_file$get_field("git_url")),sep="/")
)
gh_url <- get_gh(desc_file$get_field("URL"))
if(!is.null(gh_url)) return(gh_url)
}
## From BugReports field
if (desc_file$has_fields("BugReports")){
gh_url <- get_gh(desc_file$get_field("BugReports"))
if(!is.null(gh_url)) return(gh_url)
}
## From git_url field
if (desc_file$has_fields("git_url")){
gh_url <- paste("https://github.com",
strsplit(desc_file$get_field("git_url"),"[.]")[[1]][[2]],
basename(desc_file$get_field("git_url")),sep="/")
gh_url <- check_gh_url(gh_url)
if(!is.null(gh_url)) return(gh_url)
} else {
return(NULL)
}
Expand Down
24 changes: 18 additions & 6 deletions R/use_workflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#' @param run_pkgdown Knit the \emph{README.Rmd} (if available),
#' build documentation website, and deploy to \emph{gh-pages} branch.
#' @param has_runit Run R Unit tests.
#' @param run_docker Whether to build and push a Docker container to DockerHub.
#' @param has_latex Install a suite of LaTeX dependencies used for
#' rendering Sweave (.rnw) and other documentation files.
#' @param tinytex_installer Which release of tinytex (bundles of LaTeX
Expand All @@ -66,13 +65,24 @@
#' Read
#' \href{https://docs.github.com/en/actions/security-guides/automatic-token-authentication}{
#' here for more details}.
#' @param docker_user DockerHub username.
#' @param docker_org DockerHub organization name.
#' @param run_docker Whether to build and push a Docker container to DockerHub.
#' @param docker_registry Docker container registry to push to.
#' Options include:
#' \itemize{
#' \item{"ghcr.io"} : \href{https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry}{
#' GitHub Container Registry}
#' \item{"docker.io"} : \href{https://hub.docker.com/}{DockerHub}
#' }
#' @param docker_user Docker registry username.
#' Not used when \code{docker_registry="ghcr.io"}.
#' @param docker_org Docker registry organization name.
#' Is the same as \code{docker_user} by default.
#' @param docker_token DockerHub token.
#' Not used when \code{docker_registry="ghcr.io"}.
#' @param docker_token Docker registry token.
#' Not used when \code{docker_registry="ghcr.io"}.
#'
#' @param force_new If the GHA workflow yaml already exists,
#' overwrite with new one (default: \code{FALSE}).
#'
#' @param save_dir Directory to save workflow to.
#' @param return_path Return the path to the saved \emph{yaml} workflow file
#' (default: \code{TRUE}), or return the \emph{yaml} object directly.
Expand Down Expand Up @@ -160,6 +170,7 @@ use_workflow <- function(## action-level args
run_pkgdown=TRUE,
### Container
run_docker=FALSE,
docker_registry="ghcr.io",
docker_user=NULL,
docker_org=docker_user,
docker_token="${{ secrets.DOCKER_TOKEN }}",
Expand Down Expand Up @@ -213,6 +224,7 @@ use_workflow <- function(## action-level args
branches=branches,
runners=runners,
## workflow-level args
github_token=github_token,
run_bioccheck=run_bioccheck,
run_rcmdcheck=run_rcmdcheck,
as_cran=as_cran,
Expand All @@ -226,7 +238,7 @@ use_workflow <- function(## action-level args
tinytex_version=tinytex_version,
pandoc_version=pandoc_version,
run_docker=run_docker,
github_token=github_token,
docker_registry=docker_registry,
docker_user=docker_user,
docker_org=docker_org,
docker_token=docker_token,
Expand Down
15 changes: 9 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,23 @@ inputs:
default: false
docker_registry:
description: >
Docker container registry.
Docker container registry to push to.
Options include:
- ghcr.io : [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry}{GitHub Container Registry)
- docker.io : [DockerHub](https://hub.docker.com/)
- ghcr.io : GitHub Container Registry (https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry)
- docker.io : DockerHub (https://hub.docker.com/)
default: 'ghcr.io'
docker_user:
description: >
DockerHub username.
Docker registry username.
Not used when `docker_registry="ghcr.io"`.
docker_org:
description: >
DockerHub organization name. Can be the same as Docker username.
Docker registry organization name. Can be the same as `docker_user`.
Not used when `docker_registry="ghcr.io"`.
DOCKER_TOKEN:
description: >
DockerHub authentication token.
Docker registry authentication token.
Not used when `docker_registry="ghcr.io"`.
GITHUB_TOKEN:
description: >
GitHub authentication token with permissions to push
Expand Down
20 changes: 4 additions & 16 deletions inst/templates/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,10 @@ RUN echo $PKG
RUN mkdir -p /$PKG
ADD . /$PKG
WORKDIR /$PKG
# Install dependencies with AnVil (faster)
#### Install package dependencies ####
RUN Rscript -e 'options(download.file.method="libcurl", crayon.enabled=TRUE, timeout=2000); \
if(!require("BiocManager")) install.packages("BiocManager"); \
if(!require("AnVIL")) {BiocManager::install("AnVIL", ask = FALSE)}; \
AnVIL::install(c("remotes","devtools")); \
try({remotes::install_github("bergant/rapiclient")}); \
bioc_ver <- BiocManager::version(); \
options(repos = c(AnVIL::repositories(),\
AnVIL = file.path("https://bioconductordocker.blob.core.windows.net/packages",bioc_ver,"bioc"),\
CRAN = "https://cran.rstudio.com/"),\
download.file.method = "libcurl", Ncpus = 2); \
deps <- remotes::dev_package_deps(dependencies = TRUE)$package; \
AnVIL::install(pkgs = deps, ask = FALSE); \
deps_left <- deps[!deps %in% rownames(installed.packages())]; \
if(length(deps_left)>0) devtools::install_dev_deps(dependencies = TRUE, upgrade = "never");'
# Install R package from source
RUN R -e 'options(crayon.enabled = TRUE); \
remotes::install_local(upgrade="never")'
if(!require("remotes")) install.packages("remotes");
repos <- BiocManager::repositories()
remotes::install_local(repos=repos, dependencies=TRUE, build_vignettes=FALSE, upgrade=TRUE, force=TRUE)'
RUN rm -rf /$PKG
20 changes: 16 additions & 4 deletions man/use_workflow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified reports/dep_graph_res.rds
Binary file not shown.
Binary file modified reports/r_repos_upset.pdf
Binary file not shown.
6 changes: 3 additions & 3 deletions reports/rworkflows_depgraph.html

Large diffs are not rendered by default.

Binary file modified reports/rworkflows_depgraph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions vignettes/depgraph.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,18 @@ res <- echodeps::dep_graph(pkg = "rworkflows",
method_seed = "github",
exclude = c("neurogenomics_rworkflows",
"neurogenomics_r_workflows"),
node_size = "total_downloads",
height="100%",
#node_size = "total_downloads",
reverse = TRUE,
save_path = here::here("reports","rworkflows_depgraph.html"))
save_path = here::here("reports","rworkflows_depgraph.html"))
```

## Save data

``` r
## Save network plot as PNG
echodeps::visnet_save(res$save_path)

## Save all data and plots
saveRDS(res, here::here("reports","dep_graph_res.rds"))
```

Expand Down

0 comments on commit 1eceb31

Please sign in to comment.