forked from dbca-wa/mpaviewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
103 lines (83 loc) · 4.48 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# mpaviewer
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![Package checks](https://github.com/dbca-wa/mpaviewer/workflows/R-CMD-check/badge.svg)](https://github.com/dbca-wa/mpaviewer/actions)
[![Docker app](https://github.com/dbca-wa/mpaviewer/actions/workflows/docker.yaml/badge.svg)](https://github.com/dbca-wa/mpaviewer/actions/workflows/docker.yaml)
[![Docker data](https://github.com/dbca-wa/mpaviewer/actions/workflows/docker_cron.yaml/badge.svg)](https://github.com/dbca-wa/mpaviewer/actions/workflows/docker_cron.yaml)
[![Docs](https://github.com/dbca-wa/mpaviewer/actions/workflows/pkgdown.yaml/badge.svg)](https://github.com/dbca-wa/mpaviewer/actions/workflows/pkgdown.yaml)
<!-- badges: end -->
[mpaviewer](https://mpaviewer.dbca.wa.gov.au/) is a dashboard of marine monitoring data for DBCA staff.
## Architecture
* Data is loaded from a locally saved `.rds` file, or freshly loaded from
Google Drive or the DBCA data catalogue (and then saved as `.rds`).
The locally saved file lives on a persistent volume.
## Data
The dashboard runs off a single `mpa_data.rds` R save file which is produced
from a range of source data files (CSV, TXT, SHP).
Archived on the DBCA data catalogue as dataset [mpaviewer](https://data.dbca.wa.gov.au/dataset/mpaviewer) are:
* A link to a Google Drive folder which contains a copy of source data files
in the folder/file/data structure expected by `mpaviewer::generate_data()`.
* Links to the deployed dashboard and this GitHub code repository
* The mpaviewer data file `mpa_data.rds` at a specific resource ID expected by
`mpaviewer::download_data()`.
### Update source data
Data owners can update the Google Drive folder with new data.
### Generate dashboard data
Whenever the source data was updated, an analyst must download the contents
of the Google Drive folder "mpaviewer" into the directory `inst/data` of a local
clone of the mpaviewer codebase and run `mpaviewer::generate_data()`, then upload
the data file `mpa_data.rds` to the DBCA data catalogue.
### Update the dashboard with new data
A [Docker container for ETL](https://github.com/dbca-wa/mpaviewer/pkgs/container/mpaviewer_cron)
periodically executes a script to download source data and process it into the application data.
Until the source data files are all available from the DBCA Data Catalogue,
the container simply downloads the pre-processed data file `mpa_data.rds` from
the DBCA data catalogue.
## Development
`mpaviewer` is an RShiny app using
[Shiny modules](https://shiny.rstudio.com/articles/modules.html),
developed using [`golem`](https://mastering-shiny.org/scaling-modules.html).
The commands to develop new functionality are in `dev/02_dev.R`.
* Create a GH issue for each task, keep it as small and self-contained as possible.
* Work on one issue at a time.
* Once R CMD Check passes and all build errors and warnings are addressed,
commit changes.
* Write descriptive and well-formed commit messages and reference the GH issue.
* Push and see whether the R CMD Check GH action passes.
* Bonus points: Build and run the Docker image locally. If that's not an option,
at least make sure that any new package dependencies are added to the Dockerfile.
## Release
Once app and Docker image work, create a new version, tag, and push the tag.
```{r eval=FALSE}
styler::style_pkg()
spelling::spell_check_package()
spelling::update_wordlist()
# Code and docs tested, working, committed
usethis::use_version(which="patch")
usethis::use_version(which="minor")
usethis::use_version(which="major")
usethis::edit_file("NEWS.md")
# Document to load new package version. Git commit, tag, and push.
devtools::document()
v <- packageVersion("mpaviewer")
system(glue::glue("git tag -a v{v} -m 'v{v}' && git push && git push --tags"))
```
## Deployment
GitHub Actions are configured to build a new Docker image for every tag starting
with "v", such as "v1.0.0".
The images are pushed to the GitHub container registry `ghcr.io`.
The DBCA maintainer of `mpaviewer` then updates the tag number (e.g. `1.0.0`)
in the image run by Kubernetes, which will trigger a hot reload of the image.
The commands to deploy a new version are in `dev/03_deploy.R`.