R/deploy.R
cr_deploy_packagetests.Rd
This tests an R package each time you commit, and uploads the test coverage results to Codecov
cr_deploy_packagetests( steps = NULL, cloudbuild_file = "cloudbuild-tests.yml", env = c("NOT_CRAN=true"), test_script = NULL, codecov_script = NULL, codecov_token = "$_CODECOV", build_image = "gcr.io/gcer-public/packagetools:latest", create_trigger = c("file", "inline", "no"), trigger_repo = NULL, ... )
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 perform tests. If |
codecov_script | The script that will perform coverage. If |
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
|
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.
Create your own custom deployment using cr_buildstep_packagetests which this function uses with some defaults
Other Deployment functions:
cr_deploy_docker_trigger()
,
cr_deploy_docker()
,
cr_deploy_pkgdown()
,
cr_deploy_run_website()
,
cr_deploy_run()
,
cr_deploy_r()
# create a local cloudbuild.yml file for packagetests pd <- cr_deploy_packagetests(create_trigger = "no")#>#>#> ℹ Complete deployment of tests Cloud Build yaml:#> ● Go to https://console.cloud.google.com/cloud-build/triggers and #> #>#> ℹ Build Trigger substitution variable settings: #> #>pd#> ==cloudRunnerYaml== #> steps: #> - 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 #> - name: gcr.io/gcer-public/packagetools:latest #> args: #> - Rscript #> - -e #> - |- #> remotes::install_deps(dependencies = TRUE) #> remotes::install_local() #> cv <- covr::package_coverage() #> print(cv) #> covr::codecov(coverage=cv, commit = '$$COMMIT_SHA', branch = '$$BRANCH_NAME') #> env: #> - NOT_CRAN=true #> - CODECOV_TOKEN=$_CODECOV# 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" )#> ℹ 2021-03-19 12:27:07 > Writing to cloudbuild-tests.yml#>#> ℹ Complete deployment of tests Cloud Build yaml:#> ● Go to https://console.cloud.google.com/cloud-build/triggers and #> #>#> ℹ Build Trigger substitution variable settings: #> #>#> ==cloudRunnerYaml== #> steps: #> - name: gcr.io/cloud-builders/gcloud #> entrypoint: bash #> args: #> - -c #> - gcloud secrets versions access latest --secret=my_secret > auth.json #> - 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 #> - MY_AUTH_FILE=auth.json #> - name: gcr.io/gcer-public/packagetools:latest #> args: #> - Rscript #> - -e #> - |- #> remotes::install_deps(dependencies = TRUE) #> remotes::install_local() #> cv <- covr::package_coverage() #> print(cv) #> covr::codecov(coverage=cv, commit = '$$COMMIT_SHA', branch = '$$BRANCH_NAME') #> env: #> - NOT_CRAN=true #> - MY_AUTH_FILE=auth.json #> - CODECOV_TOKEN=$_CODECOV #> timeout: 1200s# creating a buildtrigger repo for trigger_repo repo <- cr_buildtrigger_repo("MarkEdmondson1234/googleCloudRunner", branch = "master") if (FALSE) { # 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) } unlink("cloudbuild-tests.yml")