簡體   English   中英

R 包的 Travis CI:找不到部署密鑰

[英]Travis CI for R packages: no deploy key found

我嘗試使用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 檢查在本地通過,沒有任何錯誤或警告。

對於您的設置,默認情況下pkgdown::deploy_site_github()在錯誤的位置查找 ssh 密鑰。 要手動修復此問題,請.travis.yaml像這樣修改.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

來源

我仍然不知道為什么我使用的代碼失敗了,因為它適用於tidyverse許多包。 但我最終讓它運行起來。

只需使用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 -------------------------------------------------------------

截至 2020 年 3 月,pkgdown 維護者的建議是完全避免通過 Travis 執行此操作,而是使用 Github Actions (來源)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM