knitr::opts_chunk$set(
  tidy = FALSE,
  error = FALSE,
  fig.width = 8,
  fig.height = 8)

buildr

A very simple minded build server, until r-hub is working. Don't use this for anything serious and use r-hub when it comes out because it's going to be way better.

Installation

Either

drat:::add("mrc-ide")
install.packages("buildr")

or with devtools

devtools::install_github("mrc-ide/buildr", upgrade=FALSE)

Using the client

You need the hostname of the build server, and the port if it is running on a non-default port. The simplest thing is to run:

res <- buildr::build_binaries("seagull_1.0.0.tar.gz", "localhost", port=9999L)
res

which will submit the package to server and poll until it builds or fails. By default the created binary file is copied into a temporary directory, but you can control this with the dest argument. If the build fails, the log will be printed along with an id (see below).

The argument to build can be a vector of filenames, in which case the packages will be built in order (so you can build a set of dependent packages).

More details

Create a connection to the buildr server

cl <- buildr::buildr_client("localhost", 9999L)

You can test the connection is OK:

cl$ping()

(this will hang, possibly forever, if it fails).

buildr:::buildr_http_client_response(httr::PATCH(file.path(cl$base_url, "reset")))

Submit a package. The package must be a path to a tar.gz file built with R CMD build or devtools::build (i.e., a source package). The filename will typically have an embedded version number.

id <- cl$submit("seagull_1.0.0.tar.gz")
id

The identifier is the md5 fingerprint of your source file, which you can also find with tools::md5sum:

tools::md5sum("seagull_1.0.0.tar.gz")

You can see source packages that the server knows about:

cl$packages()

To get the actual name of the source files, pass translate=TRUE:

cl$packages(translate=TRUE)

and request the status of the package you are building:

cl$status(id)

To block until a package has finished building, use wait:

filename <- cl$wait(id)
filename

The return value here is the filename where the binary has been copied to. You can also get this with:

cl$download(id)

(by default, both wait and download use a temporary directory but this is configurable with the dest argument).

The build log can be retrieved:

cl$log(id)

The packages() method has an argument binary that lists binary packages:

cl$packages(binary=TRUE)
cl$packages(binary=TRUE, translate=TRUE)

There is also an method installed that lists packages installed on the server

cl$installed()

If package versions are behind, you can get the server to upgrade everything with

cl$upgrade()

Server

The file inst/run.py file controlls the server. Running ./inst/run.py gives options:

writeLines(c("```", system2(c("inst/run.py", "--help"), stdout=TRUE), "```"))


richfitz/buildr documentation built on Nov. 22, 2019, 8:31 a.m.