Writes a ready-to-use GitHub Actions workflow that runs your package's
testthat tests, including image snapshot tests, with odiff. The workflow
installs odiff with install_odiff() (no Node.js needed), adds a
snapshot_report() summary of changed image snapshots to the job summary
and, when tests fail, uploads the new snapshots (*.new.png) and diff
images (tests/testthat/_odiffr/) as an artifact.
Arguments
- path
Path of the workflow file, relative to the working directory (which should be the root of your package). Default:
".github/workflows/odiffr.yaml". Parent directories are created as needed.- overwrite
Logical; if
TRUE, replace an existing file atpath. Default isFALSE, in which case an existing file is an error.- open
Logical; if
TRUEand the session is interactive, open the new file withutils::file.edit(). Default isFALSE.
Details
The workflow is written only when you call this function; odiffr never
writes it by itself. It runs on every push and pull request on
ubuntu-latest, so record image snapshots on Linux or use a tolerant
preset (see odiff_preset()). The template is installed with odiffr, see
system.file("templates", "odiffr-ci.yaml", package = "odiffr"); edit
the written file as needed.
The tests run with NOT_CRAN=true, as snapshot tests are skipped on CRAN.
Examples
if (FALSE) { # \dontrun{
# From the root of your package
use_odiffr_ci()
} # }
# In a temporary directory
dir <- tempfile()
dir.create(dir)
path <- use_odiffr_ci(file.path(dir, ".github", "workflows", "odiffr.yaml"))
#> Wrote GitHub Actions workflow: /tmp/RtmpIaIBy0/file1cd16449a903/.github/workflows/odiffr.yaml
#> Next steps:
#> - Commit it and push to GitHub to run your tests with odiff.
#> - Commit your image snapshots (tests/testthat/_snaps/), recorded on Linux or with a tolerant preset.
#> - Changed snapshots are listed in the job summary and uploaded as the 'image-snapshots' artifact.
unlink(dir, recursive = TRUE)
