vignettes/usecase-testthat-coverage.Rmd
usecase-testthat-coverage.Rmd
This workflow will run the package tests you have upon each commit to your git repo.
You can also optionally submit those test results to codecov via the excellent covr R package, helping you see which code your tests actually test. This is what creates this badge for this package:
If you do not need online authentication for your tests, then this is only a case of deploying the premade default cloudbuild.yml file via cr_deploy_packagetests()
.
The below assumes you have created tests for your package.
cr_deploy_packagetests()
docs/**
folder where changes should not trigger a recheck_CODECOV_TOKEN
if you are using itThe below is an example for googleCloudRunner
’s website:
The example above also adds other substitution variables to help run some of the examples.
You can customise the deployment more by using cr_buildstep_packagetests()
in your own custom build files.
For googleCloudRunner
and API packages in general, an authentication key is needed to run online tests. This authentication key can be encrypted via Google Secret Manager by adding a decryption step to your tests via cr_buildstep_secret()
- its usually only a case of uploading your auth file:
In that case, the decryption step needs to occur before the tests run, which you can do by supplying cr_buildstep_secret()
to cr_deploy_packagetests()
.
You will also want to use that auth file somehow, in the below example it is placed in an environment argument that your tests use to find the authentication file:
cr_deploy_packagetests(
steps = cr_buildstep_secret("my_secret", "auth.json"),
env = c("NOT_CRAN=true", "MY_AUTH_FILE=auth.json")
)
Use the resulting cloudbuild.yml file in the same manner as unauthenticated tests.