Skip to content
Merged
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
103 changes: 21 additions & 82 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
# NOTE: This workflow is overkill for most R packages
# check-standard.yaml is likely a better choice
# usethis::use_github_action("check-standard") will install it.
#
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches:
- main
- master
branches: [main, master]
pull_request:
branches:
- main
- master

name: R-CMD-check
name: R-CMD-check.yaml

permissions: read-all

jobs:
R-CMD-check:
Expand All @@ -26,87 +19,33 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: windows-latest, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/latest"}
- {os: ubuntu-18.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }
- {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

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

- uses: r-lib/actions/setup-r@v2
id: install-r
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-pandoc@v1

- name: Install pak and query dependencies
run: |
install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")
saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds")
shell: Rscript {0}

- name: Restore R package cache
uses: actions/cache@v2
- uses: r-lib/actions/setup-r-dependencies@v2
with:
path: |
${{ env.R_LIBS_USER }}/*
!${{ env.R_LIBS_USER }}/pak
key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }}
restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-

- name: Install system dependencies
if: runner.os == 'Linux'
run: |
pak::local_system_requirements(execute = TRUE)
pak::pkg_system_requirements("rcmdcheck", execute = TRUE)
shell: Rscript {0}
extra-packages: any::rcmdcheck
needs: check

- name: Install dependencies
run: |
pak::local_install_dev_deps(upgrade = TRUE)
pak::pkg_install("rcmdcheck")
shell: Rscript {0}

- name: Session info
run: |
options(width = 100)
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
shell: Rscript {0}

- name: Check
env:
_R_CHECK_CRAN_INCOMING_: false
run: |
options(crayon.enabled = TRUE)
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
- uses: r-lib/actions/check-r-package@v2
with:
name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results
path: check

- name: Don't use tar from old Rtools to store the cache
if: ${{ runner.os == 'Windows' && startsWith(steps.install-r.outputs.installed-r-version, '3.6' ) }}
shell: bash
run: echo "C:/Program Files/Git/usr/bin" >> $GITHUB_PATH
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
80 changes: 43 additions & 37 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,56 +1,62 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches:
- main
- master
branches: [main, master]
pull_request:
branches:
- main
- master

name: test-coverage
name: test-coverage.yaml

permissions: read-all

jobs:
test-coverage:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
env:
RSPM: https://packagemanager.rstudio.com/cran/__linux__/bionic/latest
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1
id: install-r
- uses: actions/checkout@v4

- name: Install pak and query dependencies
run: |
install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")
saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds")
shell: Rscript {0}
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Restore R package cache
uses: actions/cache@v2
- uses: r-lib/actions/setup-r-dependencies@v2
with:
path: |
${{ env.R_LIBS_USER }}/*
!${{ env.R_LIBS_USER }}/pak
key: ubuntu-18.04-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }}
restore-keys: ubuntu-18.04-${{ steps.install-r.outputs.installed-r-version }}-1-

- name: Install system dependencies
if: runner.os == 'Linux'
extra-packages: any::covr, any::xml2
needs: coverage

- name: Test coverage
run: |
pak::local_system_requirements(execute = TRUE)
pak::pkg_system_requirements("covr", execute = TRUE)
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
print(cov)
covr::to_cobertura(cov)
shell: Rscript {0}

- name: Install dependencies
- uses: codecov/codecov-action@v5
with:
# Fail if error if not on PR, or if on PR and token is given
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
files: ./cobertura.xml
plugins: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
pak::local_install_dev_deps(upgrade = TRUE)
pak::pkg_install("covr")
shell: Rscript {0}
## --------------------------------------------------------------------
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Test coverage
run: covr::codecov()
shell: Rscript {0}
- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ URL: https://rstudio.github.io/rstudioapi/,
https://github.com/rstudio/rstudioapi
BugReports: https://github.com/rstudio/rstudioapi/issues
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
Suggests:
testthat,
knitr,
Expand Down
6 changes: 4 additions & 2 deletions R/code.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,11 @@ callFun <- function(fname, ...) {
# drop arguments that aren't accepted by RStudio
# (ensure backwards-compatibility with older versions of RStudio)
args <- list(...)
if (!"..." %in% names(formals(f)))
if (!"..." %in% names(formals(f))) {
args <- checkApiArguments(fname, f, args)
if (length(args) > length(formals(f)))
length(args) <- length(formals(f))
}

# invoke the function
do.call(f, args)
Expand Down Expand Up @@ -183,7 +185,7 @@ usingTools <- function() {
}

toolsName <- function(name) {
paste(".rs.api.", name, sep="")
paste(".rs.api.", name, sep = "")
}

toolsEnv <- function() {
Expand Down
5 changes: 5 additions & 0 deletions R/launcher-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@ launcherNfsMount <- function(host,
#' @param resourceLimits A list of resource limits. See
#' \code{\link[=launcherResourceLimit]{launcherResourceLimit()}} for more
#' information.
#'
#' @param resourceProfile A resource profile name to be used for the job. The
#' resource profile must be defined in the cluster configuration.
#'
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation has trailing whitespace after the period on line 302. Remove the extra spaces for consistency with other parameter documentation.

Suggested change
#'
#'

Copilot uses AI. Check for mistakes.
#' @param queues A list of available submission queues for the cluster. Only
#' applicable to batch systems like LSF.
Expand Down Expand Up @@ -329,6 +332,7 @@ launcherSubmitJob <- function(name,
mounts = NULL,
placementConstraints = NULL,
resourceLimits = NULL,
resourceProfile = NULL,
queues = NULL,

config = NULL,
Expand All @@ -351,6 +355,7 @@ launcherSubmitJob <- function(name,
placementConstraints = placementConstraints,
queues = queues,
resourceLimits = resourceLimits,
resourceProfile = resourceProfile,
stderrFile = stderrFile,
stdin = stdin,
stdoutFile = stdoutFile,
Expand Down
35 changes: 35 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,38 @@ renderTemplate <- function(template, data) {
rendered

}

checkApiArguments <- function(fname, f, args) {

# allow opt-out just in case
enabled <- getOption("rstudioapi.checkApiArguments", default = TRUE)
if (identical(enabled, FALSE))
return(args)

# check for arguments supplied by the user that aren't available
# in the current version of RStudio
unsupportedArgNames <- setdiff(names(args), names(formals(f)))
if (length(unsupportedArgNames) == 0L)
return(args)

# check which of these arguments is NULL; if all arguments are NULL,
# then we accept the call
isNullArg <- vapply(args[unsupportedArgNames], is.null, FUN.VALUE = logical(1))
badArgNames <- names(isNullArg)[!isNullArg]
if (length(badArgNames) == 0L) {
args[unsupportedArgNames] <- NULL
return(args)
}

# if we get here, the user tried to supply a value for a parameter that isn't
# supported in this version of RStudio; emit an error
fmt <- ifelse(
length(badArgNames) == 1L,
"Parameter %s is not supported by %s in this version of RStudio.",
"Parameters %s are not supported by %s in this version of RStudio."
)

msg <- sprintf(fmt, paste(shQuote(badArgNames), collapse = ", "), shQuote(fname))
stop(msg, call. = FALSE)

}
3 changes: 2 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ knitr::opts_chunk$set(
<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/rstudioapi)](https://CRAN.R-project.org/package=rstudioapi)
[![Codecov test coverage](https://codecov.io/gh/rstudio/rstudioapi/branch/main/graph/badge.svg)](https://app.codecov.io/gh/rstudio/rstudioapi?branch=main)
[![R-CMD-check](https://github.com/rstudio/rstudioapi/workflows/R-CMD-check/badge.svg)](https://github.com/rstudio/rstudioapi/actions)
[![R-CMD-check](https://github.com/rstudio/rstudioapi/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rstudio/rstudioapi/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/rstudio/rstudioapi/graph/badge.svg)](https://app.codecov.io/gh/rstudio/rstudioapi)
<!-- badges: end -->

The `rstudioapi` package is designed to make it easy to conditionally access the
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
status](https://www.r-pkg.org/badges/version/rstudioapi)](https://CRAN.R-project.org/package=rstudioapi)
[![Codecov test
coverage](https://codecov.io/gh/rstudio/rstudioapi/branch/main/graph/badge.svg)](https://app.codecov.io/gh/rstudio/rstudioapi?branch=main)
[![R-CMD-check](https://github.com/rstudio/rstudioapi/workflows/R-CMD-check/badge.svg)](https://github.com/rstudio/rstudioapi/actions)
[![R-CMD-check](https://github.com/rstudio/rstudioapi/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rstudio/rstudioapi/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

The `rstudioapi` package is designed to make it easy to conditionally
Expand Down
4 changes: 4 additions & 0 deletions man/launcherSubmitJob.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vignettes/r-session.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Interacting with the R Session"
title: "Interact with the R Session"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Interact with the R Session}
Expand Down