This is a solution for continuous integration for R projects on Windows, using AppVeyor -- a CI testing service similar to Travis-CI. Under the hood, r-travis is used to perform the testing; this works even on Windows thanks to MinGW and MSYS.
- Sign up to AppVeyor.
- Enable testing for your project.
usethis::use_appveyor()in your project.
- (Optional) Adapt
appveyor.ymlto your needs according to the documentation.
- (Optional) Add a badge as described by the output of
- Be sure to supply a
.gitattributesfile that takes care of fixing CRLF conversion settings that are relevant on Windows. The one in this repo can be used for starters.
- Push to your repo to start building.
Build and test commands
environment: VARIABLE: value
R_VERSION: The version of R to be used for testing. Specify
oldrel, or a version number.
R_ARCH: The architecture to be used for testing, one of
RTOOLS_VERSION: The version of Rtools to be used for testing, defaults to the most recent Rtools. Specify e.g.
33for Rtools 3.3.
USE_RTOOLS: yes) if Rtools needs to be installed. Defaults to
trueif your package has a
falseotherwise. Rtools may be needed if you use
install_github(), if there are packages in
DESCRIPTIONfile, or if one of your dependencies has updated, but the associated Windows binary is not yet available from CRAN. (Set
PKGTYPE=binaryto avoid installing packages from source.)
GCC_PATH: The path to GCC in the Rtools installation, currently one of
WARNINGS_ARE_ERRORS: Set to 1 to treat all warnings as errors, otherwise leave empty.
CRAN: The CRAN mirror to use, defaults to RStudio's CDN via HTTPS. Change to HTTP for R 3.1.3 or earlier.
R_BUILD_ARGS: Arguments passed to
R CMD build, defaults to
R_CHECK_ARGS: Arguments passed to
R CMD check, defaults to
PKGTYPE: Passed as
remotes::install_deps(). Set to
bothto install packages from source if the source version is more recent than the binary version.
NOT_CRAN: Set this to
trueif you are using testthat and want to run tests marked with
R_REMOTES_STANDALONE: Set this to
trueif builds are failing due to the inability to update infrastructure packages such as curl, git2r and rlang. Read more in the docs for the remotes package.
_R_CHECK_FORCE_SUGGESTS_: Set this to
falseto avoid errors of the form "Package suggested but not available".
KEEP_VIGNETTES: Set this to a nonempty value build vignettes. You will likely need LaTeX and/or Pandoc, see below for installation instructions. By default, all vignettes are purged and the
DOWNLOAD_FILE_METHOD: On some versions of R, setting this to
wininetappears to work better than the default
In contrast to Travis-CI, AppVeyor offers facilities for hosting artifacts. This can be configured by adding a section to the
appveyor.yml. The sample file is configured to deploy logs, and source and binary versions of the built package. Check the "ARTIFACTS" section for your project at AppVeyor.
Pandoc and other software
before_test: - cinst pandoc - ps: $env:Path += ";C:\Program Files (x86)\Pandoc\" - pandoc -v
Using a 64-bit R installation
Some R packages, notably
rJava, require a 64-bit installation of
Windows and R. If you try to install these packages on a 32-bit
system you'll see a message similar to:
Error: .onLoad failed in loadNamespace() for 'rJava', details: call: inDL(x, as.logical(local), as.logical(now), ...) error: unable to load shared object 'C:/Users/appveyor/AppData/Local/Temp/1/RtmpWa3KNC/RLIBS_bdc2913935/rJava/libs/i386/rJava.dll': LoadLibrary failure: %1 is not a valid Win32 application.
To solve this problem, add to your
platform: x64 environment: R_ARCH: x64
This will cause Appveyor to run your build on a 64-bit version of Windows Server, using the 64-bit R binary.
This wouldn't have been as easy without r-travis and the experience gained there. Thanks!
The win-builder project has been around much longer and provides more comprehensive testing; you still might want to use this service before submitting to CRAN.
master-fail branch, failure expected)
MIT © Kirill Müller.