简体   繁体   English

如何为非包装代码设置Travis?

[英]How do I set up Travis for non-package code?

I would like to set up Travis CI for an R project hosted on Github that isn't a package . 我想为在Github上托管的R项目设置Travis CI,这不是一个包 Unfortunately, the official R Travis support seems to be pretty hard-wired to packages (which, to be fair, makes sense). 不幸的是,官方的R Travis支持似乎与包裹相当硬(这是公平的,有道理)。

Is there any chance to get this working for non-package code, or is my only recourse to branch r-travis and patch it according to my specifications? 有没有机会让这个工作非包装代码,或者是我唯一的求助分支r-travis并根据我的规格进行修补? I don't feel competent enough to do this easily. 我觉得很难做到这一点很容易。

Here's my failing Travis configuration: 这是我失败的Travis配置:

language: R

r_github_packages:
    - klmr/modules

r_binary_packages:
    - testthat

script: make test

This fails with the following error: 此操作失败,并显示以下错误:

The command "Rscript -e 'deps <- devtools::install_deps(dependencies = TRUE);if (!all(deps %in% installed.packages())) { message("missing: ", paste(setdiff(deps, installed.packages()), collapse=", ")); q(status = 1, save = "no")}'" failed and exited with 1 during . 命令"Rscript -e 'deps <- devtools::install_deps(dependencies = TRUE);if (!all(deps %in% installed.packages())) { message("missing: ", paste(setdiff(deps, installed.packages()), collapse=", ")); q(status = 1, save = "no")}'"失败并在1期间退出1。

This makes sense: devtools::install_deps only works in the context of a package. 这是有道理的: devtools::install_deps仅适用于包的上下文。

I've tried suppressing the installation step, by adding install: true to my configuration. 我已经尝试通过在我的配置中添加install: true来抑制安装步骤。 However, now the dependencies are no longer installed, and the build consequently fails with 但是,现在不再安装依赖项,因此构建失败了

Error in loadNamespace(name) : there is no package called 'modules' loadNamespace(name)出错:没有名为'modules'的包

It turns out that a naïve approach is fairly easy; 事实证明,一种天真的方法相当容易; the following ( complete .travis.yml ) works for my purposes: 以下( 完整的 .travis.yml )适用于我的目的:

language: R

install:
    - Rscript -e 'install.packages(c("devtools", "testthat"))'
    - Rscript -e 'devtools::install_github("klmr/modules")'

script: make test

However, I'd still prefer a solution that can actually use the Travis declarations ( r_binary_packages , etc.) instead of having to install dependencies manually. 但是,我仍然更喜欢可以实际使用Travis声明( r_binary_packages等)的解决方案,而不必手动安装依赖项。

I was looking for an even more basic setup to get started. 我正在寻找一个更基本的设置来开始。 Here is what worked well for me. 这对我来说效果很好。

  • .travis.yml : .travis.yml

     language: r install: - Rscript install_packages.R script: - Rscript testthat.R 
  • install_packages.R : install_packages.R

     install.packages('testthat') 
  • testthat.R : testthat.R

     library(testthat) test_that('blabla', { expect_equal(1+2, 3) }) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM