diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index d7d46f8..562fe0f 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -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: @@ -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")' diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 548afa5..0ab748d 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -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 diff --git a/DESCRIPTION b/DESCRIPTION index aa3eb31..7d9b0a7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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, diff --git a/R/code.R b/R/code.R index ec03ab7..f10e58c 100644 --- a/R/code.R +++ b/R/code.R @@ -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) @@ -183,7 +185,7 @@ usingTools <- function() { } toolsName <- function(name) { - paste(".rs.api.", name, sep="") + paste(".rs.api.", name, sep = "") } toolsEnv <- function() { diff --git a/R/launcher-functions.R b/R/launcher-functions.R index 89d6ced..a1ea16c 100644 --- a/R/launcher-functions.R +++ b/R/launcher-functions.R @@ -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. #' #' @param queues A list of available submission queues for the cluster. Only #' applicable to batch systems like LSF. @@ -329,6 +332,7 @@ launcherSubmitJob <- function(name, mounts = NULL, placementConstraints = NULL, resourceLimits = NULL, + resourceProfile = NULL, queues = NULL, config = NULL, @@ -351,6 +355,7 @@ launcherSubmitJob <- function(name, placementConstraints = placementConstraints, queues = queues, resourceLimits = resourceLimits, + resourceProfile = resourceProfile, stderrFile = stderrFile, stdin = stdin, stdoutFile = stdoutFile, diff --git a/R/utils.R b/R/utils.R index 49febb1..c091741 100644 --- a/R/utils.R +++ b/R/utils.R @@ -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) + +} diff --git a/README.Rmd b/README.Rmd index c6a2dc0..545925d 100644 --- a/README.Rmd +++ b/README.Rmd @@ -19,7 +19,8 @@ knitr::opts_chunk$set( [![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) The `rstudioapi` package is designed to make it easy to conditionally access the diff --git a/README.md b/README.md index 66370e2..0f71377 100644 --- a/README.md +++ b/README.md @@ -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) The `rstudioapi` package is designed to make it easy to conditionally diff --git a/man/launcherSubmitJob.Rd b/man/launcherSubmitJob.Rd index e346e38..7041024 100644 --- a/man/launcherSubmitJob.Rd +++ b/man/launcherSubmitJob.Rd @@ -22,6 +22,7 @@ launcherSubmitJob( mounts = NULL, placementConstraints = NULL, resourceLimits = NULL, + resourceProfile = NULL, queues = NULL, config = NULL, user = Sys.getenv("USER"), @@ -78,6 +79,9 @@ for more information.} \code{\link[=launcherResourceLimit]{launcherResourceLimit()}} for more information.} +\item{resourceProfile}{A resource profile name to be used for the job. The +resource profile must be defined in the cluster configuration.} + \item{queues}{A list of available submission queues for the cluster. Only applicable to batch systems like LSF.} diff --git a/vignettes/r-session.Rmd b/vignettes/r-session.Rmd index c10bed0..f10e86a 100644 --- a/vignettes/r-session.Rmd +++ b/vignettes/r-session.Rmd @@ -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}