Skip to content

Commit

Permalink
Merge branch 'main' into milanmlft/styling-and-linting
Browse files Browse the repository at this point in the history
  • Loading branch information
milanmlft authored Aug 13, 2024
2 parents 9c4b880 + 3e6b0da commit c2f9fef
Show file tree
Hide file tree
Showing 5 changed files with 2,894 additions and 64 deletions.
63 changes: 62 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,65 @@ pak::pak("UCLH-Foundry/calypso")

## Development

* Using the [`{golem}`](https://engineering-shiny.org/golem.html) framework
### Set up

Make sure you have a [recent version of R](https://cloud.r-project.org/) (>= 4.0.0) installed.
Though not required, [RStudio](https://www.rstudio.com/products/rstudio/download/) is recommended as an IDE,
as it has good support for R package development and Shiny.

1. Clone this repository

- Either with `git clone [email protected]:UCLH-Foundry/omop-data-catalogue.git`
- Or by creating [a new project in RStudio from version control](https://docs.posit.co/ide/user/ide/guide/tools/version-control.html#creating-a-new-project-based-on-a-remote-git-or-subversion-repository)

2. Install [`{renv}`](https://rstudio.github.io/renv/index.html) and restore the project library by running the following from an R console in the project directory:

```r
install.packages("renv")
renv::restore()
```

3. To preview the app locally, run the following from an R console within the project directory:

```r
golem::run_dev()
```

The `dev/02_dev.R` script contains a few helper functions to get you started.

### Design

The Shiny app is developed using the [`{golem}`](https://engineering-shiny.org/golem.html) framework.
Among other things, this means that we make heavy use of [Shiny modules](https://mastering-shiny.org/scaling-modules.html).
In brief, a Shiny module is a self-contained, encapsulated piece of Shiny UI and server logic.
In practice, this will often be a particular component of the dashboard.
Note that it is possible to nest modules within other modules, leading to a hierarchical structure.

The filenames in `R/` follow the [`{golem}` conventions](https://engineering-shiny.org/golem.html#understanding-golem-app-structure):

* The `app_*.R` files define the UI and server logic for the app itself.
* The `mod_*.R` files define the UI and server logic for the modules.
* Any business logic functions, which are independent from the app's application logic, are defined in the `fct_*.R` files.
An overview of the app's design is given in the diagram below (note that this is subject to change):

![](./dev/design/omop-data-catalogue-design.png)

### Coding style

We'll mainly follow the [tidyverse style guide](https://style.tidyverse.org/).
The [`{styler}`](https://styler.r-lib.org/index.html) package can be used to automatically format R code to this style,
by regularly running
```r
styler::style_pkg()
```
within the project directory.
It's also recommended to install [`{lintr}`](https://github.com/r-lib/lintr) and regularly run

```r
lintr::lint_package()
```

(or have it [run automatically in your IDE](https://lintr.r-lib.org/articles/editors.html)).
35 changes: 0 additions & 35 deletions dev/02_dev.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,41 +56,6 @@ usethis::use_coverage()
# Create a summary readme for the testthat subdirectory
covrpage::covrpage()

## CI ----
## Use this part of the script if you need to set up a CI
## service for your application
##
## (You'll need GitHub there)
usethis::use_github()

# GitHub Actions
usethis::use_github_action()
# Chose one of the three
# See https://usethis.r-lib.org/reference/use_github_action.html
usethis::use_github_action_check_release()
usethis::use_github_action_check_standard()
usethis::use_github_action_check_full()
# Add action for PR
usethis::use_github_action_pr_commands()

# Travis CI
usethis::use_travis()
usethis::use_travis_badge()

# AppVeyor
usethis::use_appveyor()
usethis::use_appveyor_badge()

# Circle CI
usethis::use_circleci()
usethis::use_circleci_badge()

# Jenkins
usethis::use_jenkins()

# GitLab CI
usethis::use_gitlab_ci()

# You're now set! ----
# go to dev/03_deploy.R
rstudioapi::navigateToFile("dev/03_deploy.R")
28 changes: 0 additions & 28 deletions dev/03_deploy.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,7 @@ rhub::check_for_cran()
## sent to CRAN, or to a package manager
devtools::build()

## RStudio ----
## If you want to deploy on RStudio related platforms
golem::add_rstudioconnect_file()
golem::add_shinyappsio_file()
golem::add_shinyserver_file()

## Docker ----
## If you want to deploy via a generic Dockerfile
golem::add_dockerfile_with_renv()

## If you want to deploy to ShinyProxy
golem::add_dockerfile_with_renv_shinyproxy()


# Deploy to Posit Connect or ShinyApps.io
# In command line.
rsconnect::deployApp(
appName = desc::desc_get_field("Package"),
appTitle = desc::desc_get_field("Package"),
appFiles = c(
# Add any additional files unique to your app here.
"R/",
"inst/",
"data/",
"NAMESPACE",
"DESCRIPTION",
"app.R"
),
appId = rsconnect::deployments(".")$appID,
lint = FALSE,
forceUpdate = TRUE
)
Loading

0 comments on commit c2f9fef

Please sign in to comment.