【问题标题】:Travis CI for R packages: no deploy key foundR 包的 Travis CI:找不到部署密钥
【发布时间】:2020-05-14 23:28:12
【问题描述】:

我尝试使用 pkgdown 网站设置 R 包,我想将其连接到 Travis CI。我是 Travis 的新手,我不知道为什么它仍然因错误消息而失败

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

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

> 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_PATR_TRAVISR_TRAVIS_ORG 变量在 .Renviron 中指定。 R CMD 检查在本地通过,没有任何错误或警告。

【问题讨论】:

    标签: r travis-ci pkgdown


    【解决方案1】:

    对于您的设置,pkgdown::deploy_site_github() 默认会在错误位置查找 ssh 密钥。要手动解决此问题,请通过修改您的 .travis.yaml 来告诉 pkgdown::deploy_site_github() 在哪里查找 ssh 密钥,如下所示:

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

    source

    【讨论】:

      【解决方案2】:

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

      只需使用tic 包中的tic::use_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 -------------------------------------------------------------
      
      

      【讨论】:

        【解决方案3】:

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2018-01-16
          • 2019-12-28
          • 2020-07-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-04-21
          • 1970-01-01
          相关资源
          最近更新 更多