我正在使用GitHub动作作为我的R包的CI。我正在尝试在包中同时使用testthat和shinytest。我已经根据shinytest文档正确地设置了包结构。当我在RStudio中运行RStudio时,我的包(包括testthat和shinytest测试都能工作)。
我的GitHub操作.yaml工作流是:
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
name: R-CMD-check
jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@v1
with:
r-version: ${{ matrix.config.r }}
- uses: r-lib/actions/setup-pandoc@v1
- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}
- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
- name: Install system dependencies
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}
- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}
- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check当我提交到存储库时,检查在Windows和Mac上失败,但在Ubuntu上工作。
我在Windows和Mac上遇到的错误是:
> test_check("mypackage")
-- 1. Error: application works (@test-appdir.R#6) -----------------------------
PhantomJS not found.我不认为这是我的包裹或测试的问题。我认为我的.yaml有错误的配置。如何在我的工作流中使用PhantomJS解决这个问题?
发布于 2020-11-01 15:53:27
简单的解决方案将是转到使用了PhantomJS的项目,并打开Github操作。我们将进入shiny项目,准确地说是:https://github.com/rstudio/shiny/blob/master/.github/workflows/R-CMD-check.yaml
我们可以在那里发现:
- name: Install system dependencies
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}
- name: Find PhantomJS path
id: phantomjs
run: |
echo "::set-output name=path::$(Rscript -e 'cat(shinytest:::phantom_paths()[[1]])')"
- name: Cache PhantomJS
uses: actions/cache@v1
with:
path: ${{ steps.phantomjs.outputs.path }}
key: ${{ runner.os }}-phantomjs
restore-keys: ${{ runner.os }}-phantomjs
- name: Install PhantomJS
run: >
Rscript
-e "if (!shinytest::dependenciesInstalled()) shinytest::installDependencies()"我们可以很容易地检查是否有单独的代码块,只是为了确保PhantomJS本地化是已知的,或者是否应该安装它。
您可以将这部分代码粘贴到yaml文件中。然而,最好的方法可能是遵循shiny项目的管道,
发布于 2020-10-29 14:57:54
如果没有详细的日志以及在Query dependencies步骤中安装了哪些依赖项(Query dependencies)的信息,就很难调查这个问题。似乎根本没有安装PhantomJS依赖项。工作流在ubuntu-20.04上成功,因为运行程序PhantomJS安装了开箱即用吗?。您可以看到在提供的运行程序类型这里上安装的所有软件。上面工作流中使用的其他运行程序类型(windows-latest和macOS-latest)缺少PhantomJS。这就是为什么您的工作流在Windows和MacOS上失败而在Ubuntu上成功的原因。
https://stackoverflow.com/questions/64491156
复制相似问题