Skip to content

Commit

Permalink
Explicit handling of pak package cache for pak-enabled renv
Browse files Browse the repository at this point in the history
* r-lib/setup-renv only handles the pure renv cache, which is not relevant when renv uses pak to install packages.
* This is heavily inspired by the caching done in r-lib/setup-renv, and could be easily integrated there.
  • Loading branch information
riccardoporreca committed Jan 10, 2024
1 parent c40dc56 commit ad0b5a8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci-cd-renv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,26 @@ jobs:
# No RStudio Package Manager to respect renv.lock
use-public-rspm: false

# Handling the pak package cache for pak-enabled renv is not taken care of (yet)
# by r-lib/actions/setup-renv (or renv itself)
- name: Configure pak package cache
id: pak-cache
run: |
# Package cache used by pak
cat("R_PKG_CACHE_DIR=${{ runner.temp }}/pkgcache\n", file = Sys.getenv("GITHUB_ENV"), append = TRUE)
cache_version = 1
cat("os-version=", sessionInfo()$running, "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE)
cat("r-version=", R.Version()$version.string, "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE)
cat("cache-version=", cache_version, file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE)
shell: Rscript {0}

- name: Restore pak package cache
uses: actions/cache@v3
with:
path: ${{ env.R_PKG_CACHE_DIR }}
key: pak-${{ steps.pak-cache.outputs.os-version }}-${{ steps.pak-cache.outputs.r-version }}-${{ steps.pak-cache.outputs.cache-version }}-${{ hashFiles('renv.lock') }}
restore-keys: pak-${{ steps.pak-cache.outputs.os-version }}-${{ steps.pak-cache.outputs.r-version }}-${{ steps.pak-cache.outputs.cache-version }}-

- name: Activate renv and restore packages with cache
uses: r-lib/actions/setup-renv@v2

Expand Down

0 comments on commit ad0b5a8

Please sign in to comment.