From 9eaa61a3e4cbf1db0dfca55b6b2a56f866e27cb9 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 1 Oct 2024 21:55:00 -0500 Subject: [PATCH] Add Lint workflow --- .Rbuildignore | 1 + .github/.gitignore | 1 + .github/workflows/lint-project.yaml | 33 +++++++++++++++++++++++++++++ .lintr | 2 ++ R/load_components.R | 5 ++--- dev/dev.R | 4 ++-- global.R | 5 ++--- server.R | 2 +- ui.R | 6 +++--- userInterface/home_ui.R | 14 ++++++------ userInterface/other_ui.R | 14 ++++++------ 11 files changed, 61 insertions(+), 26 deletions(-) create mode 100644 .Rbuildignore create mode 100644 .github/.gitignore create mode 100644 .github/workflows/lint-project.yaml create mode 100644 .lintr diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..c503c4f --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1 @@ +^\.github$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/lint-project.yaml b/.github/workflows/lint-project.yaml new file mode 100644 index 0000000..225eb01 --- /dev/null +++ b/.github/workflows/lint-project.yaml @@ -0,0 +1,33 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: lint-project.yaml + +permissions: read-all + +jobs: + lint-project: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - name: Install lintr + run: install.packages("lintr") + shell: Rscript {0} + + - name: Lint root directory + run: lintr::lint_dir() + shell: Rscript {0} + env: + LINTR_ERROR_ON_LINT: true diff --git a/.lintr b/.lintr new file mode 100644 index 0000000..3d4eb22 --- /dev/null +++ b/.lintr @@ -0,0 +1,2 @@ +linters: linters_with_defaults() # see vignette("lintr") +encoding: "UTF-8" diff --git a/R/load_components.R b/R/load_components.R index ed0b612..fbbbdb1 100755 --- a/R/load_components.R +++ b/R/load_components.R @@ -1,5 +1,4 @@ # Load modules -sapply(list.files('modules', full.names = TRUE), function(x) source(x)) +sapply(list.files("modules", full.names = TRUE), function(x) source(x)) # Load user interface -sapply(list.files('userInterface', full.names = TRUE), function(x) source(x)) - +sapply(list.files("userInterface", full.names = TRUE), function(x) source(x)) diff --git a/dev/dev.R b/dev/dev.R index bde8b6e..c74974f 100755 --- a/dev/dev.R +++ b/dev/dev.R @@ -1,3 +1,3 @@ -# Use this script to test code blocks for app dev. -# Make sure to add this "dev" directory +# Use this script to test code blocks for app dev. +# Make sure to add this "dev" directory. # in your gitignore after template initialization. diff --git a/global.R b/global.R index 2e360c9..4a10bf6 100755 --- a/global.R +++ b/global.R @@ -1,7 +1,6 @@ # Load libraries/ Source Files library(shiny) - + # Load data/connections - + # Preprocess small data - diff --git a/server.R b/server.R index 2cf2b76..0cb2931 100755 --- a/server.R +++ b/server.R @@ -1,4 +1,4 @@ # Shiny Server function(input, output, session) { - + } diff --git a/ui.R b/ui.R index 87427de..66204bb 100755 --- a/ui.R +++ b/ui.R @@ -1,5 +1,5 @@ navbarPage( - 'My app', - tabPanel('Home', home_page), - tabPanel('Other', other_page), + "My app", + tabPanel("Home", home_page), + tabPanel("Other", other_page), ) diff --git a/userInterface/home_ui.R b/userInterface/home_ui.R index 78ce0d4..8d9a5a3 100755 --- a/userInterface/home_ui.R +++ b/userInterface/home_ui.R @@ -1,9 +1,9 @@ home_page <- fluidPage( -# Page title -titlePanel('Home Page'), -hr(), -fluidRow( - column(6,h2('Column size 3')), - column(6,h2('Column size 3')) - ) + # Page title + titlePanel("Home Page"), + hr(), + fluidRow( + column(6, h2("Column size 6")), + column(6, h2("Column size 6")) + ) ) diff --git a/userInterface/other_ui.R b/userInterface/other_ui.R index 8ccb1f9..71a6554 100755 --- a/userInterface/other_ui.R +++ b/userInterface/other_ui.R @@ -1,9 +1,9 @@ other_page <- fluidPage( -# Page title -titlePanel('Other Page'), -hr(), -fluidRow( - column(6,h2('Column size 3')), - column(6,h2('Column size 3')) - ) + # Page title + titlePanel("Other Page"), + hr(), + fluidRow( + column(6, h2("Column size 6")), + column(6, h2("Column size 6")) + ) )