From 00fd919d4537a790326357fd38808ff53e61ab1c Mon Sep 17 00:00:00 2001 From: Richard Martin-Nielsen Date: Thu, 24 Jun 2021 22:11:42 +0300 Subject: [PATCH 01/10] Adjusted summary method, began adding source text and url fields --- R/Belgium.R | 5 +++++ R/Brazil.R | 5 +++++ R/Canada.R | 7 ++++++- R/Colombia.R | 5 +++++ R/Cuba.R | 6 ++++++ R/shared-methods.R | 4 +++- 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/R/Belgium.R b/R/Belgium.R index 0a30dc08..24b9775d 100644 --- a/R/Belgium.R +++ b/R/Belgium.R @@ -50,6 +50,11 @@ Belgium <- R6::R6Class("Belgium", ), #' @field source_data_cols existing columns within the raw data source_data_cols = c("cases_new", "deaths_new"), + #' @field source_text Plain text description of the source of the data + source_text = "Sciensano (Belgian institute of health)", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://epistat.wiv-isp.be/covid/", #' @description Set up a table of region codes for clean data #' @importFrom tibble tibble tribble diff --git a/R/Brazil.R b/R/Brazil.R index f44a0ebf..6be4ef3a 100644 --- a/R/Brazil.R +++ b/R/Brazil.R @@ -40,6 +40,11 @@ Brazil <- R6::R6Class("Brazil", ), #' @field source_data_cols existing columns within the raw data source_data_cols = c("cases_total", "deaths_total"), + #' @field source_text Plain text description of the source of the data + source_text = "Wesley Cota", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://github.com/wcota/covid19br/blob/master/README.en.md", #' @description Set up a table of region codes for clean data #' @importFrom tibble tribble diff --git a/R/Canada.R b/R/Canada.R index fff6ed6a..9180ea33 100644 --- a/R/Canada.R +++ b/R/Canada.R @@ -37,7 +37,12 @@ Canada <- R6::R6Class("Canada", "cases_new", "cases_total", "deaths_new", "recovered_total", "tested_new" ), - + #' @field source_text Plain text description of the source of the data + source_text = "Public Health Infobase, Public Health Agency of Canada", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://open.canada.ca/data/en/dataset/261c32ab-4cfd-4f81-9dea-7b64065690dc", # nolint + #' @description Set up a table of region codes for clean data #' @importFrom tibble tibble set_region_codes = function() { diff --git a/R/Colombia.R b/R/Colombia.R index ca2b322b..edbd0482 100644 --- a/R/Colombia.R +++ b/R/Colombia.R @@ -34,6 +34,11 @@ Colombia <- R6::R6Class("Colombia", # nolint end #' @field source_data_cols existing columns within the raw data source_data_cols = c("cases_total"), + #' @field source_text Plain text description of the source of the data + source_text = "Daniel Cárdenas", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://github.com/danielcs88/colombia_covid-19/", #' @description Set up a table of region codes for clean data #' @importFrom tibble tibble diff --git a/R/Cuba.R b/R/Cuba.R index 74feecd7..7dc75102 100644 --- a/R/Cuba.R +++ b/R/Cuba.R @@ -34,6 +34,12 @@ Cuba <- R6::R6Class("Cuba", # nolint end #' @field source_data_cols existing columns within the raw data source_data_cols = c("cases_new"), + #' @field source_text Plain text description of the source of the data + source_text = "COVID19 Cuba Data team", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://covid19cubadata.github.io/#cuba", + #' @description Set up a table of region codes for clean data #' @importFrom tibble tibble diff --git a/R/shared-methods.R b/R/shared-methods.R index f4c3f46a..741a5002 100644 --- a/R/shared-methods.R +++ b/R/shared-methods.R @@ -510,7 +510,9 @@ DataClass <- R6::R6Class( "national", "regional" ), data_urls = paste(unlist(self$data_urls), collapse = ", "), - source_data_cols = paste(unlist(self$source_data_cols), collapse = ", ") + source_data_cols = paste(unlist(self$source_data_cols), collapse = ", "), + source_text = self$source_text, + source_url = self$source_url ) return(sum_df) }, From df7993b98e9057b554fd5d022c41d1ade9abb490 Mon Sep 17 00:00:00 2001 From: Richard Martin-Nielsen Date: Thu, 24 Jun 2021 22:21:28 +0300 Subject: [PATCH 02/10] Build documentation --- man/Belgium.Rd | 5 +++++ man/Brazil.Rd | 5 +++++ man/Canada.Rd | 5 +++++ man/Colombia.Rd | 5 +++++ man/Cuba.Rd | 5 +++++ 5 files changed, 25 insertions(+) diff --git a/man/Belgium.Rd b/man/Belgium.Rd index 1d8f3bcd..16578b4d 100644 --- a/man/Belgium.Rd +++ b/man/Belgium.Rd @@ -64,6 +64,11 @@ each level of regions. For Belgium, there are only additional data for level 1 regions.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } diff --git a/man/Brazil.Rd b/man/Brazil.Rd index 5b625d98..1016a6aa 100644 --- a/man/Brazil.Rd +++ b/man/Brazil.Rd @@ -60,6 +60,11 @@ Subnational data sources available at the city level and is aggregated to provide state data.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } diff --git a/man/Canada.Rd b/man/Canada.Rd index 409f6b72..022d5277 100644 --- a/man/Canada.Rd +++ b/man/Canada.Rd @@ -57,6 +57,11 @@ Subnational data sources across levels.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } diff --git a/man/Colombia.Rd b/man/Colombia.Rd index f80dbeda..e8ff1a8d 100644 --- a/man/Colombia.Rd +++ b/man/Colombia.Rd @@ -56,6 +56,11 @@ Subnational data sources \item{\code{common_data_urls}}{List of named links to raw data.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } diff --git a/man/Cuba.Rd b/man/Cuba.Rd index 501d4547..4b688582 100644 --- a/man/Cuba.Rd +++ b/man/Cuba.Rd @@ -56,6 +56,11 @@ Subnational data sources \item{\code{common_data_urls}}{List of named links to raw data.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } From bb115cae4134b2c0e4bc1cad80f5f2b78d569d85 Mon Sep 17 00:00:00 2001 From: Richard Martin-Nielsen Date: Sat, 26 Jun 2021 22:21:55 +0300 Subject: [PATCH 03/10] Fixed handling of NULL in summary table, completed country data --- R/France.R | 6 ++++++ R/Germany.R | 6 ++++++ R/India.R | 5 +++++ R/Italy.R | 5 +++++ R/Lithuania.R | 6 ++++++ R/Mexico.R | 5 +++++ R/Netherlands.R | 5 +++++ R/SouthAfrica.R | 5 +++++ R/Switzerland.R | 5 +++++ R/UK.R | 5 +++++ R/USA.R | 5 +++++ R/shared-methods.R | 4 ++-- data-raw/render_available_datasets.R | 2 +- data/all_country_data.rda | Bin 2128 -> 2313 bytes 14 files changed, 61 insertions(+), 3 deletions(-) diff --git a/R/France.R b/R/France.R index 5a20ed70..643f6536 100644 --- a/R/France.R +++ b/R/France.R @@ -42,6 +42,12 @@ France <- R6::R6Class("France", # nolint end #' @field source_data_cols existing columns within the raw data source_data_cols = c("cases_new", "tested_new"), + #' @field source_text Plain text description of the source of the data + source_text = "French Public Open Data Platform", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://www.data.gouv.fr/fr/pages/donnees-coronavirus", + #' @description Set up a table of region codes for clean data #' @importFrom tibble tibble diff --git a/R/Germany.R b/R/Germany.R index e639cce1..2eba29b6 100644 --- a/R/Germany.R +++ b/R/Germany.R @@ -36,6 +36,12 @@ Germany <- R6::R6Class("Germany", # nolint end #' @field source_data_cols existing columns within the raw data source_data_cols = c("cases_new", "deaths_new"), + #' @field source_text Plain text description of the source of the data + source_text = "Robert Koch-Institut (RKI)", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://hub.arcgis.com/datasets/dd4580c810204019a7b8eb3e0b329dd6_0/explore", + #' @description Set up a table of region codes for clean data #' @importFrom tibble tibble diff --git a/R/India.R b/R/India.R index 36321812..56903124 100644 --- a/R/India.R +++ b/R/India.R @@ -30,6 +30,11 @@ India <- R6::R6Class("India", ), #' @field source_data_cols existing columns within the raw data source_data_cols = c("cases_new", "deaths_new", "recovered_new"), + #' @field source_text Plain text description of the source of the data + source_text = "COVID19India", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://www.covid19india.org", #' @description Set up a table of region codes for clean data #' @importFrom tibble tibble diff --git a/R/Italy.R b/R/Italy.R index fc2fca92..30a5b731 100644 --- a/R/Italy.R +++ b/R/Italy.R @@ -35,6 +35,11 @@ Italy <- R6::R6Class("Italy", # nolint end #' @field source_data_cols existing columns within the raw data source_data_cols = c("cases_total", "deaths_total", "tested_total"), + #' @field source_text Plain text description of the source of the data + source_text = "Department of Civil Protection, Italy", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://github.com/pcm-dpc/COVID-19/blob/master/README_EN.md", #' @description Set up a table of region codes for clean data #' @importFrom tibble tibble diff --git a/R/Lithuania.R b/R/Lithuania.R index 68809495..21463288 100644 --- a/R/Lithuania.R +++ b/R/Lithuania.R @@ -154,6 +154,12 @@ Lithuania <- R6::R6Class("Lithuania", source_data_cols = c( "cases_new", "tested_new", "recovered_total", "deaths_new" ), + #' @field source_text Plain text description of the source of the data + source_text = "Lithuanian Statistics Department", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://hub.arcgis.com/datasets/d49a63c934be4f65a93b6273785a8449_0/about", + # Additional attributes specific to the Lithuania functionality #' @field death_definition which criteria of deaths attributed to #' COVID to use diff --git a/R/Mexico.R b/R/Mexico.R index 6f529ed3..4c09e291 100644 --- a/R/Mexico.R +++ b/R/Mexico.R @@ -47,6 +47,11 @@ Mexico <- R6::R6Class("Mexico", ), #' @field source_data_cols existing columns within the raw data source_data_cols = c("cases_new", "deaths_new"), + #' @field source_text Plain text description of the source of the data + source_text = "Government of Mexico", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://datos.covid-19.conacyt.mx", #' @description Set up a table of region codes for clean data #' @importFrom tibble tibble diff --git a/R/Netherlands.R b/R/Netherlands.R index 0bfc4dcf..1cafa9a3 100644 --- a/R/Netherlands.R +++ b/R/Netherlands.R @@ -39,6 +39,11 @@ Netherlands <- R6::R6Class("Netherlands", # nolint end #' @field source_data_cols existing columns within the raw data source_data_cols = c("cases_new", "deaths_new", "hosp_new"), + #' @field source_text Plain text description of the source of the data + source_text = "National Institute for Public Health and the Environment (RIVM), Netherlands", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://data.rivm.nl/covid-19/", #' @description Set up a table of region codes for clean data #' @importFrom tibble tibble diff --git a/R/SouthAfrica.R b/R/SouthAfrica.R index 443607c0..e1b44b8b 100644 --- a/R/SouthAfrica.R +++ b/R/SouthAfrica.R @@ -34,6 +34,11 @@ SouthAfrica <- R6::R6Class("SouthAfrica", # nolint end #' @field source_data_cols existing columns within the raw data source_data_cols = c("cases_new", "deaths_new", "recovered_new"), + #' @field source_text Plain text description of the source of the data + source_text = "Data Science for Social Impact research group, University of Pretoria", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://github.com/dsfsi/covid19za", #' @description Set up a table of region codes for clean data #' @importFrom tibble tibble diff --git a/R/Switzerland.R b/R/Switzerland.R index 0f6bcffa..f3124c47 100644 --- a/R/Switzerland.R +++ b/R/Switzerland.R @@ -62,6 +62,11 @@ Switzerland <- R6::R6Class("Switzerland", "cases_total", "tested_total" ), + #' @field source_text Plain text description of the source of the data + source_text = "Open Data, Canton of Zurich", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://github.com/openZH/covid_19/", #' @description Set up a table of region codes for clean data #' @importFrom tibble tibble diff --git a/R/UK.R b/R/UK.R index a974ad0c..3bbc2840 100644 --- a/R/UK.R +++ b/R/UK.R @@ -101,6 +101,11 @@ UK <- R6::R6Class("UK", "newPillarOneTestsByPublishDate", "newPillarTwoTestsByPublishDate", "newPillarThreeTestsByPublishDate", "newPillarFourTestsByPublishDate" ), + #' @field source_text Plain text description of the source of the data + source_text = "Public Health England", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://coronavirus.data.gov.uk/", #' @description Specific function for getting region codes for UK . set_region_codes = function() { diff --git a/R/USA.R b/R/USA.R index 94772e51..a00b9ece 100644 --- a/R/USA.R +++ b/R/USA.R @@ -42,6 +42,11 @@ USA <- R6::R6Class("USA", # nolint end #' @field source_data_cols existing columns within the raw data source_data_cols = c("cases_total", "deaths_total"), + #' @field source_text Plain text description of the source of the data + source_text = "New York Times", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://github.com/nytimes/covid-19-data", #' @description Set up a table of region codes for clean data #' @importFrom tibble tribble diff --git a/R/shared-methods.R b/R/shared-methods.R index 741a5002..5e8468ef 100644 --- a/R/shared-methods.R +++ b/R/shared-methods.R @@ -511,8 +511,8 @@ DataClass <- R6::R6Class( ), data_urls = paste(unlist(self$data_urls), collapse = ", "), source_data_cols = paste(unlist(self$source_data_cols), collapse = ", "), - source_text = self$source_text, - source_url = self$source_url + source_text = ifelse(is.null(self$source_text), NA, self$source_text), + source_url = ifelse(is.null(self$source_url), NA, self$source_url) ) return(sum_df) }, diff --git a/data-raw/render_available_datasets.R b/data-raw/render_available_datasets.R index 5611e7a7..214d2edc 100644 --- a/data-raw/render_available_datasets.R +++ b/data-raw/render_available_datasets.R @@ -1,4 +1,4 @@ # render available datasets table -all_country_data <- get_regional_data(render = TRUE) +all_country_data <- get_available_datasets(render = TRUE) usethis::use_data(all_country_data, overwrite = TRUE) diff --git a/data/all_country_data.rda b/data/all_country_data.rda index b7f38a510faae21b6f5e3ef75149a85c18dbed08..bcbcf6c012b34d8fb9eb59f6118407d1cf4ff22a 100644 GIT binary patch literal 2313 zcmV+k3HJ6vT4*^jL0KkKS)QbjWdH@j|Mma>YbWgY|NQ^|-_XDR-|#>H005vs2m*kR z00H0$e+>fDB*Fqf1sVVV0|rE=rliVvjCv5KsqBRHM~Z2tjDP^qqd}pgPe?I8RA}0d zPzHogMuM7ZW~lVZG-znh003wJ0MHr$000gE02&5{hK88{8UO&$4GjPQG5`SJ00E$A zXlQAW0iXa40MO6?10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9476dU0?`Dv@Sm*2JQCMh|@3@Cd4k4(ie4 z3rY&Xj<~J~8L_7y%2_PzK|?o`GC;6rYitP2gDR>-GziHZN+B;#^xU&nD%4WC4!3NM*bJ;1sRA47H{P2%lgA0NNuDg{}*yaI8cx| GTScu?yy~3* From 1de2205233b0d741360b7e637dc3997aac491bf0 Mon Sep 17 00:00:00 2001 From: Richard Martin-Nielsen Date: Sat, 26 Jun 2021 22:56:21 +0300 Subject: [PATCH 04/10] Render documentation, generate available datasets file, lint --- R/Canada.R | 2 +- R/Colombia.R | 4 ++-- R/Cuba.R | 2 +- R/Germany.R | 2 +- R/Lithuania.R | 2 +- R/Netherlands.R | 2 +- R/SouthAfrica.R | 2 +- data/all_country_data.rda | Bin 2313 -> 2639 bytes man/France.Rd | 5 +++++ man/Germany.Rd | 5 +++++ man/India.Rd | 5 +++++ man/Italy.Rd | 5 +++++ man/Lithuania.Rd | 5 +++++ man/Mexico.Rd | 5 +++++ man/Netherlands.Rd | 5 +++++ man/SouthAfrica.Rd | 5 +++++ man/Switzerland.Rd | 5 +++++ man/UK.Rd | 5 +++++ man/USA.Rd | 5 +++++ man/all_country_data.Rd | 2 +- .../custom_data/Switzerland_level_1.rds | Bin 0 -> 5490 bytes tests/testthat/test-DataClass.R | 2 +- tests/testthat/test-get_available_datasets.R | 9 +++++++-- 23 files changed, 72 insertions(+), 12 deletions(-) create mode 100644 tests/testthat/custom_data/Switzerland_level_1.rds diff --git a/R/Canada.R b/R/Canada.R index 9180ea33..e5b09b53 100644 --- a/R/Canada.R +++ b/R/Canada.R @@ -42,7 +42,7 @@ Canada <- R6::R6Class("Canada", #' @field source_url Website address for explanation/introduction of the #' data source_url = "https://open.canada.ca/data/en/dataset/261c32ab-4cfd-4f81-9dea-7b64065690dc", # nolint - + #' @description Set up a table of region codes for clean data #' @importFrom tibble tibble set_region_codes = function() { diff --git a/R/Colombia.R b/R/Colombia.R index edbd0482..c1a3154c 100644 --- a/R/Colombia.R +++ b/R/Colombia.R @@ -35,10 +35,10 @@ Colombia <- R6::R6Class("Colombia", #' @field source_data_cols existing columns within the raw data source_data_cols = c("cases_total"), #' @field source_text Plain text description of the source of the data - source_text = "Daniel Cárdenas", + source_text = "Daniel C\u00e1rdenas", #' @field source_url Website address for explanation/introduction of the #' data - source_url = "https://github.com/danielcs88/colombia_covid-19/", + source_url = "https://github.com/danielcs88/colombia_covid-19/", #' @description Set up a table of region codes for clean data #' @importFrom tibble tibble diff --git a/R/Cuba.R b/R/Cuba.R index 7dc75102..b286652a 100644 --- a/R/Cuba.R +++ b/R/Cuba.R @@ -38,7 +38,7 @@ Cuba <- R6::R6Class("Cuba", source_text = "COVID19 Cuba Data team", #' @field source_url Website address for explanation/introduction of the #' data - source_url = "https://covid19cubadata.github.io/#cuba", + source_url = "https://covid19cubadata.github.io/#cuba", #' @description Set up a table of region codes for clean data diff --git a/R/Germany.R b/R/Germany.R index 2eba29b6..a4108765 100644 --- a/R/Germany.R +++ b/R/Germany.R @@ -40,7 +40,7 @@ Germany <- R6::R6Class("Germany", source_text = "Robert Koch-Institut (RKI)", #' @field source_url Website address for explanation/introduction of the #' data - source_url = "https://hub.arcgis.com/datasets/dd4580c810204019a7b8eb3e0b329dd6_0/explore", + source_url = "https://hub.arcgis.com/datasets/dd4580c810204019a7b8eb3e0b329dd6_0/explore", # nolint #' @description Set up a table of region codes for clean data diff --git a/R/Lithuania.R b/R/Lithuania.R index 21463288..a1b891fe 100644 --- a/R/Lithuania.R +++ b/R/Lithuania.R @@ -158,7 +158,7 @@ Lithuania <- R6::R6Class("Lithuania", source_text = "Lithuanian Statistics Department", #' @field source_url Website address for explanation/introduction of the #' data - source_url = "https://hub.arcgis.com/datasets/d49a63c934be4f65a93b6273785a8449_0/about", + source_url = "https://hub.arcgis.com/datasets/d49a63c934be4f65a93b6273785a8449_0/about", # nolint # Additional attributes specific to the Lithuania functionality #' @field death_definition which criteria of deaths attributed to diff --git a/R/Netherlands.R b/R/Netherlands.R index 1cafa9a3..94a4fc55 100644 --- a/R/Netherlands.R +++ b/R/Netherlands.R @@ -40,7 +40,7 @@ Netherlands <- R6::R6Class("Netherlands", #' @field source_data_cols existing columns within the raw data source_data_cols = c("cases_new", "deaths_new", "hosp_new"), #' @field source_text Plain text description of the source of the data - source_text = "National Institute for Public Health and the Environment (RIVM), Netherlands", + source_text = "National Institute for Public Health and the Environment (RIVM), Netherlands", # nolint #' @field source_url Website address for explanation/introduction of the #' data source_url = "https://data.rivm.nl/covid-19/", diff --git a/R/SouthAfrica.R b/R/SouthAfrica.R index e1b44b8b..ba83e17e 100644 --- a/R/SouthAfrica.R +++ b/R/SouthAfrica.R @@ -35,7 +35,7 @@ SouthAfrica <- R6::R6Class("SouthAfrica", #' @field source_data_cols existing columns within the raw data source_data_cols = c("cases_new", "deaths_new", "recovered_new"), #' @field source_text Plain text description of the source of the data - source_text = "Data Science for Social Impact research group, University of Pretoria", + source_text = "Data Science for Social Impact research group, University of Pretoria", # nolint #' @field source_url Website address for explanation/introduction of the #' data source_url = "https://github.com/dsfsi/covid19za", diff --git a/data/all_country_data.rda b/data/all_country_data.rda index bcbcf6c012b34d8fb9eb59f6118407d1cf4ff22a..ce4d5cad9d2bb89dbb05ace2caf6df251b88af44 100644 GIT binary patch literal 2639 zcmV-V3b6G;T4*^jL0KkKS&4Z6eEZ$JL`|NQ^|-|)Zx-|#>H005vs2m*kR z00H0%-+g`OcD?R&g>?rQ^zOg|T?3;*&@xmpNuVV?sifL^6HKPsKy4}NdY+KbGH3y& zjR0w*GDe0csp$cr(12)yDZMGDl+#C~0iXcL000000MPXZqyTUL8UO*1000IK>o~001-q1JoL5001-q0E$X_o`{;BO-~X7(f|g5rhw2I0002c z27mwnks$#XfK4<_G)!pHX_V8-dQA*WntGZtX{MQ>G}Fo&4H^R{+960UzYL)ivJyf) z8vxtpfcl}tIQblXK3Eq`jUQz5X)Jj+L@R`XeVceLPvaUzVA>J{0`L3nK$!Qni$>uu zwk~N2B{l-rpXB&IH=oQ|mm46$P2PB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vW3a_3o3%(K5N;Kd=A!PU#TC|DY6zDDpD$U?JY4oX&v96vM>JlH@attDnLJBd zlDdG*;DYkXL=GV_QM5D-3~h}JcLn+ub(~V8kYa;ypc2HGjYUJ7L9aFi-(Q>Nt_&`) z-xR{phjCMhlLEk0FqlNexW3>^b$!+&ZQ*RRxn$9UKtRN%;7E}^*{XqH9cI4HoWpZM zwffdxG^UWjOq1cGXm)5rnUN5ZEI>MuuB%#Rn<~&&q$3RMm`JJvFg`#*LX1Xb0^|f2 zDYnluDKoS*xH~DH$Sai4bXJdaFDffWbIoxiYhk3z##>Expx(6CDO?z1 j-Own!I5^LrYBjc}_<;!|keG=i|Ha&qP81|3sU#UdRNz-5 diff --git a/man/France.Rd b/man/France.Rd index 6ffa59c4..fb3d2b12 100644 --- a/man/France.Rd +++ b/man/France.Rd @@ -61,6 +61,11 @@ Subnational data sources specific.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } diff --git a/man/Germany.Rd b/man/Germany.Rd index e42c2559..bca080b9 100644 --- a/man/Germany.Rd +++ b/man/Germany.Rd @@ -57,6 +57,11 @@ Subnational data sources only entry, is be named main.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } diff --git a/man/India.Rd b/man/India.Rd index 0c7b4fcb..d676bd92 100644 --- a/man/India.Rd +++ b/man/India.Rd @@ -56,6 +56,11 @@ Subnational data sources \item{\code{common_data_urls}}{List of named links to raw data.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } diff --git a/man/Italy.Rd b/man/Italy.Rd index 8c90e2ec..1c527c0a 100644 --- a/man/Italy.Rd +++ b/man/Italy.Rd @@ -57,6 +57,11 @@ Subnational data sources only entry, is be named main.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } diff --git a/man/Lithuania.Rd b/man/Lithuania.Rd index a2d7b7c3..789460d5 100644 --- a/man/Lithuania.Rd +++ b/man/Lithuania.Rd @@ -172,6 +172,11 @@ across levels.} \item{\code{source_data_cols}}{existing columns within the raw data} +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} + \item{\code{death_definition}}{which criteria of deaths attributed to COVID to use} diff --git a/man/Mexico.Rd b/man/Mexico.Rd index bb91e547..5c9c653f 100644 --- a/man/Mexico.Rd +++ b/man/Mexico.Rd @@ -69,6 +69,11 @@ Subnational data sources specific.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } diff --git a/man/Netherlands.Rd b/man/Netherlands.Rd index 3506f813..d1fe4ff0 100644 --- a/man/Netherlands.Rd +++ b/man/Netherlands.Rd @@ -61,6 +61,11 @@ Subnational data sources only entry, is be named main.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } diff --git a/man/SouthAfrica.Rd b/man/SouthAfrica.Rd index e4f59c88..78c0b096 100644 --- a/man/SouthAfrica.Rd +++ b/man/SouthAfrica.Rd @@ -56,6 +56,11 @@ Subnational data sources \item{\code{common_data_urls}}{List of named links to raw data.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } diff --git a/man/Switzerland.Rd b/man/Switzerland.Rd index aa01c448..90e35976 100644 --- a/man/Switzerland.Rd +++ b/man/Switzerland.Rd @@ -81,6 +81,11 @@ Subnational data sources \item{\code{common_data_urls}}{List of named links to raw data.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } diff --git a/man/UK.Rd b/man/UK.Rd index 05433eed..c70c18c1 100644 --- a/man/UK.Rd +++ b/man/UK.Rd @@ -108,6 +108,11 @@ specific.} \item{\code{source_data_cols}}{existing columns within the raw data} +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} + \item{\code{query_filters}}{Set what filters to use to query the data} \item{\code{nhsregions}}{Whether to include NHS regions in the data} diff --git a/man/USA.Rd b/man/USA.Rd index 552c7b4e..ff36de2f 100644 --- a/man/USA.Rd +++ b/man/USA.Rd @@ -57,6 +57,11 @@ Subnational data sources specific.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } diff --git a/man/all_country_data.Rd b/man/all_country_data.Rd index fbd43e34..d8dcc66b 100644 --- a/man/all_country_data.Rd +++ b/man/all_country_data.Rd @@ -6,7 +6,7 @@ \title{Table of available datasets along with level and other information. Rendered from the individual R6 class objects included in this package.} \format{ -An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 22 rows and 8 columns. +An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 22 rows and 10 columns. } \usage{ all_country_data diff --git a/tests/testthat/custom_data/Switzerland_level_1.rds b/tests/testthat/custom_data/Switzerland_level_1.rds new file mode 100644 index 0000000000000000000000000000000000000000..0206b40f80b3e71632b0da1a8c9390c0f5cf291a GIT binary patch literal 5490 zcma*rS2!C0-!^cqDz(yDwbN46RxL53rK&nmqiPhTW)ZW5m~CmTv}P$%t7^ucv1-p~ zjaVUOY(i6sNb)|{bM$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mldy5jXx;*iGoF~CszX&QobX|l=y{+s`eX*5fy+2FuTBb6n_cVonvqs zuFVLup5#EJqsytON@JzyumMWTo!nxJoTXi8nILFr`72TTPJ-{TFNhuX=h4$eM2Pme zh&64^m%sL&X_WMa-trLr&mT+=5Rbb}k@#UfE_{jZK^`@k-H(Vc$fZK!m&wN-8eVTw zLJo;fWfKxSprC$fV8E*tvp*A=&p00@-jgD(c`CHGHH$3VyO}GtFsL* zEz2!J4|8$}BySo>(j@41aHEQznTUpT$(To`4>2%leO5sC=R2e27ctiNU~DB317=<- zq{r|=cm2d4sTG>sr4=QW6-FKx8+$PG)8^4~$BCOAsu9JCcBo*H{iaPZIl5!?@2BDm zuS@s}xU|Cg_Tsbn8^0)eC%rBH>1?uOa~@$LLmVyf=LxZzH3i46U;fu&i}mEf(*=9{uSn?_`l; zTO6zxf{c*)++QdCdDy+z++3rrZtS1^5&Oy;t6$c%C+1!(k|-t$PMPYnKwpcmy-_9* z62*8=SV4c)RE_@G+a$WMKFoLb^VT literal 0 HcmV?d00001 diff --git a/tests/testthat/test-DataClass.R b/tests/testthat/test-DataClass.R index e03415d0..4584550a 100644 --- a/tests/testthat/test-DataClass.R +++ b/tests/testthat/test-DataClass.R @@ -114,7 +114,7 @@ test_that("DataClass returns a summary", { names(sum), c( "origin", "class", "level_1_region", "level_2_region", "level_3_region", - "type", "data_urls", "source_data_cols" + "type", "data_urls", "source_data_cols", "source_text", "source_url" ) ) expect_true(sum$class[1] == "D") diff --git a/tests/testthat/test-get_available_datasets.R b/tests/testthat/test-get_available_datasets.R index d1a2b3c2..f6583a66 100644 --- a/tests/testthat/test-get_available_datasets.R +++ b/tests/testthat/test-get_available_datasets.R @@ -9,7 +9,8 @@ test_that( expected_names <- c( "origin", "class", "level_1_region", "level_2_region", "level_3_region", "type", - "data_urls", "source_data_cols" + "data_urls", "source_data_cols", + "source_text", "source_url" ) expect_identical(colnames(data), expected_names) } @@ -41,7 +42,11 @@ test_that( # test each column for na values for (name in colnames(data)) { - if (name %in% c("level_1_region", "level_2_region", "level_3_region")) { + if (name %in% c("level_1_region", + "level_2_region", + "level_3_region", + "source_text", + "source_url")) { next } test_that( From 40d0b9d2fd1cb46134a3fd1fe5204ff7c994d11f Mon Sep 17 00:00:00 2001 From: Richard Martin-Nielsen Date: Tue, 29 Jun 2021 19:33:11 +0300 Subject: [PATCH 05/10] Add source fields for country and global sources. --- R/Covid19DataHub.R | 5 +++++ R/ECDC.R | 5 +++++ R/Google.R | 6 ++++++ R/JHU.R | 5 +++++ R/JRC.R | 6 ++++++ R/SouthAfrica.R | 1 - R/WHO.R | 6 ++++++ data/all_country_data.rda | Bin 2639 -> 2809 bytes man/Covid19DataHub.Rd | 5 +++++ man/ECDC.Rd | 5 +++++ man/Google.Rd | 5 +++++ man/JHU.Rd | 5 +++++ man/JRC.Rd | 5 +++++ man/WHO.Rd | 5 +++++ 14 files changed, 63 insertions(+), 1 deletion(-) diff --git a/R/Covid19DataHub.R b/R/Covid19DataHub.R index 1c4b537e..32dca9ea 100644 --- a/R/Covid19DataHub.R +++ b/R/Covid19DataHub.R @@ -93,6 +93,11 @@ Covid19DataHub <- R6::R6Class("Covid19DataHub", # nolint end #' @field source_data_cols existing columns within the raw data source_data_cols = c("confirmed", "deaths", "recovered", "tested", "hosp"), + #' @field source_text Plain text description of the source of the data + source_text = "COVID-19 Data Hub", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://covid19datahub.io", #' @description Covid19 Data Hub specific data cleaning. #' This takes all the raw data, renames some columns and checks types. diff --git a/R/ECDC.R b/R/ECDC.R index 039b2e5a..a15c75b8 100644 --- a/R/ECDC.R +++ b/R/ECDC.R @@ -36,6 +36,11 @@ ECDC <- R6::R6Class("ECDC", ), #' @field source_data_cols existing columns within the raw data source_data_cols = c("cases_new", "deaths_new"), + #' @field source_text Plain text description of the source of the data + source_text = "European Centre for Disease Prevention and Control (ECDC)", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://www.ecdc.europa.eu/en/publications-data/download-todays-data-geographic-distribution-covid-19-cases-worldwide", # nolint #' @description ECDC specific state level data cleaning #' @importFrom dplyr mutate rename select arrange filter diff --git a/R/Google.R b/R/Google.R index b9de9902..f2f47a6b 100644 --- a/R/Google.R +++ b/R/Google.R @@ -84,6 +84,12 @@ Google <- R6::R6Class("Google", "total_recovered", "total_tested" ), + #' @field source_text Plain text description of the source of the data + source_text = "O. Wahltinez and others", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://github.com/GoogleCloudPlatform/covid-19-open-data", + #' @description GoogleData specific subregion2 level data cleaning. This #' takes all the raw data, puts into a single data frame, renames some #' columns and checks types. diff --git a/R/JHU.R b/R/JHU.R index c05db715..4d303593 100644 --- a/R/JHU.R +++ b/R/JHU.R @@ -77,6 +77,11 @@ JHU <- R6::R6Class("JHU", # rename to country name # nolint end #' @field source_data_cols existing columns within the raw data source_data_cols = c("confirmed", "deaths", "recovered"), + #' @field source_text Plain text description of the source of the data + source_text = "Center for Systems Science and Engineering (CSSE) at Johns Hopkins University (JHU)", # nolint + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://github.com/CSSEGISandData/COVID-19/", #' @description Set up a table of region codes for clean data #' @importFrom tibble tibble diff --git a/R/JRC.R b/R/JRC.R index a6c2cf69..d378f5ab 100644 --- a/R/JRC.R +++ b/R/JRC.R @@ -61,6 +61,12 @@ JRC <- R6::R6Class("JRC", "Hospitalized", "IntensiveCare" ), + #' @field source_text Plain text description of the source of the data + source_text = "European Commission Joint Research Centre (JRC)", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://github.com/ec-jrc/COVID-19", + #' @description JRC specific data cleaning. The raw source data columns are #' converted to the correct type and renamed appropriately to match the diff --git a/R/SouthAfrica.R b/R/SouthAfrica.R index ba83e17e..152ca767 100644 --- a/R/SouthAfrica.R +++ b/R/SouthAfrica.R @@ -42,7 +42,6 @@ SouthAfrica <- R6::R6Class("SouthAfrica", #' @description Set up a table of region codes for clean data #' @importFrom tibble tibble - #' @importFrom dplyr mutate set_region_codes = function() { self$codes_lookup$`1` <- tibble( code = c( diff --git a/R/WHO.R b/R/WHO.R index c866f833..bf1513d4 100644 --- a/R/WHO.R +++ b/R/WHO.R @@ -38,6 +38,12 @@ WHO <- R6::R6Class("WHO", "deaths_new", "deaths_total" ), + #' @field source_text Plain text description of the source of the data + source_text = "World Health Organisation", + #' @field source_url Website address for explanation/introduction of the + #' data + source_url = "https://covid19.who.int", + #' @description WHO specific data cleaning #' @importFrom dplyr mutate rename diff --git a/data/all_country_data.rda b/data/all_country_data.rda index ce4d5cad9d2bb89dbb05ace2caf6df251b88af44..c13613fdca58bf2a0a44aa725c56f37c97fc5a76 100644 GIT binary patch literal 2809 zcmVo5!fA#Qk|NQ^|-|)Zx-|#>H005vs2m*kR z00H0&zk6XrKm!4c2HKPZGXMsF281OwAsQ1COiih#gz*!~dYeKrdV@xWfYa1tQJ^#% zO-6=I9*`Ow0002c0009(4FCYp00Te(00F=N01W^D05ky501W^DGynhq2@;xUnv>H+ z7|6V zXk@z?cI%hM&sk{-!3_xpxBKl_NP9-LS}+C6$0_z!6$+ruxSTBhq7rD=UG&-P`qzlJlf-Fowb zb13D0$t<6DI08KhBngQL4T*yYX$b>ZOuz>UEv5!4p@5k}Ni?El6sKk770a$39%bBb z=ec7AZ+!m3*x{#nOm({(%x`iv*0z=UtA*wh#~S5Z%&k0fk7Wye?yT<5zn^7oyNp8G1R+u4$s;QwGy) zZX?egWUEv*q@bZzQ4lf$%}sh68yiDxP0m~iM~{Pc?mkVb*wb zu+u^fBf!Wx9ONk=s(_axfPS7_i)M9~o%T^-sC>k_AU(_ab^NG8_U^-{4gZf+G|b^! zK;XPlBHiynD-Xm=GVY@cWTJ=cnG3N({ROa6T|OC@8>@N74cFgrOsMRsjS(4PaBRB7 zflqW1+0)nG9}vi6%(EK84S7ukX|i{7b(aLxt2!&nR9?V)`VHMC;*5!$=Sjz7w7yc% zJyPsp*ul1#)6~KkqDoAZNinO4LbRpk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c>;12n<9A99c=WEhe##^E~$8PAb9XH#I(@OF<60s6jP6;TA)MZ2_31k#SWb z2N0O3+8PFiHpYfKLhUORh^0ZuGoa-Z2`uVjHLAm{k;G=ax6Si>Ro=qdjbfNsF!8E$ zGGJ7NMS7S-#k{)EOMQK(t-PU8pyD$H($eH)z|O%CF)6qbBu~PvpsEA5+dTcLhH;@- z`q$TZ(xO8`p(n>vXmMVIoD;!HN|Y3enPRQP!F;BkxhY#&B)NTtVUae{1;C7Ir3yfl zNe(qq(oP~B7%a`-kc&TkGtfy|rh}X^?*+wTuxCux;9D4ZG?@6ycGk;KS*NJPAUzJTZ3&eZ?_ diff --git a/man/Covid19DataHub.Rd b/man/Covid19DataHub.Rd index bad7084e..b305691f 100644 --- a/man/Covid19DataHub.Rd +++ b/man/Covid19DataHub.Rd @@ -113,6 +113,11 @@ Subnational data sources only entry, is be named main.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } diff --git a/man/ECDC.Rd b/man/ECDC.Rd index 5a434176..7b501efb 100644 --- a/man/ECDC.Rd +++ b/man/ECDC.Rd @@ -46,6 +46,11 @@ National data sources \item{\code{common_data_urls}}{List of named links to raw data.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } diff --git a/man/Google.Rd b/man/Google.Rd index 3fbe62d2..a4ff31af 100644 --- a/man/Google.Rd +++ b/man/Google.Rd @@ -102,6 +102,11 @@ Subnational data sources \item{\code{common_data_urls}}{List of named links to raw data.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } diff --git a/man/JHU.Rd b/man/JHU.Rd index 2512b07b..53e56a88 100644 --- a/man/JHU.Rd +++ b/man/JHU.Rd @@ -107,6 +107,11 @@ Subnational data sources only entry, is be named main.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } diff --git a/man/JRC.Rd b/man/JRC.Rd index 7db7544a..50cdcac7 100644 --- a/man/JRC.Rd +++ b/man/JRC.Rd @@ -59,6 +59,11 @@ National data sources \item{\code{level_data_urls}}{List of named links to raw data.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } diff --git a/man/WHO.Rd b/man/WHO.Rd index fbebb18b..6cc63911 100644 --- a/man/WHO.Rd +++ b/man/WHO.Rd @@ -45,6 +45,11 @@ National data sources only entry, is be named main.} \item{\code{source_data_cols}}{existing columns within the raw data} + +\item{\code{source_text}}{Plain text description of the source of the data} + +\item{\code{source_url}}{Website address for explanation/introduction of the +data} } \if{html}{\out{}} } From 4a07fd16f2a4bad9926cd427302eec1dc06acd77 Mon Sep 17 00:00:00 2001 From: seabbs Date: Thu, 1 Jul 2021 09:53:32 +0000 Subject: [PATCH 06/10] switch to devcontainer --- .Rbuildignore | 1 + .devcontainer/Dockerfile | 39 ++ .devcontainer/devcontainer.json | 41 ++ .../library-scripts/common-debian.sh | 451 ++++++++++++++++++ .github/workflows/check-full.yaml | 2 +- Dockerfile | 13 - 6 files changed, 533 insertions(+), 14 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/library-scripts/common-debian.sh delete mode 100644 Dockerfile diff --git a/.Rbuildignore b/.Rbuildignore index a30f3852..4833a33f 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -27,3 +27,4 @@ SMG.md ^.*.pdf$ ^inst/paper$ ^inst/examples$ +^\.devcontainer$ \ No newline at end of file diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..223a1cbe --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,39 @@ +# R version: latest, ... ,4.0.1 , 4.0.0 +ARG VARIANT="latest" +FROM rocker/verse:${VARIANT} + +# Use the [Option] comment to specify true/false arguments that should appear in VS Code UX +# +# [Option] Install zsh +ARG INSTALL_ZSH="true" +# [Option] Upgrade OS packages to their latest versions +ARG UPGRADE_PACKAGES="false" + +# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies. +ARG USERNAME=vscode +ARG USER_UID=1000 +ARG USER_GID=$USER_UID +COPY library-scripts/*.sh /tmp/library-scripts/ +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \ + && usermod -a -G staff ${USERNAME} \ + && apt-get -y install \ + python3-pip \ + libgit2-dev \ + libcurl4-openssl-dev \ + libssl-dev \ + libxml2-dev \ + libxt-dev \ + && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts \ + && python3 -m pip --no-cache-dir install radian \ + && install2.r --error --skipinstalled --repos ${CRAN} --ncpus -1 \ + devtools \ + languageserver \ + && rm -rf /tmp/downloaded_packages + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update \ +# && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +RUN Rscript -e "devtools::install_dev_deps()" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..06c14b14 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,41 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.183.0/containers/r +{ + "name": "R (Community)", + "build": { + "dockerfile": "Dockerfile", + // Update VARIANT to pick a specific R version: latest, ... ,4.0.1 , 4.0.0 + "args": { "VARIANT": "latest" } + }, + + // Set *default* container specific settings.json values on container create. + "settings": { + "r.rterm.linux": "/usr/local/bin/radian", + "r.bracketedPaste": true, + "r.sessionWatcher": true, + "[r]": { + "editor.wordSeparators": "`~!@#%$^&*()-=+[{]}\\|;:'\",<>/?" + } + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ikuyadeu.r", + "reditorsupport.r-lsp" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "R --version", + + // Uncomment to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker. + // "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ], + + // Uncomment when using a ptrace-based debugger like C++, Go, and Rust + // "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" +} diff --git a/.devcontainer/library-scripts/common-debian.sh b/.devcontainer/library-scripts/common-debian.sh new file mode 100644 index 00000000..009d9e64 --- /dev/null +++ b/.devcontainer/library-scripts/common-debian.sh @@ -0,0 +1,451 @@ +#!/usr/bin/env bash +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- +# +# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/common.md +# Maintainer: The VS Code and Codespaces Teams +# +# Syntax: ./common-debian.sh [install zsh flag] [username] [user UID] [user GID] [upgrade packages flag] [install Oh My Zsh! flag] [Add non-free packages] + +INSTALL_ZSH=${1:-"true"} +USERNAME=${2:-"automatic"} +USER_UID=${3:-"automatic"} +USER_GID=${4:-"automatic"} +UPGRADE_PACKAGES=${5:-"true"} +INSTALL_OH_MYS=${6:-"true"} +ADD_NON_FREE_PACKAGES=${7:-"false"} + +set -e + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +# Ensure that login shells get the correct path if the user updated the PATH using ENV. +rm -f /etc/profile.d/00-restore-env.sh +echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh +chmod +x /etc/profile.d/00-restore-env.sh + +# If in automatic mode, determine if a user already exists, if not use vscode +if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then + USERNAME="" + POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") + for CURRENT_USER in ${POSSIBLE_USERS[@]}; do + if id -u ${CURRENT_USER} > /dev/null 2>&1; then + USERNAME=${CURRENT_USER} + break + fi + done + if [ "${USERNAME}" = "" ]; then + USERNAME=vscode + fi +elif [ "${USERNAME}" = "none" ]; then + USERNAME=root + USER_UID=0 + USER_GID=0 +fi + +# Load markers to see which steps have already run +MARKER_FILE="/usr/local/etc/vscode-dev-containers/common" +if [ -f "${MARKER_FILE}" ]; then + echo "Marker file found:" + cat "${MARKER_FILE}" + source "${MARKER_FILE}" +fi + +# Ensure apt is in non-interactive to avoid prompts +export DEBIAN_FRONTEND=noninteractive + +# Function to call apt-get if needed +apt-get-update-if-needed() +{ + if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update + else + echo "Skipping apt-get update." + fi +} + +# Run install apt-utils to avoid debconf warning then verify presence of other common developer tools and dependencies +if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then + + PACKAGE_LIST="apt-utils \ + git \ + openssh-client \ + gnupg2 \ + iproute2 \ + procps \ + lsof \ + htop \ + net-tools \ + psmisc \ + curl \ + wget \ + rsync \ + ca-certificates \ + unzip \ + zip \ + nano \ + vim-tiny \ + less \ + jq \ + lsb-release \ + apt-transport-https \ + dialog \ + libc6 \ + libgcc1 \ + libkrb5-3 \ + libgssapi-krb5-2 \ + libicu[0-9][0-9] \ + liblttng-ust0 \ + libstdc++6 \ + zlib1g \ + locales \ + sudo \ + ncdu \ + man-db \ + strace \ + manpages \ + manpages-dev \ + init-system-helpers" + + # Needed for adding manpages-posix and manpages-posix-dev which are non-free packages in Debian + if [ "${ADD_NON_FREE_PACKAGES}" = "true" ]; then + CODENAME="$(cat /etc/os-release | grep -oE '^VERSION_CODENAME=.+$' | cut -d'=' -f2)" + sed -i -E "s/deb http:\/\/(deb|httpredir)\.debian\.org\/debian ${CODENAME} main/deb http:\/\/\1\.debian\.org\/debian ${CODENAME} main contrib non-free/" /etc/apt/sources.list + sed -i -E "s/deb-src http:\/\/(deb|httredir)\.debian\.org\/debian ${CODENAME} main/deb http:\/\/\1\.debian\.org\/debian ${CODENAME} main contrib non-free/" /etc/apt/sources.list + sed -i -E "s/deb http:\/\/(deb|httpredir)\.debian\.org\/debian ${CODENAME}-updates main/deb http:\/\/\1\.debian\.org\/debian ${CODENAME}-updates main contrib non-free/" /etc/apt/sources.list + sed -i -E "s/deb-src http:\/\/(deb|httpredir)\.debian\.org\/debian ${CODENAME}-updates main/deb http:\/\/\1\.debian\.org\/debian ${CODENAME}-updates main contrib non-free/" /etc/apt/sources.list + sed -i "s/deb http:\/\/security\.debian\.org\/debian-security ${CODENAME}\/updates main/deb http:\/\/security\.debian\.org\/debian-security ${CODENAME}\/updates main contrib non-free/" /etc/apt/sources.list + sed -i "s/deb-src http:\/\/security\.debian\.org\/debian-security ${CODENAME}\/updates main/deb http:\/\/security\.debian\.org\/debian-security ${CODENAME}\/updates main contrib non-free/" /etc/apt/sources.list + sed -i "s/deb http:\/\/deb\.debian\.org\/debian ${CODENAME}-backports main/deb http:\/\/deb\.debian\.org\/debian ${CODENAME}-backports main contrib non-free/" /etc/apt/sources.list + sed -i "s/deb-src http:\/\/deb\.debian\.org\/debian ${CODENAME}-backports main/deb http:\/\/deb\.debian\.org\/debian ${CODENAME}-backports main contrib non-free/" /etc/apt/sources.list + echo "Running apt-get update..." + apt-get update + PACKAGE_LIST="${PACKAGE_LIST} manpages-posix manpages-posix-dev" + else + apt-get-update-if-needed + fi + + # Install libssl1.1 if available + if [[ ! -z $(apt-cache --names-only search ^libssl1.1$) ]]; then + PACKAGE_LIST="${PACKAGE_LIST} libssl1.1" + fi + + # Install appropriate version of libssl1.0.x if available + LIBSSL=$(dpkg-query -f '${db:Status-Abbrev}\t${binary:Package}\n' -W 'libssl1\.0\.?' 2>&1 || echo '') + if [ "$(echo "$LIBSSL" | grep -o 'libssl1\.0\.[0-9]:' | uniq | sort | wc -l)" -eq 0 ]; then + if [[ ! -z $(apt-cache --names-only search ^libssl1.0.2$) ]]; then + # Debian 9 + PACKAGE_LIST="${PACKAGE_LIST} libssl1.0.2" + elif [[ ! -z $(apt-cache --names-only search ^libssl1.0.0$) ]]; then + # Ubuntu 18.04, 16.04, earlier + PACKAGE_LIST="${PACKAGE_LIST} libssl1.0.0" + fi + fi + + echo "Packages to verify are installed: ${PACKAGE_LIST}" + apt-get -y install --no-install-recommends ${PACKAGE_LIST} 2> >( grep -v 'debconf: delaying package configuration, since apt-utils is not installed' >&2 ) + + PACKAGES_ALREADY_INSTALLED="true" +fi + +# Get to latest versions of all packages +if [ "${UPGRADE_PACKAGES}" = "true" ]; then + apt-get-update-if-needed + apt-get -y upgrade --no-install-recommends + apt-get autoremove -y +fi + +# Ensure at least the en_US.UTF-8 UTF-8 locale is available. +# Common need for both applications and things like the agnoster ZSH theme. +if [ "${LOCALE_ALREADY_SET}" != "true" ] && ! grep -o -E '^\s*en_US.UTF-8\s+UTF-8' /etc/locale.gen > /dev/null; then + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen + locale-gen + LOCALE_ALREADY_SET="true" +fi + +# Create or update a non-root user to match UID/GID. +if id -u ${USERNAME} > /dev/null 2>&1; then + # User exists, update if needed + if [ "${USER_GID}" != "automatic" ] && [ "$USER_GID" != "$(id -G $USERNAME)" ]; then + groupmod --gid $USER_GID $USERNAME + usermod --gid $USER_GID $USERNAME + fi + if [ "${USER_UID}" != "automatic" ] && [ "$USER_UID" != "$(id -u $USERNAME)" ]; then + usermod --uid $USER_UID $USERNAME + fi +else + # Create user + if [ "${USER_GID}" = "automatic" ]; then + groupadd $USERNAME + else + groupadd --gid $USER_GID $USERNAME + fi + if [ "${USER_UID}" = "automatic" ]; then + useradd -s /bin/bash --gid $USERNAME -m $USERNAME + else + useradd -s /bin/bash --uid $USER_UID --gid $USERNAME -m $USERNAME + fi +fi + +# Add add sudo support for non-root user +if [ "${USERNAME}" != "root" ] && [ "${EXISTING_NON_ROOT_USER}" != "${USERNAME}" ]; then + echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME + chmod 0440 /etc/sudoers.d/$USERNAME + EXISTING_NON_ROOT_USER="${USERNAME}" +fi + +# ** Shell customization section ** +if [ "${USERNAME}" = "root" ]; then + USER_RC_PATH="/root" +else + USER_RC_PATH="/home/${USERNAME}" +fi + +# .bashrc/.zshrc snippet +RC_SNIPPET="$(cat << 'EOF' + +if [ -z "${USER}" ]; then export USER=$(whoami); fi +if [[ "${PATH}" != *"$HOME/.local/bin"* ]]; then export PATH="${PATH}:$HOME/.local/bin"; fi + +# Display optional first run image specific notice if configured and terminal is interactive +if [ -t 1 ] && [[ "${TERM_PROGRAM}" = "vscode" || "${TERM_PROGRAM}" = "codespaces" ]] && [ ! -f "$HOME/.config/vscode-dev-containers/first-run-notice-already-displayed" ]; then + if [ -f "/usr/local/etc/vscode-dev-containers/first-run-notice.txt" ]; then + cat "/usr/local/etc/vscode-dev-containers/first-run-notice.txt" + elif [ -f "/workspaces/.codespaces/shared/first-run-notice.txt" ]; then + cat "/workspaces/.codespaces/shared/first-run-notice.txt" + fi + mkdir -p "$HOME/.config/vscode-dev-containers" + # Mark first run notice as displayed after 10s to avoid problems with fast terminal refreshes hiding it + ((sleep 10s; touch "$HOME/.config/vscode-dev-containers/first-run-notice-already-displayed") &) +fi + +EOF +)" + +# code shim, it fallbacks to code-insiders if code is not available +cat << 'EOF' > /usr/local/bin/code +#!/bin/sh + +get_in_path_except_current() { + which -a "$1" | grep -A1 "$0" | grep -v "$0" +} + +code="$(get_in_path_except_current code)" + +if [ -n "$code" ]; then + exec "$code" "$@" +elif [ "$(command -v code-insiders)" ]; then + exec code-insiders "$@" +else + echo "code or code-insiders is not installed" >&2 + exit 127 +fi +EOF +chmod +x /usr/local/bin/code + +# systemctl shim - tells people to use 'service' if systemd is not running +cat << 'EOF' > /usr/local/bin/systemctl +#!/bin/sh +set -e +if [ -d "/run/systemd/system" ]; then + exec /bin/systemctl/systemctl "$@" +else + echo '\n"systemd" is not running in this container due to its overhead.\nUse the "service" command to start services intead. e.g.: \n\nservice --status-all' +fi +EOF +chmod +x /usr/local/bin/systemctl + +# Codespaces bash and OMZ themes - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme +CODESPACES_BASH="$(cat \ +<<'EOF' + +# Codespaces bash prompt theme +__bash_prompt() { + local userpart='`export XIT=$? \ + && [ ! -z "${GITHUB_USER}" ] && echo -n "\[\033[0;32m\]@${GITHUB_USER} " || echo -n "\[\033[0;32m\]\u " \ + && [ "$XIT" -ne "0" ] && echo -n "\[\033[1;31m\]➜" || echo -n "\[\033[0m\]➜"`' + local gitbranch='`\ + export BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null); \ + if [ "${BRANCH}" = "HEAD" ]; then \ + export BRANCH=$(git describe --contains --all HEAD 2>/dev/null); \ + fi; \ + if [ "${BRANCH}" != "" ]; then \ + echo -n "\[\033[0;36m\](\[\033[1;31m\]${BRANCH}" \ + && if git ls-files --error-unmatch -m --directory --no-empty-directory -o --exclude-standard ":/*" > /dev/null 2>&1; then \ + echo -n " \[\033[1;33m\]✗"; \ + fi \ + && echo -n "\[\033[0;36m\]) "; \ + fi`' + local lightblue='\[\033[1;34m\]' + local removecolor='\[\033[0m\]' + PS1="${userpart} ${lightblue}\w ${gitbranch}${removecolor}\$ " + unset -f __bash_prompt +} +__bash_prompt + +EOF +)" +CODESPACES_ZSH="$(cat \ +<<'EOF' +__zsh_prompt() { + local prompt_username + if [ ! -z "${GITHUB_USER}" ]; then + prompt_username="@${GITHUB_USER}" + else + prompt_username="%n" + fi + PROMPT="%{$fg[green]%}${prompt_username} %(?:%{$reset_color%}➜ :%{$fg_bold[red]%}➜ )" # User/exit code arrow + PROMPT+='%{$fg_bold[blue]%}%(5~|%-1~/…/%3~|%4~)%{$reset_color%} ' # cwd + PROMPT+='$(git_prompt_info)%{$fg[white]%}$ %{$reset_color%}' # Git status + unset -f __zsh_prompt +} +ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[cyan]%}(%{$fg_bold[red]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " +ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg_bold[yellow]%}✗%{$fg_bold[cyan]%})" +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[cyan]%})" +__zsh_prompt +EOF +)" + +# Add notice that Oh My Bash! has been removed from images and how to provide information on how to install manually +OMB_README="$(cat \ +<<'EOF' +"Oh My Bash!" has been removed from this image in favor of a simple shell prompt. If you +still wish to use it, remove "~/.oh-my-bash" and install it from: https://github.com/ohmybash/oh-my-bash +You may also want to consider "Bash-it" as an alternative: https://github.com/bash-it/bash-it +See here for infomation on adding it to your image or dotfiles: https://aka.ms/codespaces/omb-remove +EOF +)" +OMB_STUB="$(cat \ +<<'EOF' +#!/usr/bin/env bash +if [ -t 1 ]; then + cat $HOME/.oh-my-bash/README.md +fi +EOF +)" + +# Add RC snippet and custom bash prompt +if [ "${RC_SNIPPET_ALREADY_ADDED}" != "true" ]; then + echo "${RC_SNIPPET}" >> /etc/bash.bashrc + echo "${CODESPACES_BASH}" >> "${USER_RC_PATH}/.bashrc" + echo 'export PROMPT_DIRTRIM=4' >> "${USER_RC_PATH}/.bashrc" + if [ "${USERNAME}" != "root" ]; then + echo "${CODESPACES_BASH}" >> "/root/.bashrc" + echo 'export PROMPT_DIRTRIM=4' >> "/root/.bashrc" + fi + chown ${USERNAME}:${USERNAME} "${USER_RC_PATH}/.bashrc" + RC_SNIPPET_ALREADY_ADDED="true" +fi + +# Add stub for Oh My Bash! +if [ ! -d "${USER_RC_PATH}/.oh-my-bash}" ] && [ "${INSTALL_OH_MYS}" = "true" ]; then + mkdir -p "${USER_RC_PATH}/.oh-my-bash" "/root/.oh-my-bash" + echo "${OMB_README}" >> "${USER_RC_PATH}/.oh-my-bash/README.md" + echo "${OMB_STUB}" >> "${USER_RC_PATH}/.oh-my-bash/oh-my-bash.sh" + chmod +x "${USER_RC_PATH}/.oh-my-bash/oh-my-bash.sh" + if [ "${USERNAME}" != "root" ]; then + echo "${OMB_README}" >> "/root/.oh-my-bash/README.md" + echo "${OMB_STUB}" >> "/root/.oh-my-bash/oh-my-bash.sh" + chmod +x "/root/.oh-my-bash/oh-my-bash.sh" + fi + chown -R "${USERNAME}:${USERNAME}" "${USER_RC_PATH}/.oh-my-bash" +fi + +# Optionally install and configure zsh and Oh My Zsh! +if [ "${INSTALL_ZSH}" = "true" ]; then + if ! type zsh > /dev/null 2>&1; then + apt-get-update-if-needed + apt-get install -y zsh + fi + if [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then + echo "${RC_SNIPPET}" >> /etc/zsh/zshrc + ZSH_ALREADY_INSTALLED="true" + fi + + # Adapted, simplified inline Oh My Zsh! install steps that adds, defaults to a codespaces theme. + # See https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh for official script. + OH_MY_INSTALL_DIR="${USER_RC_PATH}/.oh-my-zsh" + if [ ! -d "${OH_MY_INSTALL_DIR}" ] && [ "${INSTALL_OH_MYS}" = "true" ]; then + TEMPLATE_PATH="${OH_MY_INSTALL_DIR}/templates/zshrc.zsh-template" + USER_RC_FILE="${USER_RC_PATH}/.zshrc" + umask g-w,o-w + mkdir -p ${OH_MY_INSTALL_DIR} + git clone --depth=1 \ + -c core.eol=lf \ + -c core.autocrlf=false \ + -c fsck.zeroPaddedFilemode=ignore \ + -c fetch.fsck.zeroPaddedFilemode=ignore \ + -c receive.fsck.zeroPaddedFilemode=ignore \ + "https://github.com/ohmyzsh/ohmyzsh" "${OH_MY_INSTALL_DIR}" 2>&1 + echo -e "$(cat "${TEMPLATE_PATH}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${USER_RC_FILE} + sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="codespaces"/g' ${USER_RC_FILE} + + mkdir -p ${OH_MY_INSTALL_DIR}/custom/themes + echo "${CODESPACES_ZSH}" > "${OH_MY_INSTALL_DIR}/custom/themes/codespaces.zsh-theme" + # Shrink git while still enabling updates + cd "${OH_MY_INSTALL_DIR}" + git repack -a -d -f --depth=1 --window=1 + # Copy to non-root user if one is specified + if [ "${USERNAME}" != "root" ]; then + cp -rf "${USER_RC_FILE}" "${OH_MY_INSTALL_DIR}" /root + chown -R ${USERNAME}:${USERNAME} "${USER_RC_PATH}" + fi + fi +fi + +# Persist image metadata info, script if meta.env found in same directory +META_INFO_SCRIPT="$(cat << 'EOF' +#!/bin/sh +. /usr/local/etc/vscode-dev-containers/meta.env + +# Minimal output +if [ "$1" = "version" ] || [ "$1" = "image-version" ]; then + echo "${VERSION}" + exit 0 +elif [ "$1" = "release" ]; then + echo "${GIT_REPOSITORY_RELEASE}" + exit 0 +elif [ "$1" = "content" ] || [ "$1" = "content-url" ] || [ "$1" = "contents" ] || [ "$1" = "contents-url" ]; then + echo "${CONTENTS_URL}" + exit 0 +fi + +#Full output +echo +echo "Development container image information" +echo +if [ ! -z "${VERSION}" ]; then echo "- Image version: ${VERSION}"; fi +if [ ! -z "${DEFINITION_ID}" ]; then echo "- Definition ID: ${DEFINITION_ID}"; fi +if [ ! -z "${VARIANT}" ]; then echo "- Variant: ${VARIANT}"; fi +if [ ! -z "${GIT_REPOSITORY}" ]; then echo "- Source code repository: ${GIT_REPOSITORY}"; fi +if [ ! -z "${GIT_REPOSITORY_RELEASE}" ]; then echo "- Source code release/branch: ${GIT_REPOSITORY_RELEASE}"; fi +if [ ! -z "${BUILD_TIMESTAMP}" ]; then echo "- Timestamp: ${BUILD_TIMESTAMP}"; fi +if [ ! -z "${CONTENTS_URL}" ]; then echo && echo "More info: ${CONTENTS_URL}"; fi +echo +EOF +)" +SCRIPT_DIR="$(cd $(dirname $0) && pwd)" +if [ -f "${SCRIPT_DIR}/meta.env" ]; then + mkdir -p /usr/local/etc/vscode-dev-containers/ + cp -f "${SCRIPT_DIR}/meta.env" /usr/local/etc/vscode-dev-containers/meta.env + echo "${META_INFO_SCRIPT}" > /usr/local/bin/devcontainer-info + chmod +x /usr/local/bin/devcontainer-info +fi + +# Write marker file +mkdir -p "$(dirname "${MARKER_FILE}")" +echo -e "\ + PACKAGES_ALREADY_INSTALLED=${PACKAGES_ALREADY_INSTALLED}\n\ + LOCALE_ALREADY_SET=${LOCALE_ALREADY_SET}\n\ + EXISTING_NON_ROOT_USER=${EXISTING_NON_ROOT_USER}\n\ + RC_SNIPPET_ALREADY_ADDED=${RC_SNIPPET_ALREADY_ADDED}\n\ + ZSH_ALREADY_INSTALLED=${ZSH_ALREADY_INSTALLED}" > "${MARKER_FILE}" + +echo "Done!" diff --git a/.github/workflows/check-full.yaml b/.github/workflows/check-full.yaml index 1ade1938..e238e96a 100644 --- a/.github/workflows/check-full.yaml +++ b/.github/workflows/check-full.yaml @@ -291,5 +291,5 @@ jobs: uses: docker/build-push-action@v2 with: context: . - push: true + file: .devcontainer/Dockerfile push: true tags: docker.pkg.github.com/epiforecasts/covidregionaldata/covidregionaldata:latest diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index c1a1930b..00000000 --- a/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -## Start with the latest tidyvere (verse) image - once development is complete -## needs to be version locked with tags -## verse has pdf related tools built in (i.e latex) -FROM rocker/verse:latest - -## Copy files to working directory of server -ADD . /home/rstudio/covidregionaldata - -## Set working directory to be this folder -WORKDIR /home/rstudio/covidregionaldata - -## Install missing packages. -RUN Rscript -e "devtools::install_dev_deps()" From c030f17e03cc0976f3638706a4977e031453b64c Mon Sep 17 00:00:00 2001 From: seabbs Date: Thu, 1 Jul 2021 09:58:13 +0000 Subject: [PATCH 07/10] update naming and add docthis --- .devcontainer/Dockerfile | 7 +++++++ .devcontainer/devcontainer.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 223a1cbe..2df7c905 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -36,4 +36,11 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ # && export DEBIAN_FRONTEND=noninteractive \ # && apt-get -y install --no-install-recommends +# install dependencies RUN Rscript -e "devtools::install_dev_deps()" + +# configure precommit +RUN Rscript -e "precommit::install_precommit(); precommit::use_precommit()" + +# add docthis +RUN Rscript -e 'devtools::install_github("mdlincoln/docthis")' \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 06c14b14..5e518d4f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: // https://github.com/microsoft/vscode-dev-containers/tree/v0.183.0/containers/r { - "name": "R (Community)", + "name": "covidregionaldata", "build": { "dockerfile": "Dockerfile", // Update VARIANT to pick a specific R version: latest, ... ,4.0.1 , 4.0.0 From ae46da44e0ff6d0055ad66e620ff7162beaddd2a Mon Sep 17 00:00:00 2001 From: Sam Abbott Date: Thu, 1 Jul 2021 11:05:19 +0100 Subject: [PATCH 08/10] Update check-full.yaml --- .github/workflows/check-full.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check-full.yaml b/.github/workflows/check-full.yaml index e238e96a..8e759ccf 100644 --- a/.github/workflows/check-full.yaml +++ b/.github/workflows/check-full.yaml @@ -291,5 +291,6 @@ jobs: uses: docker/build-push-action@v2 with: context: . - file: .devcontainer/Dockerfile push: true + file: .devcontainer/Dockerfile + push: true tags: docker.pkg.github.com/epiforecasts/covidregionaldata/covidregionaldata:latest From 49deed2e7342a6e6ba9d5e212ce78f9af975ef25 Mon Sep 17 00:00:00 2001 From: seabbs Date: Thu, 1 Jul 2021 11:56:19 +0000 Subject: [PATCH 09/10] docker build working --- .devcontainer/Dockerfile | 19 ++++++++++--------- .devcontainer/devcontainer.json | 3 ++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 2df7c905..5060a065 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -11,9 +11,9 @@ ARG UPGRADE_PACKAGES="false" # Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies. ARG USERNAME=vscode -ARG USER_UID=1000 +ARG USER_UID=1100 ARG USER_GID=$USER_UID -COPY library-scripts/*.sh /tmp/library-scripts/ +COPY .devcontainer/library-scripts/*.sh /tmp/library-scripts/ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ && /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \ && usermod -a -G staff ${USERNAME} \ @@ -24,11 +24,14 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ libssl-dev \ libxml2-dev \ libxt-dev \ - && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts \ - && python3 -m pip --no-cache-dir install radian \ - && install2.r --error --skipinstalled --repos ${CRAN} --ncpus -1 \ + && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts + +RUN python3 -m pip --no-cache-dir install radian pre-commit +RUN install2.r --error --skipinstalled --repos ${CRAN} --ncpus -1 \ devtools \ languageserver \ + precommit \ + git2r \ && rm -rf /tmp/downloaded_packages # [Optional] Uncomment this section to install additional OS packages. @@ -37,10 +40,8 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ # && apt-get -y install --no-install-recommends # install dependencies -RUN Rscript -e "devtools::install_dev_deps()" - -# configure precommit -RUN Rscript -e "precommit::install_precommit(); precommit::use_precommit()" +COPY DESCRIPTION /tmp/package/DESCRIPTION +RUN Rscript -e "devtools::install_dev_deps('/tmp/package')" # add docthis RUN Rscript -e 'devtools::install_github("mdlincoln/docthis")' \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 5e518d4f..9c3b5319 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,7 +5,8 @@ "build": { "dockerfile": "Dockerfile", // Update VARIANT to pick a specific R version: latest, ... ,4.0.1 , 4.0.0 - "args": { "VARIANT": "latest" } + "args": { "VARIANT": "latest" }, + "context": ".." }, // Set *default* container specific settings.json values on container create. From 6dc82c0c60bb7f35a9043fe9b462f5b30de48013 Mon Sep 17 00:00:00 2001 From: seabbs Date: Thu, 1 Jul 2021 12:23:59 +0000 Subject: [PATCH 10/10] update prec-commit --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4cf6f352..1018538f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # R specific hooks: https://github.com/lorenzwalthert/precommit repos: - repo: https://github.com/lorenzwalthert/precommit - rev: v0.1.3 + rev: v0.1.3.9014 hooks: - id: style-files args: [--style_pkg=styler, --style_fun=tidyverse_style] @@ -40,7 +40,7 @@ repos: - id: no-browser-statement - id: deps-in-desc - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.4.0 + rev: v4.0.1 hooks: - id: check-added-large-files args: ['--maxkb=800']