Skip to content

feat(ci): install R dependencies from renv.lock via setup-renv - #321

Merged
ShixiangWang merged 2 commits into
mainfrom
ci/renv-stage2
Oct 10, 2026
Merged

ShixiangWang merged 2 commits into
mainfrom
ci/renv-stage2

Conversation

@ShixiangWang

Copy link
Copy Markdown
Member

B1 stage 2 — render workflows switch to renv.lock installs

Part of the CI acceleration tracked in #306 (stage 1: #320 added renv.lock; this PR wires the render workflows to it).

What changes

All three render workflows (quarto-publish.yml, quarto-publish-update-cache.yml, ci-benchmark.yml) switch from r-lib/actions/setup-r-dependencies@v2 to r-lib/actions/setup-renv@v2:

  • Cache keyed on renv.lock hash — an unchanged lockfile restores the whole ~650-package library in minutes instead of ~26 min of pak resolution + install (measured baseline: r_deps = 162 s on the warm path, but full cold installs hit 26 min; restore-hit path is the big win).
  • Repinned GitHub packages take effect automatically — a changed pin changes the lockfile hash, so renv::restore() reinstalls it. This removes the "Drop cached babelquarto" workaround from all three workflows.
  • System requirements preserved — the old PKG_SYSREQS: "true" job is replaced by explicit apt packages (libudunits2-dev, libglpk-dev added to the existing libcurl4-openssl-dev line) plus a pak::pkg_sysreqs("deps::.") step that executes the returned install scripts for the full dependency closure.
  • Scan-added dependencies covered — after update-dependencies.R appends QMD-discovered install-call packages to DESCRIPTION, a delta step probes loadability and pak-installs anything the lockfile restore missed (no-op on a typical run).
  • renv sandbox disabled on ephemeral runners, matching generate-renv-lock.yml.

Verification plan

  • YAML validated locally (all three parse; step order confirmed)
  • PR pull_request render run goes green
  • ci-benchmark.yml dispatched after merge; r_deps phase drops toward restore-hit times

🤖 Generated with Claude Code

Switch all three render workflows (quarto-publish, quarto-publish-update-
cache, ci-benchmark) from setup-r-dependencies to r-lib/actions/setup-renv
(issue #306, B1 stage 2):

- setup-renv restores the renv.lock-pinned library with its package cache
  keyed on the lockfile hash: an unchanged lockfile restores in minutes
  instead of ~26 min of pak resolution + install; a changed lockfile only
  pays the delta via restore-keys.
- Drop the "Drop cached babelquarto" workaround: a repinned GitHub package
  changes the lockfile hash, so renv::restore() reinstalls it naturally.
- Replace PKG_SYSREQS=true with explicit apt packages (libudunits2-dev,
  libglpk-dev added) plus a pak::pkg_sysreqs() step that runs the returned
  install scripts, covering the full dependency closure.
- Delta-install QMD-scan-added packages after update-dependencies.R: the
  scan can append imports newer than renv.lock, so probe loadability and
  pak-install anything missing before rendering.
- Disable renv's install sandbox on ephemeral runners (same as
  generate-renv-lock.yml).

Co-Authored-By: Claude Code <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ QMD Format Check

No new QMD tutorial files to check.

Automated check by the PR Review workflow.
See contribution guidance for the expected tutorial format.

PR #321's first run failed inside renv::restore(): rsvg load-tested at
install time with 'librsvg-2.so.2: cannot open shared object file' —
the pak pkg_sysreqs() step ran after setup-renv, so the system library
arrived too late (and pak itself was not installed before restore).

Move the sysreqs step before setup-renv (bootstrapping pak from PPM as
a fast binary), and add librsvg2-dev to the explicit apt list as
defense-in-depth.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ QMD Format Check

No new QMD tutorial files to check.

Automated check by the PR Review workflow.
See contribution guidance for the expected tutorial format.

@ShixiangWang

Copy link
Copy Markdown
Member Author

Fixed the first-run failure (run 38069996992): renv::restore() load-tests every package at install time, and rsvg died on missing librsvg-2.so.2 because the pak sysreqs step ran after setup-renv (and pak itself wasn't installed before restore). Fix in 5a1372f: sysreqs step (with a PPM-binary pak bootstrap) now runs before setup-renv, plus librsvg2-dev added to the explicit apt list as defense-in-depth.

Re-run 38070651651 is green end-to-end: sysreqs 2m13s → restore 13m12s (first run for this lockfile hash, builds the cache) → delta 47s → full site render success. Subsequent runs on an unchanged lockfile should restore in minutes.

🤖 Generated with Claude Code

@ShixiangWang
ShixiangWang merged commit 601952a into main Oct 10, 2026
4 checks passed
@ShixiangWang
ShixiangWang deleted the ci/renv-stage2 branch October 10, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant