Skip to content
Open
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
46 changes: 46 additions & 0 deletions .github/actions/rhub-check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Check on one R-hub platform"
description: >
Run R CMD check for one entry of the matrices that `rhub-setup` produces,
in its container or on its virtual machine.
The calling job's matrix must be named `config`:
`r-hub/actions/run-check` reads `matrix.config.label` to decide
which sanitizer, valgrind or rchk findings to look for.

inputs:
job-config:
description: "The `job-config` of the matrix entry."
required: true
token:
description: "Passed on to the R-hub actions, which use it for runs that `rhub::rhub_check()` starts."
required: false
default: ""
setup-r:
description: "Whether to install R first: `true` on a virtual machine, `false` in a container, which brings its own."
required: false
default: "false"

runs:
using: "composite"
steps:
- uses: r-hub/actions/checkout@v1

- uses: r-hub/actions/setup-r@v1
if: inputs.setup-r == 'true'
with:
job-config: ${{ inputs.job-config }}
token: ${{ inputs.token }}

- uses: r-hub/actions/platform-info@v1
with:
job-config: ${{ inputs.job-config }}
token: ${{ inputs.token }}

- uses: r-hub/actions/setup-deps@v1
with:
job-config: ${{ inputs.job-config }}
token: ${{ inputs.token }}

- uses: r-hub/actions/run-check@v1
with:
job-config: ${{ inputs.job-config }}
token: ${{ inputs.token }}
48 changes: 48 additions & 0 deletions .github/actions/rhub-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: "Choose the R-hub platforms"
description: >
Choose the R-hub platforms to check the package on,
and resolve them into the container and virtual-machine matrices that `rhub-check` runs.

inputs:
config:
description: >
Comma- or space-separated R-hub platforms, overriding the package's own.
Empty uses `Config/gha/rhub-platforms` from DESCRIPTION,
or else the default for the package, see `platforms.R`.
required: false
default: ""

outputs:
config:
description: "The chosen platforms, comma-separated, empty for none."
value: ${{ steps.choose.outputs.config }}
containers:
description: "Matrix of the container platforms, `[]` for none."
value: ${{ steps.setup.outputs.containers || '[]' }}
platforms:
description: "Matrix of the virtual-machine platforms, `[]` for none."
value: ${{ steps.setup.outputs.platforms || '[]' }}

runs:
using: "composite"
steps:
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Choose the platforms
id: choose
env:
REQUESTED: ${{ inputs.config }}
run: |
Rscript "${{ github.action_path }}/platforms.R"
shell: bash

# Skipped rather than called with an empty list: the outputs above turn a
# skipped step into two empty matrices, without pulling R-hub's image.
- name: Resolve the platforms into matrices
id: setup
if: steps.choose.outputs.config != ''
uses: r-hub/actions/setup@v1
with:
config: ${{ steps.choose.outputs.config }}
71 changes: 71 additions & 0 deletions .github/actions/rhub-setup/platforms.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Choose the R-hub platforms to check the package on, and write them to the
# `config` output as a comma-separated list, empty for none.
#
# Run from the package's checkout. The first of these that is set wins:
#
# * `REQUESTED`, the `config` input of the action;
# * `Config/gha/rhub-platforms` in DESCRIPTION, a comma- or space-separated
# list, or `none` to skip the checks;
# * the default: `nosuggests` for every package, plus `gcc-asan`,
# `clang-asan`, `clang-ubsan`, `valgrind` and `rchk` when `src/` holds
# sources to compile. rchk inspects the package's shared object and fails
# on a package without one, so it belongs to compiled code only.

requested <- trimws(Sys.getenv("REQUESTED"))
# read.dcf(), not `grep`: a DCF value may wrap onto continuation lines.
declared <- read.dcf("DESCRIPTION", fields = "Config/gha/rhub-platforms")[1, 1]

# The file types R CMD INSTALL compiles from src/.
sources <- dir(
"src",
pattern = "[.](c|cc|cpp|cxx|f|f90|f95|m|mm)$",
ignore.case = TRUE,
recursive = TRUE
)
compiled <- length(sources) > 0

if (nzchar(requested)) {
spec <- requested
origin <- "the `config` input of this run"
} else if (!is.na(declared)) {
spec <- declared
origin <- "`Config/gha/rhub-platforms` in DESCRIPTION"
} else if (compiled) {
spec <- "nosuggests gcc-asan clang-asan clang-ubsan valgrind rchk"
origin <- "the default for a package with compiled code in src/"
} else {
spec <- "nosuggests"
origin <- "the default for a package without compiled code"
}

