1

我正在尝试从R 包运行use_github_action_check_standard()命令,以在每次推送 GitHub Actions 时检查我的包。usethis

该测试在 Windows 和 MacOS 上没有问题,但是对于这两个 Linux 版本,我的工作流代码甚至在到达包代码之前就失败了。

当它尝试安装给我错误的系统依赖项时失败##[error]Process completed with exit code 1

当我查看原始日志(如下)时,我注意到以下行: Cache not found for input keys: Linux-287c850eb370edd647ed85b6fac18cbaee02effa7d01b981304dce84a452b22c-1-, Linux--1-. 但恐怕我不明白那个错误。另外我不认为是这样,因为密钥##[endgroup]已经出现在上面的组中(注意 ),但错误只出现在下一组中(如屏幕截图所示)。

有任何想法吗?非常感谢!

我还在下面发布了我的整个工作流程代码。

截屏

在此处输入图像描述

原始日志

2020-08-12T22:21:55.5243116Z ##[group]Run install.packages('remotes')
2020-08-12T22:21:55.5243360Z [36;1minstall.packages('remotes')[0m
2020-08-12T22:21:55.5243487Z [36;1msaveRDS(remotes::dev_package_deps(dependencies = TRUE), "../.github/depends.Rds", version = 2)[0m
2020-08-12T22:21:55.5243834Z [36;1mwriteLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), "../.github/R-version")[0m
2020-08-12T22:21:55.5250702Z shell: /usr/local/bin/Rscript {0}
2020-08-12T22:21:55.5251247Z env:
2020-08-12T22:21:55.5251370Z   R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
2020-08-12T22:21:55.5251571Z   RSPM: https://packagemanager.rstudio.com/cran/__linux__/focal/latest
2020-08-12T22:21:55.5251726Z   R_LIBS_USER: /home/runner/work/_temp/Library
2020-08-12T22:21:55.5251838Z   TZ: UTC
2020-08-12T22:21:55.5251944Z   NOT_CRAN: true
2020-08-12T22:21:55.5252036Z ##[endgroup]
2020-08-12T22:21:55.7245517Z Installing package into ‘/home/runner/work/_temp/Library’
2020-08-12T22:21:55.7246358Z (as ‘lib’ is unspecified)
2020-08-12T22:22:10.8252493Z trying URL 'https://packagemanager.rstudio.com/cran/__linux__/focal/latest/src/contrib/remotes_2.2.0.tar.gz'
2020-08-12T22:22:11.4785067Z Content type 'binary/octet-stream' length 385906 bytes (376 KB)
2020-08-12T22:22:11.4972702Z ==================================================
2020-08-12T22:22:11.4973457Z downloaded 376 KB
2020-08-12T22:22:11.4973749Z 
2020-08-12T22:22:11.7705424Z * installing *binary* package ‘remotes’ ...
2020-08-12T22:22:11.7751638Z * DONE (remotes)
2020-08-12T22:22:11.7952384Z 
2020-08-12T22:22:11.7953131Z The downloaded source packages are in
2020-08-12T22:22:11.7954176Z    ‘/tmp/RtmpnMfdtp/downloaded_packages’
2020-08-12T22:22:28.2516191Z ##[group]Run actions/cache@v1
2020-08-12T22:22:28.2516310Z with:
2020-08-12T22:22:28.2516416Z   path: /home/runner/work/_temp/Library
2020-08-12T22:22:28.2516545Z   key: Linux-287c850eb370edd647ed85b6fac18cbaee02effa7d01b981304dce84a452b22c-1-
2020-08-12T22:22:28.2516663Z   restore-keys: Linux--1-
2020-08-12T22:22:28.2516765Z env:
2020-08-12T22:22:28.2516865Z   R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
2020-08-12T22:22:28.2517041Z   RSPM: https://packagemanager.rstudio.com/cran/__linux__/focal/latest
2020-08-12T22:22:28.2517180Z   R_LIBS_USER: /home/runner/work/_temp/Library
2020-08-12T22:22:28.2517288Z   TZ: UTC
2020-08-12T22:22:28.2517383Z   NOT_CRAN: true
2020-08-12T22:22:28.2517481Z ##[endgroup]
2020-08-12T22:22:28.3670558Z Cache not found for input keys: Linux-287c850eb370edd647ed85b6fac18cbaee02effa7d01b981304dce84a452b22c-1-, Linux--1-.
2020-08-12T22:22:28.3750527Z ##[group]Run while read -r cmd
2020-08-12T22:22:28.3750930Z [36;1mwhile read -r cmd[0m
2020-08-12T22:22:28.3751045Z [36;1mdo[0m
2020-08-12T22:22:28.3751155Z [36;1m  eval sudo $cmd[0m
2020-08-12T22:22:28.3751285Z [36;1mdone < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')[0m
2020-08-12T22:22:28.3792540Z shell: /usr/bin/bash -e {0}
2020-08-12T22:22:28.3792673Z env:
2020-08-12T22:22:28.3792794Z   R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
2020-08-12T22:22:28.3792990Z   RSPM: https://packagemanager.rstudio.com/cran/__linux__/focal/latest
2020-08-12T22:22:28.3793151Z   R_LIBS_USER: /home/runner/work/_temp/Library
2020-08-12T22:22:28.3793268Z   TZ: UTC
2020-08-12T22:22:28.3793377Z   NOT_CRAN: true
2020-08-12T22:22:28.3793480Z ##[endgroup]
2020-08-12T22:22:29.0943838Z usage: sudo -h | -K | -k | -V
2020-08-12T22:22:29.0944936Z usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
2020-08-12T22:22:29.0945856Z usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user]
2020-08-12T22:22:29.0946223Z             [command]
2020-08-12T22:22:29.0947040Z usage: sudo [-AbEHknPS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
2020-08-12T22:22:29.0947710Z             prompt] [-T timeout] [-u user] [VAR=value] [-i|-s] [<command>]
2020-08-12T22:22:29.0948381Z usage: sudo -e [-AknS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
2020-08-12T22:22:29.0948992Z             prompt] [-T timeout] [-u user] file ...
2020-08-12T22:22:29.0956330Z ##[error]Process completed with exit code 1.

工作流程代码:

# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - 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 }}
    
   defaults:
      run:
        working-directory: myfunctionname
    steps:
      - uses: actions/checkout@v2

      - uses: r-lib/actions/setup-r@master
        with:
          r-version: ${{ matrix.config.r }}

      - uses: r-lib/actions/setup-pandoc@master

      - 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@v1
        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 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')
      - 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
4

1 回答 1

5

我最终想通了,但将其留在这里,因为它可能对其他人有用!

该错误与命令中的 R 代码相关联,因此如果您也遇到这种情况,请关注代码的 R 部分而不是工作流代码。

run: |
   while read -r cmd
        do
          eval sudo $cmd
        done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')

正如我在上面的工作目录中指定的那样,我的包位于myfunctionname我的 GitHub 帐户的子目录中:

defaults:
      run:
        working-directory: myfunctionname

这意味着 R 函数remotes::system_requirements("ubuntu", "20.04")在指定文件夹中找不到包。一旦我通过简单地添加信息: remotes::system_requirements("ubuntu", "20.04","myfunctionname")一切正常。

于 2020-08-16T22:56:15.697 回答