r-lib/actions

allow "extra-packages when using setup-renv

Opened this issue · 0 comments

Hey everyone,

At work, I have a shiny app developed as a "golem" package that depends on another package called {mypackage}hosted on the workplace RSPM. I want to run my devtools::test() when I create a pull request to master branch.

"mypackage" appears in my DESCRIPTION and renv.lock files.
Also, the internal RSPM appears as the repo in my renv.lock file.

Right now, the approach I have found is to use

      - uses: r-lib/actions/setup-r-dependencies@v2
        env:
          RENV_CONFIG_REPOS_OVERRIDE: "https://packagemanager.rstudio.com/all/latest"
        with:
          cache-version: 2
          extra-packages: any::devtools, mypackage=?ignore

to use the public rspm in github runners and to skip {mypackage}
Then I just need to use testthat::skip_if_ci() to skip tests that rely on {mypackage}

This works, but it ends up using "random" package version.

I think a better approach (for me) would be to use setup-renv instead of setup-r-dependencies , but setup-r doesnt accept the extra-packages: any::devtools, mypackage=?ignore line.

here is my full yaml, in case it's useful:

name: R-CMD-check

on:
  pull_request:
    branches: [master]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: r-lib/actions/setup-r@v2
        with:
          r-version: 'renv' # Use "renv" to retrieve R version recorded in renv.lock file.
          use-public-rspm: true
      - uses: r-lib/actions/setup-r-dependencies@v2
        env:
          RENV_CONFIG_REPOS_OVERRIDE: "https://packagemanager.rstudio.com/all/latest"
        with:
          cache-version: 2
          extra-packages: any::devtools, mypackage=?ignore
      - name: Run tests
        env:
          R_COMPILE_AND_INSTALL_PACKAGES: never
        run: Rscript -e 'devtools::test()'