platforms <- strsplit(trimws(spec), "[[:space:],]+")[[1]]
platforms <- platforms[nzchar(platforms)]

# The list is spliced into a shell command by r-hub/actions/setup,
# so anything but a plain platform name is refused here.
bad <- grep("^[A-Za-z0-9._-]+$", platforms, value = TRUE, invert = TRUE)
if (length(bad) > 0) {
stop("Not an R-hub platform name: ", paste0("'", bad, "'", collapse = ", "), call. = FALSE)
}
if ("none" %in% platforms) {
if (length(platforms) > 1) {
stop("`none` cannot be combined with other platforms.", call. = FALSE)
}
platforms <- character()
}

config <- paste(platforms, collapse = ",")
cat("config=", config, "\n", sep = "", file = Sys.getenv("GITHUB_OUTPUT"), append = TRUE)

summary <- c(
"## R-hub platforms",
"",
if (length(platforms) > 0) {
paste0("Checking on ", paste0("`", platforms, "`", collapse = ", "), ", from ", origin, ".")
} else {
paste0("No checks, as set by ", origin, ".")
},
""
)
writeLines(summary)
cat(summary, sep = "\n", file = Sys.getenv("GITHUB_STEP_SUMMARY"), append = TRUE)
25 changes: 22 additions & 3 deletions .github/workflows/R-CMD-check-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ permissions:
jobs:
matrix:
runs-on: ubuntu-26.04
timeout-minutes: 30 # longest run seen: 2 min
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

Expand All @@ -40,6 +41,7 @@ jobs:

check-matrix:
runs-on: ubuntu-26.04
timeout-minutes: 15 # longest run seen: 1 min
needs: matrix

name: Check deps
Expand All @@ -54,9 +56,13 @@ jobs:

R-CMD-check-base:
runs-on: ubuntu-26.04
timeout-minutes: 120 # longest run seen: 46 min

name: base

outputs:
binary: ${{ steps.binary.outputs.artifact-name }}

permissions:
# Both required by the update-snapshots action, which opens a pull
# request with refreshed snapshots.
Expand All @@ -78,7 +84,7 @@ jobs:
with:
cache-version: rcc-dev-base-1
needs: build, check
extra-packages: "any::rcmdcheck any::remotes ."
extra-packages: "any::rcmdcheck any::remotes"
token: ${{ secrets.GITHUB_TOKEN }}

- name: Session info
Expand All @@ -88,21 +94,28 @@ jobs:
uses: ./.github/workflows/custom/after-install
if: hashFiles('.github/workflows/custom/after-install/action.yml') != ''

- name: Build, install and upload the binary package
id: binary
uses: cynkra/cynkratemplate/.github/actions/build-binary@main
with:
name: ubuntu-26.04-rrelease-base

- name: Update the testthat snapshots
uses: cynkra/cynkratemplate/.github/actions/update-snapshots@main
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository

- name: Run R CMD check
uses: cynkra/cynkratemplate/.github/actions/check@main
with:
results: ${{ matrix.package }}
results: base

R-CMD-check-dev:
needs:
- matrix
- R-CMD-check-base

runs-on: ubuntu-26.04
timeout-minutes: 120 # longest run seen: 57 min

name: 'rcc-dev: ${{ matrix.package }}'

Expand All @@ -127,9 +140,15 @@ jobs:
with:
cache-version: rcc-dev-${{ matrix.package }}-1
needs: build, check
extra-packages: "any::rcmdcheck r-lib/remotes@f-618-universe ."
extra-packages: "any::rcmdcheck r-lib/remotes@f-618-universe"
token: ${{ secrets.GITHUB_TOKEN }}

# Same runner and R version as the base job, so its binary fits.
- name: Install the package from the base job's binary
uses: cynkra/cynkratemplate/.github/actions/install-binary@main
with:
name: ${{ needs.R-CMD-check-base.outputs.binary }}

- name: Install dev version of ${{ matrix.package }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/R-CMD-check-status.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ permissions: {}
jobs:
rcc-status:
runs-on: ubuntu-26.04
timeout-minutes: 15 # longest run seen: 1 min

name: "Update commit status"

Expand Down
Loading