Title: | Checks for Various Computing Environments |
---|---|
Description: | A collection of lightweight functions that can be used to determine the computing environment in which your code is running. This includes operating systems, continuous integration (CI) environments, containers, and more. |
Authors: | Brian Connelly [aut, cre, cph] , Mark Padgham [ctb] , LluĂs Revilla Sancho [ctb] |
Maintainer: | Brian Connelly <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.0 |
Built: | 2024-10-26 03:32:41 UTC |
Source: | CRAN |
Detect Bioconductor
on_bioconductor()
on_bioconductor()
A logical value
Check the Bioconductor Build System: https://github.com/Bioconductor/BBS/
on_bioconductor()
on_bioconductor()
This function detects whether the current R environment is a
CRAN machine or not. It returns FALSE
if the NOT_CRAN
environment
variable used in "github/r-lib" packages like devtools and
testthat is set to "true". If that variable is not set, the function
examines other environment variables typically set on CRAN machines, as
documented in the issue on this packages' GitHub repository at
https://github.com/briandconnelly/ami/issues/14.
on_cran(cran_pattern = "_R_", n_cran_envvars = 5L)
on_cran(cran_pattern = "_R_", n_cran_envvars = 5L)
cran_pattern |
String to match against environment variables. |
n_cran_envvars |
If at least this number of environment variables match
the |
A logical value
on_cran() withr::with_envvar( list("NOT_CRAN" = "false", "_R_1" = 1, "_R_2" = 2), on_cran(n_cran_envvars = 2L) )
on_cran() withr::with_envvar( list("NOT_CRAN" = "false", "_R_1" = 1, "_R_2" = 2), on_cran(n_cran_envvars = 2L) )
online()
uses curl::has_internet to check whether the
machine is connected to the internet
online() using_host(hostname)
online() using_host(hostname)
hostname |
String containing a hostname or hostnames to check |
A logical value
online() using_host("somehost.fakedomain.com")
online() using_host("somehost.fakedomain.com")
Determine whether a given user account is being used
using_account(username)
using_account(username)
username |
Username to check for |
A logical value
using_account("root")
using_account("root")
using_ci()
reports whether a continuous integration
environment is being used.
using_appveyor()
reports whether AppVeyor is being used
using_circle_ci()
reports whether CircleCI is being used
using_codebuild()
reports whether AWS CodeBuild is being used
using_github_actions()
reports whether GitHub Actions is being
used
using_gitlab_ci()
reports whether GitLab CI/CD is being used
using_jenkins()
reports whether Jenkins is being used
using_travis_ci()
reports whether Travis CI is being used
using_ci(service = NULL) using_appveyor() using_circle_ci() using_codebuild() using_github_actions() using_gitlab_ci() using_jenkins() using_travis_ci()
using_ci(service = NULL) using_appveyor() using_circle_ci() using_codebuild() using_github_actions() using_gitlab_ci() using_jenkins() using_travis_ci()
service |
If provided, a particular CI service is checked. If not, the
commonly-used |
A logical value
using_ci() using_appveyor() using_circle_ci() using_codebuild() using_github_actions() using_gitlab_ci() using_jenkins() using_travis_ci()
using_ci() using_appveyor() using_circle_ci() using_codebuild() using_github_actions() using_gitlab_ci() using_jenkins() using_travis_ci()
Determine whether Conda environment is being used
using_conda(env = NULL)
using_conda(env = NULL)
env |
Optional environment name to compare against |
A logical value
# Check if Conda is being used (regardless of environment name) using_conda() # Check if the 'dev' Conda environment is being used using_conda(env = "dev")
# Check if Conda is being used (regardless of environment name) using_conda() # Check if the 'dev' Conda environment is being used using_conda(env = "dev")
Environment-specific configuration values can be used to alter code's
behavior in different environments. The
config package uses the
R_CONFIG_ACTIVE
environment variable to specify the active environment.
If R_CONFIG_ACTIVE
is not set, the "default"
configuration is used.
using_config(config)
using_config(config)
config |
Configuration name |
A logical value
# See whether the default configuration is being used using_config("default") # See whether the "production" configuration is being used using_config("production")
# See whether the default configuration is being used using_config("default") # See whether the "production" configuration is being used using_config("production")
Detect container environments
using_container() using_docker_container() using_podman_container() using_kubernetes()
using_container() using_docker_container() using_podman_container() using_kubernetes()
A logical value
using_container() using_docker_container() using_podman_container() using_kubernetes()
using_container() using_docker_container() using_podman_container() using_kubernetes()
Detect covr
using_covr()
using_covr()
A logical value
using_covr()
using_covr()
using_cpu()
checks whether the machine uses the given type
of processor or not.
using_x86_cpu()
checks whether the machine uses an x86
processor
using_arm_cpu()
checks whether the machine uses an ARM-based
processor
using_cpu(arch = c("arm", "x86")) using_x86_cpu() using_arm_cpu()
using_cpu(arch = c("arm", "x86")) using_x86_cpu() using_arm_cpu()
arch |
CPU architecture name. Either |
A logical value
using_arm_cpu() using_x86_cpu() using_arm_cpu()
using_arm_cpu() using_x86_cpu() using_arm_cpu()
Detect Databricks Runtime Environment
using_databricks()
using_databricks()
A logical value
using_databricks()
using_databricks()
Determine whether an environment variable is being used
using_envvar(x, value = NULL)
using_envvar(x, value = NULL)
x |
Environment variable |
value |
Optional value to compare against |
A logical value
using_envvar("NOT_CRAN") using_envvar("CI", "true")
using_envvar("NOT_CRAN") using_envvar("CI", "true")
Nix
Shellusing_nix_shell()
checks whether code is running within an
environment defined by a Nix expression.
using_nix_shell(pure = NULL)
using_nix_shell(pure = NULL)
pure |
Whether or not the environment is pure, meaning most environment variables have been cleared before the shell started. |
A logical value
# Check for Nix using_nix_shell() # Check for Nix in a pure environment using_nix_shell(pure = TRUE)
# Check for Nix using_nix_shell() # Check for Nix in a pure environment using_nix_shell(pure = TRUE)
Determine whether a global option is being used
using_option(x, value = NULL)
using_option(x, value = NULL)
x |
Option name |
value |
Optional value to compare against |
A logical value
using_option("width") using_option("boot.parallel", value = "multicore")
using_option("width") using_option("boot.parallel", value = "multicore")
Tests for operating systems
using_os(os = c("linux", "macos", "solaris", "windows")) using_linux() using_macos() using_solaris() using_windows()
using_os(os = c("linux", "macos", "solaris", "windows")) using_linux() using_macos() using_solaris() using_windows()
os |
Operating system name. One of |
A logical value
using_os(os = "linux") using_linux() using_macos() using_solaris() using_windows()
using_os(os = "linux") using_linux() using_macos() using_solaris() using_windows()
using_quarto()
determines whether code is being run within a Quarto
document
using_quarto()
using_quarto()
A logical value
The is_using_quarto()
function in the quarto
package can be used to determine whether your are in a quarto project.
using_quarto()
using_quarto()
Get information about the R environment being used.
using_r_version()
determines whether or not a particular version of R is
being used.
using_latest_r_version()
determines whether or not the latest stable
version of R is being used.
using_interactive_session()
determines whether or not R is
being run interactively.
using_r_version(ver) using_latest_r_version() using_interactive_session()
using_r_version(ver) using_latest_r_version() using_interactive_session()
ver |
Version string |
A logical value
using_r_version(ver = "4.3.0") using_latest_r_version() using_interactive_session()
using_r_version(ver = "4.3.0") using_latest_r_version() using_interactive_session()
These functions enable you to determine whether code is being run in the presence of various features of the RStudio IDE and other Posit products.
using_rstudio()
determines whether code is being run in RStudio.
using_rstudio_desktop()
, using_rstudio_server()
, and
using_rstudio_workbench()
are helpers to determine whether those specific
environments are being used.
using_rstudio_jobs()
determines whether code is running as
an RStudio Job
using_rstudio_dark_theme()
determines whether a dark theme is
being used
using_posit_connect()
checks whether Posit Connect
is being used
using_rstudio(mode = "any") using_rstudio_desktop() using_rstudio_server() using_rstudio_workbench() using_rstudio_jobs() using_rstudio_dark_theme() using_posit_connect()
using_rstudio(mode = "any") using_rstudio_desktop() using_rstudio_server() using_rstudio_workbench() using_rstudio_jobs() using_rstudio_dark_theme() using_posit_connect()
mode |
Optional argument specifying whether RStudio is being used in
|
A logical value
https://docs.posit.co/connect/user/content-settings/#content-vars
using_rstudio() using_rstudio_jobs() using_rstudio_dark_theme() using_posit_connect()
using_rstudio() using_rstudio_jobs() using_rstudio_dark_theme() using_posit_connect()
Detect testthat
using_testthat()
using_testthat()
A logical value
using_testthat()
using_testthat()
Detect whether code is running in Visual Studio Code
using_vscode()
using_vscode()
A logical value
using_vscode()
using_vscode()