| Title: | CI Testing for shiny |
|---|---|
| Description: | Core shiny team tools to facilitate testing of the shiny-verse. |
| Authors: | Barret Schloerke [aut, cre], Winston Chang [aut], Alan Dipert [aut], RStudio [cph, fnd] |
| Maintainer: | Barret Schloerke <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.0.9009 |
| Built: | 2026-06-05 10:53:52 UTC |
| Source: | https://github.com/rstudio/shinycoreci |
Accepts all snapshot changes for every shiny application in inst/apps.
accept_snaps(repo_dir = rprojroot::find_package_root_file())accept_snaps(repo_dir = rprojroot::find_package_root_file())
repo_dir |
Root repo folder path |
test_in_local() outputMethod called when test_in_local() is called with assert = TRUE.
assert_test_output(output)assert_test_output(output)
output |
value received from |
Clear cache for test chart and package info
clear_cache()clear_cache()
The corresponding rsconnect account should already exist before calling connect_set_public. This can be done by calling rsconnect::connectApiUser to add the appropriate account information.
connect_set_public( apps = apps_shiny, account = "barret", server = "beta.rstudioconnect.com" ) connect_urls( apps = apps_deploy, account = "barret", server = "beta.rstudioconnect.com" )connect_set_public( apps = apps_shiny, account = "barret", server = "beta.rstudioconnect.com" ) connect_urls( apps = apps_deploy, account = "barret", server = "beta.rstudioconnect.com" )
apps |
A character vector of fully defined shiny application folders |
account, server
|
args supplied to |
connect_set_public(): Set all the Shiny apps to be public on a Connect server
connect_urls(): Retrieve the urls from a Connect server using the Shiny applications provided in dir
## Not run: rsconnect::addConnectServer(url = 'https://SERVER.com/API', name = 'CustomName') rsconnect::connectApiUser('barret', 'CustomName', apiKey = 'SuperSecretKey') deploy_apps(account = 'barret', server = 'CustomName') connect_set_public(account = 'barret', server = 'CustomName') urls <- connect_urls(account = 'barret', server = 'CustomName') ## End(Not run)## Not run: rsconnect::addConnectServer(url = 'https://SERVER.com/API', name = 'CustomName') rsconnect::connectApiUser('barret', 'CustomName', apiKey = 'SuperSecretKey') deploy_apps(account = 'barret', server = 'CustomName') connect_set_public(account = 'barret', server = 'CustomName') urls <- connect_urls(account = 'barret', server = 'CustomName') ## End(Not run)
Run this in the terminal (not RStudio IDE) as it has issues when installing some packages.
deploy_apps( apps = apps_deploy, account = "testing-apps", server = "shinyapps.io", ..., local_pkgs = FALSE, extra_packages = NULL, cores = 1, retry = 2, retrying_ = FALSE )deploy_apps( apps = apps_deploy, account = "testing-apps", server = "shinyapps.io", ..., local_pkgs = FALSE, extra_packages = NULL, cores = 1, retry = 2, retrying_ = FALSE )
apps |
A character vector of fully defined shiny application folders |
account, server
|
args supplied to |
... |
ignored |
local_pkgs |
If |
extra_packages |
A character vector of extra packages to install |
cores |
number of cores to use when deploying |
retry |
If |
retrying_ |
For internal use only |
Installation will use default libpaths.
Clean up docker files
docker_clean(stopped_containers = TRUE, untagged_images = TRUE)docker_clean(stopped_containers = TRUE, untagged_images = TRUE)
stopped_containers |
boolean that determines if all stopped containers should be removed |
untagged_images |
boolean that determines of all untagged images should be removed |
_snaps files and merge all gha- branchesThis method will apply patches from corresponding GitHub branches for each R and Operating System combination. Changes will not be committed or pushed back to GitHub. The user will need to perform this action manually.
fix_snaps( sha = git_sha(repo_dir), ..., ask_apps = FALSE, ask_branches = TRUE, ask_if_not_main = TRUE, repo_dir = rprojroot::find_package_root_file() )fix_snaps( sha = git_sha(repo_dir), ..., ask_apps = FALSE, ask_branches = TRUE, ask_if_not_main = TRUE, repo_dir = rprojroot::find_package_root_file() )
sha |
git sha of base branch to look for |
... |
Extra arguments passed to |
ask_apps, ask_branches
|
Logical which allows for particular apps or branches are to be inspected |
ask_if_not_main |
Logical which will check if |
repo_dir |
Root repo folder path |
Note: This function will NOT fix shinyjster failures.
Outline of steps performed:
Validate the current git branch is main
Validate there are no git changes or untracked files in the current base branch
Validate there are .new _snaps files
Create patch files for each corresponding gha- branch in ./patches
Ask which branches should be applied. Filter patch files accordingly
Ask which app changes should be kept
Apply patch files
Call accept_snaps() on all app folders
Undo changes to app that were not selected
Prompt user to commit and push changes back to GitHub
Equivalent to the terminal code: git config github.user
github_user()github_user()
Execution platform
platform()platform()
one of c("win", "mac", "linux")
Platform and R Version
platform_rversion(platform_val = platform(), r_version = r_version_short())platform_rversion(platform_val = platform(), r_version = r_version_short())
platform_val |
See |
r_version |
R Version
r_version_short()r_version_short()
Major and minor number only. Ex: "4.0"
test_in_local() outputUse view_test_results() to preview test results generated by save_test_results()
(saving should only ever be done in a GHA workflow).
save_test_results( output, gha_branch_name, pr_number, username, repo_dir = rprojroot::find_package_root_file() )save_test_results( output, gha_branch_name, pr_number, username, repo_dir = rprojroot::find_package_root_file() )
output |
output from |
gha_branch_name |
an identifier determined by the GHA workflow |
pr_number |
the pull request number. |
username |
the username of the github profile. |
repo_dir |
Location of local shinycoreci repo |
Methods to get and reset the shinyverse libpath.
shinycoreci_libpath() shinycoreci_clean_libpaths()shinycoreci_libpath() shinycoreci_clean_libpaths()
shinycoreci_libpath(): Library path that will persist across installations. But will have a different path for different R versions
shinycoreci_clean_libpaths(): Removes the cached R library
Automatically runs the next app in a fresh callr::r_bg session. To stop, close the shiny application window.
test_in_browser( app_name = apps[1], apps = apps_manual, ..., port = 8080, port_background = NULL, host = "127.0.0.1", local_pkgs = FALSE )test_in_browser( app_name = apps[1], apps = apps_manual, ..., port = 8080, port_background = NULL, host = "127.0.0.1", local_pkgs = FALSE )
app_name |
app number or name to start with. If numeric, it will match the leading number in the testing application |
apps |
List of apps to test |
... |
ignored |
port |
|
port_background |
|
host |
|
local_pkgs |
If |
## Not run: test_in_browser() ## End(Not run)## Not run: test_in_browser() ## End(Not run)
Opens an app on the hosted server and runs silbing apps in an iframe.
test_in_connect(type = c("manual", "all")) test_in_shinyappsio(type = c("manual", "all"))test_in_connect(type = c("manual", "all")) test_in_shinyappsio(type = c("manual", "all"))
type |
Type of apps to test. |
test_in_connect(): Test deployed applications on RStudio Connect
test_in_shinyappsio(): Test connect applications given the server and account
## Not run: test_in_connect() ## Not run: test_in_test_in_shinyapps_io()## Not run: test_in_connect() ## Not run: test_in_test_in_shinyapps_io()
Automatically runs the next app in a fresh RStudio session after closing the current app. To stop, send an interrupt signal (esc or ctrl+c) to the app twice in rapid succession.
test_in_ide( app_name = apps[1], apps = apps_manual, ..., port = 8000, host = "127.0.0.1", delay = 1, local_pkgs = FALSE, viewer = NULL, refresh_ = FALSE )test_in_ide( app_name = apps[1], apps = apps_manual, ..., port = 8000, host = "127.0.0.1", delay = 1, local_pkgs = FALSE, viewer = NULL, refresh_ = FALSE )
app_name |
app number or name to start with. If numeric, it will match the leading number in the testing application |
apps |
List of apps to test |
... |
ignored |
port |
|
host |
|
delay |
Time to wait between applications. [ |
local_pkgs |
If |
viewer |
RStudio IDE viewer to use. [ |
refresh_ |
For internal use. If TRUE, packages will not be reinstalled. |
Kill testing by hitting esc in RStudio.
If options() need to be set, set them in your
.Rprofile
file. See usethis::edit_r_profile()
## Not run: test_in_ide(dir = "apps") ## End(Not run)## Not run: test_in_ide(dir = "apps") ## End(Not run)
shiny::runTests() using local libpathTest apps using shiny::runTests() using local libpath
test_in_local( apps = apps_with_tests(repo_dir), ..., assert = TRUE, timeout = 10 * 60, retries = 2, repo_dir = rprojroot::find_package_root_file(), local_pkgs = FALSE )test_in_local( apps = apps_with_tests(repo_dir), ..., assert = TRUE, timeout = 10 * 60, retries = 2, repo_dir = rprojroot::find_package_root_file(), local_pkgs = FALSE )
apps |
applications within |
... |
ignored |
assert |
logical value which will determine if |
timeout |
Length of time allowed for an application's full test suit can run before determining it is a failure |
retries |
number of attempts to retry before declaring the test a failure |
repo_dir |
Location of local shinycoreci repo |
local_pkgs |
If |
Automatically launches docker in a background process. Once the docker is ready, a shiny application will be launched to help move through the applications.
test_in_sso( app_name = apps[1], apps = apps_manual, ..., user = github_user(), release = c("jammy", "focal", "centos7"), r_version = c("4.3", "4.2", "4.1", "4.0", "3.6"), tag = NULL, port = 8080, port_background = switch(release, centos7 = 7878, 3838), host = "127.0.0.1" ) test_in_ssp( app_name = apps[1], apps = apps_manual, ..., license_file = NULL, user = github_user(), release = c("jammy", "focal", "centos7"), r_version = c("4.3", "4.2", "4.1", "4.0", "3.6"), tag = NULL, port = 8080, port_background = switch(release, centos7 = 8989, 4949), host = "127.0.0.1" )test_in_sso( app_name = apps[1], apps = apps_manual, ..., user = github_user(), release = c("jammy", "focal", "centos7"), r_version = c("4.3", "4.2", "4.1", "4.0", "3.6"), tag = NULL, port = 8080, port_background = switch(release, centos7 = 7878, 3838), host = "127.0.0.1" ) test_in_ssp( app_name = apps[1], apps = apps_manual, ..., license_file = NULL, user = github_user(), release = c("jammy", "focal", "centos7"), r_version = c("4.3", "4.2", "4.1", "4.0", "3.6"), tag = NULL, port = 8080, port_background = switch(release, centos7 = 8989, 4949), host = "127.0.0.1" )
app_name |
app number or name to start with. If numeric, it will match the leading number in the testing application |
apps |
List of apps to test |
... |
ignored |
user |
GitHub username. Ex: |
release |
Distro release name, such as "focal" for ubuntu or "7" for centos |
r_version |
R version to use. Ex: |
tag |
Extra tag information for the docker image. This will prepend a |
port |
Port for local shiny application |
port_background |
Port to connect to the Docker container |
host |
|
license_file |
Path to a SSP license file |
The docker application will stop when the shiny application exits.
test_in_sso(): Test SSO Shiny applications
test_in_ssp(): Test SSP Shiny applications
## Not run: test_in_sso() ## Not run: test_in_ssp()## Not run: test_in_sso() ## Not run: test_in_ssp()
This function uses the GitHub API to create a repository dispatch event that can trigger workflows.
trigger( event_type, repo = "rstudio/shinycoreci", client_payload = list(), auth_token = Sys.getenv("GITHUB_PAT") ) trigger_tests( repo = "rstudio/shinycoreci", auth_token = Sys.getenv("GITHUB_PAT") ) trigger_deploy( repo = "rstudio/shinycoreci", auth_token = Sys.getenv("GITHUB_PAT") ) trigger_docker( repo = "rstudio/shinycoreci", auth_token = Sys.getenv("GITHUB_PAT") ) trigger_results( repo = "rstudio/shinycoreci", auth_token = Sys.getenv("GITHUB_PAT") )trigger( event_type, repo = "rstudio/shinycoreci", client_payload = list(), auth_token = Sys.getenv("GITHUB_PAT") ) trigger_tests( repo = "rstudio/shinycoreci", auth_token = Sys.getenv("GITHUB_PAT") ) trigger_deploy( repo = "rstudio/shinycoreci", auth_token = Sys.getenv("GITHUB_PAT") ) trigger_docker( repo = "rstudio/shinycoreci", auth_token = Sys.getenv("GITHUB_PAT") ) trigger_results( repo = "rstudio/shinycoreci", auth_token = Sys.getenv("GITHUB_PAT") )
event_type |
The name of the event to create on the repository |
repo |
The GitHub repo to create the event on; defaults to rstudio/shinycoreci |
client_payload |
The JSON object to make available in the workflow as
the |
auth_token |
Your GitHub Personal Access Token; defaults to
|
All apps_* methods inspect each application to determine if if testing is possible.
use_manual_app(app_dir)use_manual_app(app_dir)
app_dir |
Shiny application directory containing an app.R, ui.R, server.R, or index.Rmd |
This creates a testing file that will test shinyjster on each applicable browser.
use_shinyjster(app_dir)use_shinyjster(app_dir)
app_dir |
Location of shiny application to test |
View Shinytest Images
view_test_images(repo_dir = rprojroot::find_package_root_file())view_test_images(repo_dir = rprojroot::find_package_root_file())
repo_dir |
directory to the shinycoreci repo |
Write system information to a file
write_sysinfo(file = stdout(), libpath = resolve_libpath())write_sysinfo(file = stdout(), libpath = resolve_libpath())
file |
Name of file, or file object to write to (defaults to stdout). |
libpath |
Library path to find installed packages. |