使用 Packrat 和 AppVeyor 构建 R 包

Building R packages with Packrat and AppVeyor

有人可以向我指出一个 packrat is used with AppVeyor 构建 R 包的工作示例吗?搜索 Google 和 GitHub,我找不到任何使用 AppVeyor 的 packrat-enable 包。

appveyor.yml 文件是否需要更改?我需要通过 AppVeyor 网站添加一些设置吗?

我有一个非常小的包(testthat 是唯一的依赖项)破坏了 AppVeyor 构建。这是 code frozen for that commit. Here is the AppVeyor log.

(如果这个 SO 问题听起来很熟悉,我即将 ask a similar question for Travis-CI。)

是的,这里的解决方法和类似。

这里有一个 appveyor.yml 文件的例子,它可以让你在你的包中使用 packrat 包:

# DO NOT CHANGE the "init" and "install" sections below

# Download script file from GitHub
init:
  ps: |
        $ErrorActionPreference = "Stop"
        Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1"
        Import-Module '..\appveyor-tool.ps1'
install:
  ps: Bootstrap

# Adapt as necessary starting from here

environment:
  global:
   WARNINGS_ARE_ERRORS: 0
   USE_RTOOLS: true

build_script:
  - R -e  "0" --args --bootstrap-packrat

test_script:
  - travis-tool.sh run_tests

on_failure:
  - 7z a failure.zip *.Rcheck\*
  - appveyor PushArtifact failure.zip

artifacts:
  - path: '*.Rcheck\**\*.log'
    name: Logs

  - path: '*.Rcheck\**\*.out'
    name: Logs

  - path: '*.Rcheck\**\*.fail'
    name: Logs

  - path: '*.Rcheck\**\*.Rout'
    name: Logs

  - path: '\*_*.tar.gz'
    name: Bits

  - path: '\*_*.zip'
    name: Bits

the template不同的重要部分是:

 environment:
      global:
       WARNINGS_ARE_ERRORS: 0
       USE_RTOOLS: true

    build_script:
      - R -e  "0" --args --bootstrap-packrat

这会为构建启用 Rtools,并加载 packrat 包。

同样重要的是要注意我们将 - travis-tool.sh install_deps 排除在外,因为这会导致您依赖的包从 CRAN 下载,而不是从您的 packrat 目录构建。

这是一个简单的 R 包的 appveyor 构建示例,它正在运行:https://ci.appveyor.com/project/benmarwick/javaonappveyortest/build/1.0.21