2

我尝试设置一个带有pkgdown网站的 R 包,我想将其连接到 Travis CI。我是特拉维斯的新手,我不知道为什么它仍然因错误按摩而失败

Deploying application
Error: No deploy key found, please setup with `travis::use_travis_deploy()`
Execution halted
Script failed with status 1
failed to deploy

travis::use_travis_deploy()在 RStudio 中执行调用返回

> travis::use_travis_deploy()
i Querying Github deploy keys from repo.
i Getting environment variables for `j3ypi/inductive` on Travis CI.
> Deploy keys for Travis CI (`.org`) already present. No action required.

表明一切都像它应该的那样。当 Travis CI 设置环境变量时,它甚至会说

Setting environment variables from repository settings
$ export TRAVIS_DEPLOY_KEY=[secure]
$ export GITHUB_PAT=[secure]

对于.travis.yml我面向dplyr包之一的文件。看起来像这样

# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r

language: r
os: linux
dist: trusty
cache: packages
latex: false

jobs:
  include:
    before_cache: Rscript -e 'remotes::install_cran("pkgdown")'
    deploy:
      provider: script
      script: Rscript -e 'pkgdown::deploy_site_github()'
      skip_cleanup: true
      github-token: $GITHUB_PAT

env:
  global:
  - _R_CHECK_FORCE_SUGGESTS_=false
  - MAKEFLAGS="-j 2"
  - TRAVIS_CXXFLAGS="-Wall -Wextra -pedantic -Werror"
  - R_REMOTES_NO_ERRORS_FROM_WARNINGS=true
  - _R_CHECK_SYSTEM_CLOCK_=FALSE

有人有想法吗?奇怪的是,Github 上的部署密钥说它从未被使用过。GITHUB_PAT和变量在R_TRAVISR_TRAVIS_ORG指定.Renviron。R CMD 检查在本地通过,没有任何错误或警告。

4

3 回答 3

2

对于您的设置,pkgdown::deploy_site_github()默认情况下会在错误位置查找 ssh 密钥。要手动修复此问题pkgdown::deploy_site_github(),请通过如下方式修改您的 ssh 密钥.travis.yaml

deploy:
  provider: script
  script: Rscript -e 'pkgdown::deploy_site_github(ssh_id = Sys.getenv("TRAVIS_DEPLOY_KEY", ""))'
  skip_cleanup: true

资源

于 2020-02-05T11:04:56.890 回答
1

我仍然不知道为什么我使用的代码失败了,因为它适用于tidyverse. 但我最终让它运行起来。

只需tic::use_tic()tic包中使用,它将.travis.yml正确设置您的文件。该.travis.yml文件将类似于以下内容:

# tic documentation: https://docs.ropensci.org/tic/dev/

# OS ---------------------------------------------------------------------------
os: linux
dist: bionic

# meta -------------------------------------------------------------------------
language: r
cache:
  - packages
  - ccache
latex: false

# multiple R versions ----------------------------------------------------------
matrix:
  include:
  - r: devel
  - r: oldrel
  - r: release
    env:
    - BUILD_PKGDOWN=true

# Stages -----------------------------------------------------------------------

before_install:
  - if [ "${TRAVIS_OS_NAME}" == "osx" ]; then brew install ccache; fi
  - if [ "${TRAVIS_OS_NAME}" == "osx" ]; then export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi
  - echo -e "options(Ncpus = 8, repos = structure(c(CRAN = 'https://cloud.r-project.org/')))" > $HOME/.Rprofile
  - mkdir -p $HOME/.R && echo -e 'CXX_STD = CXX14\n\nCC=ccache gcc -std=gnu99\nCXX=ccache g++\nCXX11=ccache g++ -std=gnu99\nCXX14=ccache g++ -std=gnu99\nC11=ccache g++\nC14=ccache g++\nFC=ccache gfortran\nF77=ccache gfortran' > $HOME/.R/Makevars
  - mkdir -p $HOME/.ccache && echo -e 'max_size = 5.0G\nsloppiness = include_file_ctime\nhash_dir=false' > $HOME/.ccache/ccache.conf
  - R -q -e 'if (!requireNamespace("remotes")) install.packages("remotes")'
  - R -q -e 'if (getRversion() < "3.2" && !requireNamespace("curl")) install.packages("curl")'
  - R -q -e 'remotes::install_github("ropensci/tic", upgrade = "always"); print(tic::dsl_load()); tic::prepare_all_stages()'
  - R -q -e 'tic::before_install()'
install:
  - R -q -e 'tic::install()'
before_script: R -q -e 'tic::before_script()'
script: R -q -e 'tic::script()'
after_success: R -q -e 'tic::after_success()'
after_failure: R -q -e 'tic::after_failure()'
before_deploy: R -q -e 'tic::before_deploy()'
deploy:
  provider: script
  script: R -q -e 'tic::deploy()'
  on:
    all_branches: true
after_deploy: R -q -e 'tic::after_deploy()'
after_script: R -q -e 'tic::after_script()'

# Custom user code -------------------------------------------------------------

于 2020-02-02T14:01:33.660 回答
1

截至 2020 年 3 月,pkgdown 维护者的建议是完全避免通过 Travis 执行此操作,而改用 Github Actions (来源)

于 2020-05-01T19:50:11.263 回答