In this vignette, we show how to use atime for continuous integration testing. We begin by cloning a github repository of an R package which already has atime CI code.
tdir <- tempfile()
dir.create(tdir)
git2r::clone("https://github.com/tdhock/binsegRcpp", tdir)
#> cloning into '/tmp/RtmpnyQdoR/file57a862d77c8'...
#> Receiving objects: 1% (13/1298), 24 kb
#> Receiving objects: 11% (143/1298), 64 kb
#> Receiving objects: 21% (273/1298), 88 kb
#> Receiving objects: 31% (403/1298), 112 kb
#> Receiving objects: 41% (533/1298), 128 kb
#> Receiving objects: 51% (662/1298), 152 kb
#> Receiving objects: 61% (792/1298), 184 kb
#> Receiving objects: 71% (922/1298), 184 kb
#> Receiving objects: 81% (1052/1298), 200 kb
#> Receiving objects: 91% (1182/1298), 240 kb
#> Receiving objects: 100% (1298/1298), 259 kb, done.
#> Local: master /tmp/RtmpnyQdoR/file57a862d77c8
#> Remote: master @ origin (https://github.com/tdhock/binsegRcpp)
#> Head: [977f385] 2022-08-24: rm rcppdeepstate yaml action
repo <- git2r::repository(tdir)
git2r::checkout(repo, branch="another-branch")
The code below is the atime test suite of the binsegRcpp package:
inst.atime <- file.path(tdir, "inst", "atime")
test.lines <- readLines(file.path(inst.atime, "tests.R"))
cat(test.lines, sep="\n")
#> test.list <- c(
#> atime::atime_grid(
#> list(DIST=c("l1", "poisson", "meanvar_norm")),
#> "binseg(1:N,maxSegs=N/2)"=list(
#> N=2^seq(2, 20),
#> setup={
#> max.segs <- as.integer(N/2)
#> data.vec <- 1:N
#> },
#> expr=binsegRcpp::binseg(DIST, data.vec, max.segs))),
#> atime::atime_grid(
#> "binseg_normal(1:N,maxSegs=N/2)"=list(
#> seconds.limit=0.1,
#> N=2^seq(2, 20),
#> setup={
#> max.segs <- as.integer(N/2)
#> data.vec <- 1:N
#> },
#> expr=binsegRcpp::binseg_normal(data.vec, max.segs))))
We can run the atime CI code in that package via:
result.list <- atime::atime_pkg(tdir)
#> Warning: Some expressions had a GC in every iteration; so filtering is
#> disabled.
tests.png <- file.path(inst.atime, "tests_all_facet.png")
knitr::include_graphics(tests.png)