print_yaml <- function(filename) { cat("```yaml", readLines(filename), "```", sep = "\n") }
This action tests a Shiny application (or Shiny-based document) using the {shinytest2}
package. The ${{ inputs.app-dir}}/tests/testthat/_snaps
directory will be uploaded if enabled (default).
Inputs available:
app-dir
- default "."
. Directory of Shiny application (or Shiny-based document) to testupload-snapshots
- default true
. Whether to upload all testthat snapshots as an artifact.Typical (single app testing) GHA step usage:
- uses: rstudio/shinytest2/actions/test-app@actions/v1 with: app-dir: | dir/to/app
Multiple Apps can be tested by supplying multiple directories to app-dir
separated by a newline:
- uses: rstudio/shinytest2/actions/test-app@actions/v1 with: app-dir: | dir/to/app1 dir/to/app2
These workflows are a good building block / starting point for testing your Shiny applications. You may need to alter what is actually executed to fit your needs.
test-app-description
- An example CI workflow to test your Shiny application given you are using a DESCRIPTION
file to state your dependencies.test-app-renv
- An example CI workflow to test your Shiny application given you are using {renv}
to manage your dependencies.test-app-package
- An example CI workflow to test a Shiny application within your local R package. It is recommended to use app-dir
input to set the location of your Shiny application.Install workflow using:
usethis::use_github_action( url = "https://github.com/rstudio/shinytest2/raw/main/actions/test-app/example-test-app-descrption.yaml", save_as = "test-app-description.yaml" )
Workflow contents:
print_yaml("example-test-app-description.yaml")
{renv}
Install workflow using:
usethis::use_github_action( url = "https://github.com/rstudio/shinytest2/raw/main/actions/test-app/example-test-app-renv.yaml", save_as = "test-app-renv.yaml" )
Workflow contents:
print_yaml("example-test-app-renv.yaml")
If you are using a local package and want to test an application within the same repo, this may be a good option. However, it is recommended to try to execute these tests as a part of your standard {testthat}
testting.
Install workflow using:
usethis::use_github_action( url = "https://github.com/rstudio/shinytest2/raw/main/actions/test-app/example-test-app-package.yaml", save_as = "test-app-package.yaml" )
Workflow contents:
print_yaml("example-test-app-package.yaml")
The test-app
action uses a sliding git tag that follows the pattern actions/vX
, e.g. actions/v1
. For historical reasons, we also support the v1
tag, but future versions will only be available under the actions/vX
tag.
The test-app
action release cycle is not dependent on the shinytest2 package cycle. When changes are made to the test-app
action, you should force-update the current sliding tag version:
git tag -f v1 # update historical v1 tag git tag -f actions/v1 # update sliding tag git push --tags --force # push tag to github
The scripts and documentation in this project are released under the MIT License
Contributions are welcome!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.