Skip to content

Copy freshwater resources app #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: app-freshwater-resources
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions extensions/freshwater-resources-dashboard/.Rprofile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
if (file.exists("renv")) {
source("renv/activate.R")
} else {
# The `renv` directory is automatically skipped when deploying with rsconnect.
message("No 'renv' directory found; renv won't be activated.")
}

# Allow absolute module imports (relative to the app root).
options(box.path = getwd())

options(repos = c(CRAN = "https://packagemanager.posit.co/cran/latest"))
9 changes: 9 additions & 0 deletions extensions/freshwater-resources-dashboard/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.gitignore
.Rpoj.user/
.github/
renv/library/
renv/staging/
.rhino/node_modules/
.renvignore
.Renviron
.rscignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

### Changes proposed in this pull request:
-

### How to test the change:
-

Closes #


### Author Verification

- [ ] Ensure a well-defined and described task exists for the change; create one if necessary.
- [ ] Open a pull request for the change and assign a reviewer.

### Reviewer Verification

- [ ] Test the change (manually or with automated tests) to ensure it runs correctly and doesn't break existing functionality.
- [ ] Verify no new error or warning messages are introduced.
- [ ] Confirm user interactions, messages, plots, and reports are clear, helpful, and written with the end-user in mind.
- [ ] Update README, documentation, and code comments to reflect the change.
- [ ] Review all code before merging.
- [ ] Merge changes into the `dev` branch for ongoing development.
- [ ] Configure and ensure continuous integration checks (linter, unit tests, integration tests) pass.
- [ ] Add unit tests for all new or changed logic.
- [ ] Create end-to-end frontend and integration tests.
- [ ] Include all data assumptions in the code (e.g., as assertions).
- [ ] Verify all task requirements are satisfied.
- [ ] Ensure changes follow the Appsilon style-guide.
- [ ] Confirm results are easily reproducible (assuming data remains consistent).
- [ ] Document and make accessible all data sources to the reviewer (if applicable).


Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Rhino Test
on: push
permissions:
contents: read
jobs:
main:
name: Run linters and tests
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Extract R version from lockfile
run: printf 'R_VERSION=%s\n' "$(jq --raw-output .R.Version renv.lock)" >> $GITHUB_ENV

- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ env.R_VERSION }}

- name: Setup system dependencies
run: >
sudo apt-get update && sudo apt-get install --yes
libcurl4-openssl-dev
libharfbuzz-dev
libfribidi-dev
gdal-bin
libgdal-dev
libudunits2-dev

- name: Restore renv from cache
uses: actions/cache@v4
env:
CACHE_KEY: renv-${{ runner.arch }}-${{ runner.os }}-${{ env.R_VERSION }}
with:
path: renv/library
key: ${{ env.CACHE_KEY }}-${{ hashFiles('renv.lock') }}
restore-keys: ${{ env.CACHE_KEY }}-

- name: Sync renv with lockfile
shell: Rscript {0}
run: |
options(renv.config.cache.symlinks = FALSE)
renv::restore(clean = TRUE)

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Lint R
if: always()
shell: Rscript {0}
run: rhino::lint_r()

- name: Lint JavaScript
if: always()
shell: Rscript {0}
run: rhino::lint_js()

- name: Lint Sass
if: always()
shell: Rscript {0}
run: rhino::lint_sass()

- name: Build JavaScript
if: always()
shell: Rscript {0}
run: rhino::build_js()

- name: Build Sass
if: always()
shell: Rscript {0}
run: rhino::build_sass()

- name: Run R unit tests
if: always()
shell: Rscript {0}
run: rhino::test_r()

- name: Run Cypress end-to-end tests
if: always()
uses: cypress-io/github-action@v6
with:
working-directory: .rhino # Created by earlier commands which use Node.js
start: npm run run-app
project: ../tests
5 changes: 5 additions & 0 deletions extensions/freshwater-resources-dashboard/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
.DS_Store
6 changes: 6 additions & 0 deletions extensions/freshwater-resources-dashboard/.lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
linters:
linters_with_defaults(
line_length_linter = line_length_linter(100),
object_usage_linter = NULL, # Does not work with `box::use()`.
return_linter = NULL
)
3 changes: 3 additions & 0 deletions extensions/freshwater-resources-dashboard/.renvignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Only use `dependencies.R` to infer project dependencies.
*
!dependencies.R
7 changes: 7 additions & 0 deletions extensions/freshwater-resources-dashboard/.rscignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.github
.lintr
.renvignore
.Renviron
.rhino
.rscignore
tests
14 changes: 14 additions & 0 deletions extensions/freshwater-resources-dashboard/.whitesource
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"scanSettings": {
"baseBranches": []
},
"checkRunSettings": {
"vulnerableCheckRunConclusionLevel": "failure",
"displayMode": "diff",
"useMendCheckNames": true
},
"issueSettings": {
"minSeverityLevel": "LOW",
"issueType": "DEPENDENCY"
}
}
57 changes: 57 additions & 0 deletions extensions/freshwater-resources-dashboard/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM r-base:4.2.2

## system libraries of general use
RUN apt-get update && apt-get install -y \
sudo \
curl \
npm \
libgtk2.0-0 \
libgtk-3-0 \
libgbm-dev \
libnotify-dev \
libgconf-2-4 \
libnss3 \
libxss1 \
libasound2 \
libxtst6 \
xauth \
xvfb \
libcurl4-openssl-dev \
libharfbuzz-dev \
libfribidi-dev \
gdal-bin \
libgdal-dev \
libfontconfig1-dev

ENV RENV_VERSION 0.17.3

## install node
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get install -y nodejs

## set up R Shiny
WORKDIR /renewflow
COPY . .
COPY .rhino/package.json .rhino/package.json
COPY .rhino/package-lock.json .rhino/package-lock.json

## setting up cypress and dependencies
WORKDIR /renewflow/.rhino
RUN npm install
WORKDIR /renewflow

## installing R packages
RUN R -e "install.packages('remotes', repos = c(CRAN = 'https://cloud.r-project.org'))"
RUN R -e "remotes::install_github('rstudio/renv@${RENV_VERSION}')"
RUN R -e "renv::restore();"
RUN R -e "rhino::lint_r();"
RUN R -e "rhino::lint_sass();"
RUN R -e "rhino::lint_js();"
RUN R -e "rhino::test_r();"
RUN R -e "rhino::test_e2e();"

## expose port for Shiny
EXPOSE 9999

## run R Shiny
CMD ["R", "-s", "-e", "shiny::runApp(host = '0.0.0.0', port = 9999)"]
Loading