cr_deploy_packagetests {googleCloudRunner}R Documentation

Deploy a cloudbuild.yml for R package tests and upload to Codecov

Description

This tests an R package each time you commit, and uploads the test coverage results to Codecov

Usage

cr_deploy_packagetests(
  steps = NULL,
  cloudbuild_file = "cloudbuild-tests.yml",
  env = c("NOT_CRAN=true"),
  test_script = NULL,
  codecov_script = NULL,
  codecov_token = "$_CODECOV_TOKEN",
  build_image = "gcr.io/gcer-public/packagetools:latest",
  create_trigger = c("file", "inline", "no"),
  trigger_repo = NULL,
  ...
)

Arguments

steps

extra steps to run before the cr_buildstep_packagetests steps run (such as decryption of auth files)

cloudbuild_file

The cloudbuild yaml file to write to. See create_trigger

env

Environment arguments to be set during the test script runs

test_script

The script that will call rcmdcheck to perform tests. If NULL a default script is used in system.file("r_buildsteps", "devtools_tests.R", package="googlecloudRunner")

codecov_script

The script that will call codecov to perform coverage. If NULL a default script is used in system.file("r_buildsteps", "codecov_tests.R", package="googleCloudRunner")

codecov_token

If using codecov, supply your codecov token here.

build_image

The docker image that will be used to run the R code for the test scripts

create_trigger

If creating a trigger, whether to create it from the cloudbuild_file or inline

trigger_repo

If not NULL, a cr_buildtrigger_repo where a buildtrigger will be created via cr_buildtrigger

...

Arguments passed on to cr_build_make

yaml

A Yaml object created from cr_build_yaml or a file location of a .yaml/.yml cloud build file

artifacts

Artifacts that may be built via cr_build_yaml_artifact

options

Options to pass to a Cloud Build

availableSecrets

Secret Manager objects built by cr_build_yaml_secrets

logsBucket

The gs:// location of a bucket to put logs in

source

A Source object specifying the location of the source files to build, usually created by cr_build_source

timeout

Amount of time that this build should be allowed to run, to second

images

A list of images to be pushed upon the successful completion of all build

substitutions

Substitutions data for 'Build' resource

serviceAccount

service account email to be used for the build

Details

The trigger repository needs to hold an R package configured to do tests upon.

For GitHub, the repository will need to be linked to the project you are building within, via https://console.cloud.google.com/cloud-build/triggers/connect

If your tests need authentication details, add these via cr_buildstep_secret to the steps argument, which will prepend decrypting the authentication file before running the tests.

If you want codecov to ignore some files then also deploy a .covrignore file to your repository - see covr website at https://covr.r-lib.org/ for details.

See Also

Create your own custom deployment using cr_buildstep_packagetests which this function uses with some defaults

cr_buildstep_packagetests

Other Deployment functions: cr_deploy_docker_trigger(), cr_deploy_docker(), cr_deploy_pkgdown(), cr_deploy_run_website(), cr_deploy_run(), cr_deploy_r()

Examples


# create a local cloudbuild.yml file for packagetests
pd <- cr_deploy_packagetests(create_trigger = "no")
pd

# add a decryption step for an auth file
cr_deploy_packagetests(
  steps = cr_buildstep_secret("my_secret", "auth.json"),
  env = c("NOT_CRAN=true", "MY_AUTH_FILE=auth.json"),
  timeout = 1200,
  create_trigger = "no"
)


# creating a buildtrigger repo for trigger_repo
repo <- cr_buildtrigger_repo("MarkEdmondson1234/googleCloudRunner",
  branch = "master"
)
## Not run: 

# will create the file in the repo, and point a buildtrigger at it
cr_deploy_packagetests(create_trigger = "file", trigger_repo = repo)


# will make an inline build within a buildtrigger
cr_deploy_packagetests(create_trigger = "inline", trigger_repo = repo)

## End(Not run)

unlink("cloudbuild-tests.yml")

[Package googleCloudRunner version 0.5.0 Index]