Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…nner

* 'master' of https://github.com/MarkEdmondson1234/cloudRunner: (33 commits)
  [skip travis] Build website from commit 626b70a:                   20191210T10:57:09
  not that name
  A function helper for #8 let users specify own Dockerfile in gadget #1
  [skip travis] Build website from commit 736a8ba:                   20191209T09:00:35
  gadget launch api that works with pubsub #1 #8
  [skip travis] Build website from commit 346d776:                   20191208T21:49:16
  working gadget Docker deployments and R scheduling
  [skip travis] Build website from commit 8928036:                   20191208T16:56:28
  work on rstudio gadget #1
  [skip travis] Build website from commit 73f41a1:                   20191206T22:08:54
  do not ignore docs folder else it doesn't update...
  [skip travis] Build website from commit 4186bce:                   20191206T21:53:42
  [skip travis] Build website from commit 4186bce:                   20191206T21:50:54
  gadgets
  [skip travis] Build website from commit cb0394e:                   20191206T21:33:19
  add all files for new pkgdown
  [skip travis] Build website from commit bec88e5:                   20191206T21:26:52
  work on gadget for #1
  [skip travis] Build website from commit 5a43dd3:                   20191206T20:45:33
  fix docs
  ...

# Conflicts:
#	R/deploy.R
  • Loading branch information
Mark IIH committed Dec 10, 2019
2 parents 5d956b0 + 18c3c0b commit 5cb7f6d
Show file tree
Hide file tree
Showing 108 changed files with 3,751 additions and 309 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ auth/
.Renviron
deploy
inst/doc
docs/
13 changes: 7 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@ Imports:
jsonlite (>= 1.5),
methods,
openssl,
plumber,
rstudioapi,
stats,
utils,
yaml
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
Suggests:
containerit (>= 0.6.0),
knitr,
miniUI,
rmarkdown,
rstudioapi,
shiny,
testthat (>= 2.1.0)
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
Remotes:
o2r-project/containerit,
r-hub/sysreqs
Expand Down
6 changes: 5 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export(Job)
export(RepoSource)
export(Source)
export(StorageSource)
export(Yaml)
export(cr_bucket_get)
export(cr_bucket_set)
export(cr_build)
Expand All @@ -34,6 +33,7 @@ export(cr_build_status)
export(cr_build_upload_gcs)
export(cr_build_wait)
export(cr_build_write)
export(cr_build_yaml)
export(cr_buildstep)
export(cr_buildstep_decrypt)
export(cr_buildstep_df)
Expand All @@ -49,13 +49,17 @@ export(cr_buildtrigger_delete)
export(cr_buildtrigger_edit)
export(cr_buildtrigger_get)
export(cr_buildtrigger_list)
export(cr_buildtrigger_make)
export(cr_buildtrigger_run)
export(cr_deploy_docker)
export(cr_deploy_gadget)
export(cr_deploy_pkgdown)
export(cr_deploy_r)
export(cr_deploy_run)
export(cr_dockerfile)
export(cr_email_get)
export(cr_email_set)
export(cr_plumber_pubsub)
export(cr_project_get)
export(cr_project_set)
export(cr_region_get)
Expand Down
2 changes: 1 addition & 1 deletion R/build_sources.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ is.gar_SourceRepo <- function(x){
#' branchName="master"))
#'
#' build <- cr_build(
#' Yaml(steps =
#' cr_build_yaml(steps =
#' cr_buildstep("gcloud", c("-c","ls -la"),
#' entrypoint = "bash",
#' dir = "")),
Expand Down
7 changes: 4 additions & 3 deletions R/buildsteps.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#'
#' # creating yaml for use in deploying cloud run
#' image = "gcr.io/my-project/my-image:$BUILD_ID"
#' Yaml(
#' cr_build_yaml(
#' steps = c(
#' cr_buildstep("docker", c("build","-t",image,".")),
#' cr_buildstep("docker", c("push",image)),
Expand All @@ -48,7 +48,7 @@
#'
#' # use premade docker buildstep - combine using c()
#' image = "gcr.io/my-project/my-image"
#' Yaml(
#' cr_build_yaml(
#' steps = c(cr_buildstep_docker(image),
#' cr_buildstep("gcloud",
#' args = c("beta","run","deploy",
Expand All @@ -57,7 +57,8 @@
#' images = image)
#'
#' # list files with a new entrypoint for gcloud
#' Yaml(steps = cr_buildstep("gcloud", c("-c","ls -la"), entrypoint = "bash"))
#' cr_build_yaml(steps = cr_buildstep("gcloud", c("-c","ls -la"),
#' entrypoint = "bash"))
#'
#' # to call from images not using gcr.io/cloud-builders stem
#' cr_buildstep("alpine", c("-c","ls -la"), entrypoint = "bash", prefix="")
Expand Down
22 changes: 13 additions & 9 deletions R/buildsteps_templates.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' Helper to run R code within build steps, from either an existing local R file or within the source of the build.
#'
#' @param r R code to run or a file containing R code - see details
#' @param r R code to run or a file containing R code
#' @param name The docker image that will run the R code, usually from rocker-project.org
#' @param r_source Whether the R code will be from a runtime file within the source or at build time copying over from a local R file in your session
#' @param ... Other arguments passed to \link{cr_buildstep}
Expand Down Expand Up @@ -33,7 +33,7 @@
#' # use a different Rocker image e.g. rocker/verse
#' cr_buildstep_r(c("library(dplyr)",
#' "mtcars %>% select(mpg)",
#' "sessionInfo"),
#' "sessionInfo()"),
#' name = "verse")
#'
#' # use your own R image with custom R
Expand All @@ -50,20 +50,25 @@ cr_buildstep_r <- function(r,
...){

r_source <- match.arg(r_source)

# catches name=rocker/verse etc.
if(dirname(name) == "rocker"){
name <- basename(name)
}

# don't allow dot names that would break things
dots <- list(...)
assert_that(
is.null(dots$args),
is.null(dots$name),
is.null(dots$prefix)
)

rchars <- r
if(r_source == "local"){
assert_that(is.character(r))

rchars <- r
if(grepl("\\.R", r[[1]], ignore.case = TRUE)){
if(grepl("\\.R$", r[[1]], ignore.case = TRUE)){
# filepath
assert_that(is.readable(r), is.string(r))
rchars <- readLines(r)
Expand Down Expand Up @@ -194,7 +199,7 @@ cr_buildstep_docker <- function(image,
#' @examples
#'
#' # assumes you have previously saved git ssh key via KMS called "git_key"
#' Yaml(
#' cr_build_yaml(
#' steps = c(
#' cr_buildstep_gitsetup("my_keyring", "git_key"),
#' cr_buildstep_git(c("clone",
Expand Down Expand Up @@ -225,7 +230,6 @@ cr_buildstep_gitsetup <- function(keyring = "my-keyring",
keyring = keyring,
key = key,
volumes = git_volume()),
#TODO: pull in the host_file in inst/ssh/host_file
cr_buildstep_extract(bs, 2)
)
}
Expand Down Expand Up @@ -288,7 +292,7 @@ cr_buildstep_git <- function(
#' steps <- cr_buildstep_pkgdown("$_GITHUB_REPO",
#' "cloudbuild@google.com",
#' env = c("MYVAR=$_MY_VAR", "PROJECT=$PROJECT_ID"))
#' build_yaml <- Yaml(steps = steps)
#' build_yaml <- cr_build_yaml(steps = steps)
#' my_source <- cr_build_source(RepoSource("my_repo", branch="master"))
#' build <- cr_build_make(build_yaml, source = my_source)
cr_buildstep_pkgdown <- function(
Expand All @@ -303,7 +307,6 @@ cr_buildstep_pkgdown <- function(
pd <- system.file("cloudbuild/cloudbuild_pkgdown.yml",
package = "googleCloudRunner")


# In yaml.load: NAs introduced by coercion: . is not a real
pdb <- suppressWarnings(cr_build_make(pd))

Expand All @@ -317,11 +320,12 @@ cr_buildstep_pkgdown <- function(
cipher = cipher),
cr_buildstep_git(c("clone",repo, "repo")),
pkg_env,
cr_buildstep_git(c("add", "."), dir = "repo"),
cr_buildstep_git(c("add", "--all"), dir = "repo"),
cr_buildstep_git(c("commit", "-a", "-m",
"[skip travis] Build website from commit ${COMMIT_SHA}: \
$(date +\"%Y%m%dT%H:%M:%S\")"),
dir = "repo"),
cr_buildstep_git(c("status"), dir = "repo"),
cr_buildstep_git("push", repo, dir = "repo")
)

Expand Down
36 changes: 25 additions & 11 deletions R/buildtriggers.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ cr_buildtrigger_get <- function(triggerId,
#'
#' Seems not to work at the moment (issue #16)
#'
#' @param BuildTrigger The \link{BuildTrigger} object to pass to this method
#' @param BuildTrigger The \link{BuildTrigger} object to update to
#' @param projectId ID of the project that owns the trigger
#' @param triggerId ID of the `BuildTrigger` to get or a \code{BuildTriggerResponse} object
#' @param triggerId ID of the `BuildTrigger` to edit or a previous \code{BuildTriggerResponse} object that will be edited
#' @importFrom googleAuthR gar_api_generator
#' @family BuildTrigger functions
#'
Expand All @@ -48,7 +48,6 @@ cr_buildtrigger_get <- function(triggerId,
#' description = "edited trigger")
#'
#' edited <- cr_buildtrigger_edit(bt3, triggerId = bt2)
#' # Error: API returned: trigger (1080525199262, ) not found
#'
#' }
#'
Expand All @@ -58,13 +57,14 @@ cr_buildtrigger_edit <- function(BuildTrigger,
projectId = cr_project_get()) {

triggerId <- get_buildTriggerResponseId(triggerId)
BuildTrigger$id <- triggerId

url <- sprintf("https://cloudbuild.googleapis.com/v1/projects/%s/triggers/%s",
projectId, triggerId)
# cloudbuild.projects.triggers.patch
f <- gar_api_generator(url, "PATCH",
data_parse_function = as.buildTriggerResponse,
checkTrailingSlash = FALSE)
checkTrailingSlash = TRUE)
stopifnot(inherits(BuildTrigger, "BuildTrigger"))

f(the_body = BuildTrigger)
Expand Down Expand Up @@ -127,28 +127,32 @@ parse_buildtrigger_list <- function(x){
#' Creates a new `BuildTrigger`.This API is experimental.
#'
#' @inheritParams BuildTrigger
#' @param trigger The trigger which will be a \link{RepoSource} or a \link{GitHubEventsConfig}
#' @param trigger The trigger source which will be a \link{RepoSource} or a \link{GitHubEventsConfig}
#' @param build A file location within the trigger source to use for the build steps, or a \link{Build} object
#' @param projectId ID of the project for which to configure automatic builds
#' @importFrom googleAuthR gar_api_generator
#' @family BuildTrigger functions
#' @export
#' @examples
#'
#' \dontrun{
#' cloudbuild <- system.file("cloudbuild/cloudbuild.yaml",
#' package = "googleCloudRunner")
#' bb <- cr_build_make(cloudbuild, projectId = "test-project")
#' github <- GitHubEventsConfig("MarkEdmondson1234/googleCloudRunner", branch = "master")
#' github <- GitHubEventsConfig("MarkEdmondson1234/googleCloudRunner",
#' branch = "master")
#' # creates a trigger with named subtitutions
#' ss <- list(`_MYVAR` = "TEST1",
#' `_GITHUB` = "MarkEdmondson1234/googleCloudRunner")
#'
#' \dontrun{
#'
#' cr_buildtrigger("trig1", trigger = github, build = bb)
#'
#' # creates a trigger with named subtitutions
#' ss <- list(`_MYVAR` = "TEST1", `_GITHUB` = "MarkEdmondson1234/googleCloudRunner")
#' cr_buildtrigger("trig2", trigger = github, build = bb, substitutions = ss)
#'
#' # create a trigger that will build from the file in the repo
#' cr_buildtrigger("trig3", trigger = github, build = "inst/cloudbuild/cloudbuild.yaml")
#' cr_buildtrigger("trig3", trigger = github,
#' build = "inst/cloudbuild/cloudbuild.yaml")
#' }
cr_buildtrigger <- function(name,
trigger,
Expand Down Expand Up @@ -231,6 +235,16 @@ cr_buildtrigger_run <- function(triggerId,

}

#' Create a buildtrigger object
#' @family BuildTrigger functions
#' @inheritDotParams cr_buildtrigger
#' @export
cr_buildtrigger_make <- function(...){

buildtrigger_make(...)

}


buildtrigger_make <- function(name,
trigger,
Expand All @@ -248,7 +262,7 @@ buildtrigger_make <- function(name,
UseMethod("buildtrigger_make", trigger)
}

buildtrigger_make.RepoSource <- function(name,
buildtrigger_make.gar_RepoSource <- function(name,
trigger,
build,
description = NULL,
Expand Down
Loading

0 comments on commit 5cb7f6d

Please sign in to comment.