Added a toast in case of test data being used (#347) #133
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Shiny App Startup | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
RENV_PATHS_ROOT: ~/.cache/R/renv | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: 4.2.0 | |
- name: Restore Renv package cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
${{ env.RENV_PATHS_ROOT }} | |
./renv/library | |
key: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{ inputs.cache-version }}-${{ hashFiles('renv.lock') }} | |
restore-keys: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{ inputs.cache-version }}- | |
- name: Install system dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libcurl4-openssl-dev libssl-dev libxml2-dev libsqlite3-dev libglu1-mesa-dev default-jdk libmagick++-dev libharfbuzz-dev libfribidi-dev libfreetype6-dev | |
sudo apt install curl | |
- name: Install and activate renv | |
shell: Rscript {0} | |
run: | | |
install.packages("renv") | |
print(getwd()) | |
renv::restore(lockfile="program/renv.lock") | |
# - name: Get R and OS version | |
# id: get-version | |
# run: | | |
# cat("##[set-output name=os-version;]", sessionInfo()$running, "\n", sep = "") | |
# cat("##[set-output name=r-version;]", R.Version()$version.string, sep = "") | |
# shell: Rscript {0} | |
# - name: Setup renv | |
# uses: r-lib/actions/setup-renv@v2 | |
# - name: Restore packages | |
# shell: Rscript {0} | |
# run: | | |
# renv::restore() | |
# - name: test specific packages | |
# run: | | |
# Rscript -e 'install.packages("Rcpp")' | |
# Rscript -e 'install.packages("RcppArmadillo")' | |
# Rscript -e 'install.packages("DESeq2")' | |
- name: Test if Shiny app starts | |
timeout-minutes: 2 | |
shell: Rscript {0} | |
run: | | |
install.packages('processx') | |
library(processx) | |
execute_shiny_app <- function() { | |
tryCatch( | |
{ | |
# Start the Shiny app in a separate process | |
app_process <- process$new( | |
"Rscript", | |
c("-e", "shiny::runApp('program/shinyApp', launch.browser = FALSE, port = 3838)"), | |
stdout = "|", stderr = "|" | |
) | |
# Wait for a few seconds to allow the app to start | |
Sys.sleep(15) | |
# Check if the process is still running | |
if (app_process$is_alive()) { | |
# Terminate the app if it started successfully | |
app_process$kill() | |
return("Success") | |
} else { | |
# Capture and return the error message if the app failed to start | |
error_message <- app_process$read_error() | |
return(paste("Error:", error_message)) | |
} | |
}, | |
error = function(e) { | |
return(paste("Error:", e$message)) | |
} | |
) | |
} | |
result <- execute_shiny_app() | |
# Check if the result is "failure" | |
if (result == "Success") { | |
cat("Test passed") | |
} else { | |
cat("Test failed: Output is 'failure'\n") | |
quit(status = 1) | |
} | |
- name: Save cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.local/share/renv | |
./renv/library | |
key: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{ inputs.cache-version }}-${{ hashFiles('renv.lock') }} | |