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()
returns
> 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_TRAVIS
和 R_TRAVIS_ORG
变量在 .Renviron
中指定。 R CMD 检查在本地通过,没有任何错误或警告。
我仍然不知道为什么我使用的代码失败了,因为它适用于 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 -------------------------------------------------------------
对于您的设置,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
截至 2020 年 3 月,pkgdown 维护者的建议是完全避免通过 Travis 执行此操作,而是使用 Github 操作 (source).
我尝试设置一个带有 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()
returns
> 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_TRAVIS
和 R_TRAVIS_ORG
变量在 .Renviron
中指定。 R CMD 检查在本地通过,没有任何错误或警告。
我仍然不知道为什么我使用的代码失败了,因为它适用于 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 -------------------------------------------------------------
对于您的设置,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
截至 2020 年 3 月,pkgdown 维护者的建议是完全避免通过 Travis 执行此操作,而是使用 Github 操作 (source).