This lets you run R package tests and is intended to be used in a trigger when you push to a repository so you can monitor code quality.

cr_buildstep_packagetests(
  test_script = NULL,
  codecov_script = NULL,
  codecov_token = "$_CODECOV_TOKEN",
  build_image = "gcr.io/gcer-public/packagetools:latest",
  env = c("NOT_CRAN=true")
)

Arguments

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

env

Environment arguments to be set during the test script runs

Details

If using codecov, these environment arguments are added to aid with the codecoverage:

* "CODECOV_TOKEN=$_CODECOV_TOKEN" * "GCB_PROJECT_ID=$PROJECT_ID" * "GCB_BUILD_ID=$BUILD_ID" * "GCB_COMMIT_SHA=$COMMIT_SHA" * "GCB_REPO_NAME=$REPO_NAME" * "GCB_BRANCH_NAME=$BRANCH_NAME" * "GCB_TAG_NAME=$TAG_NAME" * "GCB_HEAD_BRANCH=$_HEAD_BRANCH" * "GCB_BASE_BRANCH=$_BASE_BRANCH" * "GCB_HEAD_REPO_URL=$_HEAD_REPO_URL" * "GCB_PR_NUMBER=$_PR_NUMBER"

Examples


cr_buildstep_packagetests()
#> [[1]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/gcer-public/packagetools:latest
#> args:
#> - Rscript
#> - -e
#> - |-
#>   message("cran mirror: ", getOption("repos"))
#>   remotes::install_deps(dependencies = TRUE)
#>   rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "warning")
#> env:
#> - NOT_CRAN=true
#> 
#> [[2]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/gcer-public/packagetools:latest
#> args:
#> - Rscript
#> - -e
#> - |-
#>   remotes::install_deps(dependencies = TRUE)
#>   remotes::install_local()
#>   cv <- covr::package_coverage()
#>   up <- covr::codecov(coverage = cv,
#>                 commit = "$COMMIT_SHA", branch = "$BRANCH_NAME",
#>                 quiet = FALSE)
#>   up
#>   if (!up$uploaded) stop("Error uploading codecov reports")
#> env:
#> - NOT_CRAN=true
#> - CODECOV_TOKEN=$_CODECOV_TOKEN
#> - CI=true
#> - GCB_PROJECT_ID=$PROJECT_ID
#> - GCB_BUILD_ID=$BUILD_ID
#> - GCB_COMMIT_SHA=$COMMIT_SHA
#> - GCB_REPO_NAME=$REPO_NAME
#> - GCB_BRANCH_NAME=$BRANCH_NAME
#> - GCB_TAG_NAME=$TAG_NAME
#> - GCB_HEAD_BRANCH=$_HEAD_BRANCH
#> - GCB_BASE_BRANCH=$_BASE_BRANCH
#> - GCB_HEAD_REPO_URL=$_HEAD_REPO_URL
#> - GCB_PR_NUMBER=$_PR_NUMBER
#>