Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/actions/r-sysreqs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Install R system requirements without the Chromium PPA
description: >
Installs the Linux system packages that setup-r-dependencies would install
for the same inputs, except Chromium. pak installs Chromium from a Launchpad
PPA. That PPA has seen multiple outages that cause Linux jobs to fail;
the runner image already ships Chrome, so we use that instead.
Run setup-r-dependencies afterwards with PKG_SYSREQS set to
"false". Does nothing on macOS and Windows, where pak installs no system
packages.

inputs:
extra-packages:
description: The extra-packages input given to setup-r-dependencies.
default: ""
needs:
description: The needs input given to setup-r-dependencies.
default: ""
working-directory:
description: The working-directory input given to setup-r-dependencies.
default: "."

runs:
using: composite
steps:
- name: Install system requirements except Chromium
if: runner.os == 'Linux'
shell: Rscript {0}
working-directory: ${{ inputs.working-directory }}
env:
SYSREQS_EXTRA_PACKAGES: ${{ inputs.extra-packages }}
SYSREQS_NEEDS: ${{ inputs.needs }}
run: |
# A private library, so this pak does not interfere with the one
# setup-r-dependencies installs.
lib <- file.path(Sys.getenv("RUNNER_TEMP", tempdir()), "sysreqs-pak")
dir.create(lib, recursive = TRUE, showWarnings = FALSE)
install.packages("pak", lib = lib, quiet = TRUE, repos = sprintf(
"https://r-lib.github.io/p/pak/stable/%s/%s/%s",
.Platform$pkgType, R.Version()$os, R.Version()$arch
))
# pak's worker subprocess looks for pak on the library path.
.libPaths(c(lib, .libPaths()))

split <- function(x) {
parts <- trimws(strsplit(x, "[[:space:],]+")[[1]])
parts[nzchar(parts)]
}
# The same resolution setup-r-dependencies asks pak for.
refs <- unique(c("deps::.", split(Sys.getenv("SYSREQS_EXTRA_PACKAGES"))))
needs <- split(Sys.getenv("SYSREQS_NEEDS"))
plan <- pak::pkg_sysreqs(
refs,
dependencies = c("all", if (length(needs)) paste0("Config/Needs/", needs))
)
rows <- plan$packages[plan$packages$sysreq != "chrome", ]

sudo <- if (Sys.info()[["effective_user"]] == "root") "" else "sudo "
run <- function(command) {
message("> ", command)
status <- system(paste0(
sudo, "env DEBIAN_FRONTEND=noninteractive sh -c ", shQuote(command)
))
if (status != 0) stop("Failed: ", command, call. = FALSE)
}
for (command in unique(unlist(rows$pre_install))) run(command)
run("apt-get -y update")
system_packages <- unique(unlist(rows$system_packages))
if (length(system_packages)) {
run(paste("apt-get -y install", paste(system_packages, collapse = " ")))
}
for (command in unique(unlist(rows$post_install))) run(command)
11 changes: 9 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: "R: R CMD check"
on:
push:
branches: [main]
paths: [pkg-r/**, tests/shared/**, .github/workflows/R-CMD-check.yaml]
paths: [pkg-r/**, tests/shared/**, .github/workflows/R-CMD-check.yaml, .github/actions/r-sysreqs/**]
pull_request:
paths: [pkg-r/**, tests/shared/**, .github/workflows/R-CMD-check.yaml]
paths: [pkg-r/**, tests/shared/**, .github/workflows/R-CMD-check.yaml, .github/actions/r-sysreqs/**]
workflow_dispatch:

permissions: read-all
Expand Down Expand Up @@ -49,7 +49,14 @@ jobs:
install.packages("odbc", lib = lib, repos = "https://cran.r-project.org")
stopifnot(nzchar(system.file(package = "odbc", lib.loc = lib)))
# END odbc workaround
- uses: ./.github/actions/r-sysreqs
with:
extra-packages: any::rcmdcheck, local::.
needs: check
working-directory: pkg-r
- uses: r-lib/actions/setup-r-dependencies@v2
env:
PKG_SYSREQS: "false"
with:
extra-packages: any::rcmdcheck, local::.
needs: check
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/citation-browser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: "R: Citation browser tests"
on:
push:
branches: [main]
paths: [pkg-r/**, tests/shared/**, .github/workflows/citation-browser.yaml]
paths: [pkg-r/**, tests/shared/**, .github/workflows/citation-browser.yaml, .github/actions/r-sysreqs/**]
pull_request:
paths: [pkg-r/**, tests/shared/**, .github/workflows/citation-browser.yaml]
paths: [pkg-r/**, tests/shared/**, .github/workflows/citation-browser.yaml, .github/actions/r-sysreqs/**]
workflow_dispatch:

permissions: read-all
Expand All @@ -23,11 +23,19 @@ jobs:
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: ./.github/actions/r-sysreqs
with:
extra-packages: local::., any::devtools, any::shinytest2, any::chromote
needs: check
working-directory: pkg-r
- uses: r-lib/actions/setup-r-dependencies@v2
env:
PKG_SYSREQS: "false"
with:
extra-packages: local::., any::devtools, any::shinytest2, any::chromote
needs: check
working-directory: pkg-r
# The runner image's Chrome, since r-sysreqs skips the Chromium PPA.
- name: Locate Chrome
run: Rscript -e 'stopifnot(nzchar(chromote::find_chrome()))'
- name: Run citation browser tests
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
on:
push:
branches: [main, master]
paths: [pkg-r/**, tests/shared/**, docs/**, .github/workflows/pkgdown.yaml]
paths: [pkg-r/**, tests/shared/**, docs/**, .github/workflows/pkgdown.yaml, .github/actions/r-sysreqs/**]
pull_request:
paths: [pkg-r/**, tests/shared/**, docs/**, .github/workflows/pkgdown.yaml]
paths: [pkg-r/**, tests/shared/**, docs/**, .github/workflows/pkgdown.yaml, .github/actions/r-sysreqs/**]
release:
types: [published]
workflow_dispatch:
Expand Down Expand Up @@ -36,7 +36,15 @@ jobs:

- uses: r-lib/actions/setup-r@v2

- uses: ./.github/actions/r-sysreqs
with:
extra-packages: any::pkgdown, local::.
needs: website
working-directory: pkg-r

- uses: r-lib/actions/setup-r-dependencies@v2
env:
PKG_SYSREQS: "false"
with:
extra-packages: any::pkgdown, local::.
needs: website
Expand Down
Loading