Learn R Programming

googleCloudRunner (version 0.2.0)

cr_deploy_packagetests: 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:master",
  ...
)

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

env

Environment arguments to be set during the test script runs

test_script

The script that will run first making tests. If NULL a default script it used

codecov_script

The script that will run first making tests. If NULL a default script it used

codecov_token

If using codecov, supply your codecov token here. Default assumes you add it to the Cloud Build substitution macros, which is more secure and recommended.

build_image

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

...

Other arguments passed to cr_build_make

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_decrypt 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

Other Deployment functions: cr_deploy_docker(), cr_deploy_git_html(), cr_deploy_github_docker(), cr_deploy_pkgdown(), cr_deploy_run(), cr_deploy_r()

Examples

Run this code
# NOT RUN {
pd <- cr_deploy_packagetests()
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
)

unlink("cloudbuild-tests.yml")

# }

Run the code above in your browser using DataLab