From 5677c02589c67543ae1379fab62d6036ba3c5372 Mon Sep 17 00:00:00 2001 From: Riccardo Porreca Date: Mon, 15 Jan 2024 11:10:12 +0100 Subject: [PATCH] Use pak to ensure system requirements for all packages in `renv.lock` --- .github/workflows/ci-cd-renv.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci-cd-renv.yml b/.github/workflows/ci-cd-renv.yml index 29162ee..6614855 100644 --- a/.github/workflows/ci-cd-renv.yml +++ b/.github/workflows/ci-cd-renv.yml @@ -46,20 +46,21 @@ jobs: # No RStudio Package Manager to respect renv.lock use-public-rspm: false - - name: Install system dependencies - # This is not taken care of (yet) by r-lib/actions/setup-renv - # We need the development version of remotes to support Ubuntu 22.04 and - # for querying system requirements for multiple pkgs (r-lib/remotes#665) + # System dependencies are not taken care of (yet) by r-lib/actions/setup-renv + # We rely on pak and explicitly install them for the renv.lock packages # We could use pak-based installation for renv, which includes system # requirements, but would have to handle the pak cache explicitly # See https://github.com/r-lib/actions/issues/785 - run: | - Rscript -e "install.packages(c('remotes', 'distro', 'jsonlite'))" - Rscript -e "remotes::install_github('r-lib/remotes')" - while read -r cmd - do - eval sudo $cmd - done < <(Rscript -e 'writeLines(with(distro::distro(), remotes::system_requirements(id, short_version, package = names(jsonlite::read_json("renv.lock")$Packages))))') + - name: Setup pak to install system dependencies + uses: r-lib/actions/setup-r-dependencies@v2 + with: + packages: jsonlite + dependencies: NA + cache-version: 'sysreqs-1' # to exclude caches with the renv cache + + - name: Install system dependencies + run: pak::sysreqs_fix_installed(names(jsonlite::read_json("renv.lock")$Packages)) + shell: Rscript {0} - name: Activate renv and restore packages with cache uses: r-lib/actions/setup-renv@v2