From 5266915cf68f55c79d055886d256de977fe31d5c Mon Sep 17 00:00:00 2001 From: Sam Abbott Date: Sat, 5 Feb 2022 18:50:16 +0000 Subject: [PATCH 1/9] depreciate get_interventions --- NEWS.md | 4 +++ R/get_interventions_data.R | 58 -------------------------------------- 2 files changed, 4 insertions(+), 58 deletions(-) delete mode 100644 R/get_interventions_data.R diff --git a/NEWS.md b/NEWS.md index 8ba7bf2f..7ba74355 100644 --- a/NEWS.md +++ b/NEWS.md @@ -19,6 +19,10 @@ This release is currently under development - Fixed a bug in the data sourced from Germany so that instead of treating it as a line list of individuals it is treated as a relatively finely resolved count data which needs to be summed up (by @sbfnk). - Fixed a bug in the Vietnam class due to `stringr` ([#448](https://github.com/epiforecasts/covidregionaldata/pull/448) by @RichardMN) +## Depreciations + +- `get_interventions_data()` has been depreciated. + # covidregionaldata 0.9.2 This release adds support for the Covid19 Data Hub which includes Google and Apple mobility data amongst a large range of other data sets, data from the European Commission's Joint Research Centre which is at both the regional and national level, and individual sources for regional data from several countries. Package updates have been made in line with a software review at the [Journal of Open Source Software](https://github.com/openjournals/joss-reviews/issues/3290). Finally, this release exposes more of the testing infrastructure to users and adds a package hexsticker. diff --git a/R/get_interventions_data.R b/R/get_interventions_data.R deleted file mode 100644 index 37dfa4cc..00000000 --- a/R/get_interventions_data.R +++ /dev/null @@ -1,58 +0,0 @@ -#' Get ACAPS Government Interventions dataset -#' -#' @description -#' `r lifecycle::badge("deprecated")` -#' -#' Downloads the ACAPS Government Interventions dataset. -#' This function is deprecated: data are no longer updated as of December 2020. -#' -#' Over 100 alternative datasets are available, covering government -#' interventions worldwide. Several include subnational level policy. -#' See: https://supertracker.spi.ox.ac.uk/policy-trackers/ -#' -#' @return a dataframe of government interventions up to Dec 2020 from ACAPS -#' @source \url{https://www.acaps.org/covid-19-government-measures-dataset} -#' @author Paul Campbell @paulcampbell91 -#' -#' @keywords internal -#' -#' @importFrom readxl read_excel -#' @importFrom dplyr mutate -#' @importFrom utils download.file -#' @importFrom lifecycle deprecate_warn -#' -get_interventions_data <- function() { - deprecate_warn( - when = "0.9.0", - what = "covidregionaldata::get_interventions_data()", - details = c( - "The ACAPS data source stopped updating in December 2020.", - "Over 100 alternative data sets are available at:", - "https://supertracker.spi.ox.ac.uk/policy-trackers/" - ) - ) - - base_url <- "https://www.acaps.org/sites/acaps/files/resources/files/acaps_covid19_government_measures_dataset_0.xlsx" # nolint - temp <- tempdir() - filename <- "interventions.xlsx" - download.file(base_url, - destfile = file.path(temp, filename), - mode = "wb", quiet = TRUE - ) - # Read in data and correct excel dates - data <- suppressWarnings(read_excel(file.path(temp, filename), - sheet = "Dataset", - col_types = "text" - )) %>% - mutate( - ENTRY_DATE = as.Date((as.numeric(.data$ENTRY_DATE) - 2), - origin = as.Date("1900-01-01") - ), - DATE_IMPLEMENTED = as.Date((as.numeric(.data$DATE_IMPLEMENTED) - 2), - origin = as.Date("1900-01-01") - ) - ) - names(data) <- tolower(names(data)) - - return(data) -} From 88b2833e18f0399479bf0a4d814c9712e2812a4d Mon Sep 17 00:00:00 2001 From: Sam Abbott Date: Sat, 5 Feb 2022 18:54:09 +0000 Subject: [PATCH 2/9] drop get_info_covidregionaldata --- NEWS.md | 1 + R/get_info_covidregionaldata.R | 18 ------------ man/get_info_covidregionaldata.Rd | 14 ---------- man/get_interventions_data.Rd | 28 ------------------- .../test-get_info_covidregionaldata.R | 6 ---- 5 files changed, 1 insertion(+), 66 deletions(-) delete mode 100644 R/get_info_covidregionaldata.R delete mode 100644 man/get_info_covidregionaldata.Rd delete mode 100644 man/get_interventions_data.Rd delete mode 100644 tests/testthat/test-get_info_covidregionaldata.R diff --git a/NEWS.md b/NEWS.md index 7ba74355..482a79ea 100644 --- a/NEWS.md +++ b/NEWS.md @@ -23,6 +23,7 @@ This release is currently under development - `get_interventions_data()` has been depreciated. + # covidregionaldata 0.9.2 This release adds support for the Covid19 Data Hub which includes Google and Apple mobility data amongst a large range of other data sets, data from the European Commission's Joint Research Centre which is at both the regional and national level, and individual sources for regional data from several countries. Package updates have been made in line with a software review at the [Journal of Open Source Software](https://github.com/openjournals/joss-reviews/issues/3290). Finally, this release exposes more of the testing infrastructure to users and adds a package hexsticker. diff --git a/R/get_info_covidregionaldata.R b/R/get_info_covidregionaldata.R deleted file mode 100644 index 632d77c1..00000000 --- a/R/get_info_covidregionaldata.R +++ /dev/null @@ -1,18 +0,0 @@ -#' Get available datasets -#' -#' @description -#' `r lifecycle::badge("deprecated")` -#' -#' This function is deprecated. Please use `get_available_datasets()` instead. -#' -#' @keywords internal -#' @importFrom lifecycle deprecate_warn -get_info_covidregionaldata <- function() { - deprecate_warn( - when = "0.9.0", - what = "covidregionaldata::get_info_covidregionaldata()", - with = "covidregionaldata::get_available_datasets()" - ) - data <- get_available_datasets() - return(data) -} diff --git a/man/get_info_covidregionaldata.Rd b/man/get_info_covidregionaldata.Rd deleted file mode 100644 index f656ae0c..00000000 --- a/man/get_info_covidregionaldata.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/get_info_covidregionaldata.R -\name{get_info_covidregionaldata} -\alias{get_info_covidregionaldata} -\title{Get available datasets} -\usage{ -get_info_covidregionaldata() -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} - -This function is deprecated. Please use \code{get_available_datasets()} instead. -} -\keyword{internal} diff --git a/man/get_interventions_data.Rd b/man/get_interventions_data.Rd deleted file mode 100644 index f8e8c870..00000000 --- a/man/get_interventions_data.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/get_interventions_data.R -\name{get_interventions_data} -\alias{get_interventions_data} -\title{Get ACAPS Government Interventions dataset} -\source{ -\url{https://www.acaps.org/covid-19-government-measures-dataset} -} -\usage{ -get_interventions_data() -} -\value{ -a dataframe of government interventions up to Dec 2020 from ACAPS -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} - -Downloads the ACAPS Government Interventions dataset. -This function is deprecated: data are no longer updated as of December 2020. - -Over 100 alternative datasets are available, covering government -interventions worldwide. Several include subnational level policy. -See: https://supertracker.spi.ox.ac.uk/policy-trackers/ -} -\author{ -Paul Campbell @paulcampbell91 -} -\keyword{internal} diff --git a/tests/testthat/test-get_info_covidregionaldata.R b/tests/testthat/test-get_info_covidregionaldata.R deleted file mode 100644 index 1ef53bcd..00000000 --- a/tests/testthat/test-get_info_covidregionaldata.R +++ /dev/null @@ -1,6 +0,0 @@ -test_that("get_info_covidregionaldata works as expected", { - expect_warning(get_info_covidregionaldata()) - expect_s3_class( - suppressWarnings(get_info_covidregionaldata()), "data.frame" - ) -}) From c6c36a3c0af8d7cfc0f5ebdc7b5d3aef78807920 Mon Sep 17 00:00:00 2001 From: Sam Abbott Date: Sat, 5 Feb 2022 18:57:17 +0000 Subject: [PATCH 3/9] drop the country arg from get_national_data --- NEWS.md | 5 +++-- R/get_national_data.R | 11 ----------- man/get_national_data.Rd | 4 ---- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/NEWS.md b/NEWS.md index 482a79ea..36bbb08a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -21,8 +21,9 @@ This release is currently under development ## Depreciations -- `get_interventions_data()` has been depreciated. - +- `get_interventions_data()` has been depreciated and removed. +- `get_info_covidregionaldata()` has been depreciated and removed. +- The `country` argument to `get_national_data()` has been depreciated and removed. It's functionality can be replicated using the `countries` argument. # covidregionaldata 0.9.2 diff --git a/R/get_national_data.R b/R/get_national_data.R index 00cde97f..bb5628e3 100644 --- a/R/get_national_data.R +++ b/R/get_national_data.R @@ -12,8 +12,6 @@ #' #' @param countries A character vector specifying country names of interest. #' Used to filter the data. -#' @param country `r lifecycle::badge("deprecated")` A character string -#' specifying a country to filter for. #' @param source A character string specifying the data source (not case #' dependent). Defaults to WHO (the World Health Organisation). See #' `get_available_datasets("national")` for all options. @@ -54,16 +52,7 @@ #' } get_national_data <- function(countries, source = "who", level = "1", totals = FALSE, steps = FALSE, class = FALSE, verbose = TRUE, - country = deprecated(), ...) { - if (is_present(country)) { - deprecate_warn( - "0.9.0", - "covidregionaldata::get_national_data(country = )", - "covidregionaldata::get_national_data(countries = )" - ) - countries <- country - } # check data availability and initiate country class if available nation_class <- initialise_dataclass( diff --git a/man/get_national_data.Rd b/man/get_national_data.Rd index 098ca65b..9b19b25a 100644 --- a/man/get_national_data.Rd +++ b/man/get_national_data.Rd @@ -12,7 +12,6 @@ get_national_data( steps = FALSE, class = FALSE, verbose = TRUE, - country = deprecated(), ... ) } @@ -43,9 +42,6 @@ Overrides \code{steps}.} \item{verbose}{Logical, defaults to \code{TRUE}. Should verbose processing messages and warnings be returned.} -\item{country}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} A character string -specifying a country to filter for.} - \item{...}{Additional arguments to pass to class specific functionality.} } \value{ From 927d9f10b8be47781e9e83d4c87831bc3fb47e0b Mon Sep 17 00:00:00 2001 From: Sam Abbott Date: Sat, 5 Feb 2022 18:59:39 +0000 Subject: [PATCH 4/9] update tests for get_national_data --- NEWS.md | 2 +- tests/testthat/test-get_national_data.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 36bbb08a..0e5d98d8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -17,7 +17,7 @@ This release is currently under development - Fixed a bug in `fill_empty_dates_with_na()` caused by changes made in version `1.2.0` of `tidyr`. - Fixed a bug in the data sourced from Germany so that instead of treating it as a line list of individuals it is treated as a relatively finely resolved count data which needs to be summed up (by @sbfnk). -- Fixed a bug in the Vietnam class due to `stringr` ([#448](https://github.com/epiforecasts/covidregionaldata/pull/448) by @RichardMN) +- Fixed a bug in the Vietnam class due to `stringr` ([#448](https://github.com/epiforecasts/covidregionaldata/pull/448) by @RichardMN). ## Depreciations diff --git a/tests/testthat/test-get_national_data.R b/tests/testthat/test-get_national_data.R index 4caed1a2..9133e4ce 100644 --- a/tests/testthat/test-get_national_data.R +++ b/tests/testthat/test-get_national_data.R @@ -27,7 +27,7 @@ test_get_national_data <- function(source) { verbose = FALSE )) expect_warning(get_national_data( - country = "Zimbabwe", source = source, + countries = "Zimbabwe", source = source, verbose = FALSE )) expect_equal( From aff45c63b8bebf9c7b6eb111195e4c62a47c762b Mon Sep 17 00:00:00 2001 From: Sam Abbott Date: Sat, 5 Feb 2022 19:01:41 +0000 Subject: [PATCH 5/9] drop dep args from get_regional_data --- R/get_regional_data.R | 26 ------------------------- tests/testthat/test-get_regional_data.R | 13 ------------- 2 files changed, 39 deletions(-) diff --git a/R/get_regional_data.R b/R/get_regional_data.R index bf533566..f3bbb97d 100644 --- a/R/get_regional_data.R +++ b/R/get_regional_data.R @@ -13,11 +13,6 @@ #' @param country A character string specifying the country to get data from. #' Not case dependent. Name should be the English name. For a list of #' options use `get_available_datasets()`. -#' @param include_level_2_regions `r lifecycle::badge("deprecated")` Boolean. If TRUE, returns data stratified by -#' level 2 regions. If FALSE, stratified by Level 1. Note that Level 2 region -#' data is not always available. In these cases the user will get a warning -#' and the Level 1 data will be returned. -#' @param localise_regions `r lifecycle::badge("deprecated")` Logical, defaults to TRUE. Should region names be localised. #' @inheritParams return_data #' @inheritParams initialise_dataclass #' @return A tibble with data related to cases, deaths, hospitalisations, @@ -47,28 +42,7 @@ get_regional_data <- function(country, level = "1", totals = FALSE, localise = TRUE, steps = FALSE, class = FALSE, verbose = TRUE, regions, - include_level_2_regions = deprecated(), - localise_regions = deprecated(), ...) { - if (is_present(include_level_2_regions)) { - deprecate_warn( - "0.9.0", - "covidregionaldata::get_regional_data(include_level_2_regions = )", "covidregionaldata::get_regional_data(level = )" - ) - if (include_level_2_regions) { - level <- "1" - } else { - level <- "2" - } - } - - if (is_present(localise_regions)) { - deprecate_warn( - "0.9.0", - "covidregionaldata::get_regional_data(localise_regions = )", "covidregionaldata::get_regional_data(localise = )" - ) - localise <- localise_regions - } # check data availability and initiate country class if available region_class <- initialise_dataclass( diff --git a/tests/testthat/test-get_regional_data.R b/tests/testthat/test-get_regional_data.R index ec826ad6..1cc59b90 100644 --- a/tests/testthat/test-get_regional_data.R +++ b/tests/testthat/test-get_regional_data.R @@ -46,19 +46,6 @@ test_get_regional_data <- function(level) { verbose = FALSE ) ) - # test depreciated args - if (level == "2") { - expect_warning(get_regional_data("mexico", - level = level, - include_level_2_regions = TRUE, verbose = FALSE - )) - expect_warning( - get_regional_data("mexico", - localise_regions = TRUE, - verbose = FALSE - ) - ) - } }) } From 6700bc288f572567e715a55eb60f4b68d0eba962 Mon Sep 17 00:00:00 2001 From: Sam Abbott Date: Sat, 5 Feb 2022 19:09:37 +0000 Subject: [PATCH 6/9] switch get_linelist to depreciate_stop vs warn --- NAMESPACE | 4 +--- R/get_linelist.R | 4 ++-- R/get_national_data.R | 1 - R/get_regional_data.R | 1 - man/get_regional_data.Rd | 9 --------- 5 files changed, 3 insertions(+), 16 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index e1363830..51a779b0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -89,9 +89,7 @@ importFrom(httr,POST) importFrom(httr,content) importFrom(httr,status_code) importFrom(jsonlite,fromJSON) -importFrom(lifecycle,deprecate_warn) -importFrom(lifecycle,deprecated) -importFrom(lifecycle,is_present) +importFrom(lifecycle,deprecate_stop) importFrom(lubridate,as_date) importFrom(lubridate,dmy) importFrom(lubridate,mdy) diff --git a/R/get_linelist.R b/R/get_linelist.R index 6b5f48ca..2f2d11f8 100644 --- a/R/get_linelist.R +++ b/R/get_linelist.R @@ -21,7 +21,7 @@ #' #' @keywords internal #' -#' @importFrom lifecycle deprecate_warn +#' @importFrom lifecycle deprecate_stop #' @importFrom dplyr if_else select mutate filter #' @importFrom lubridate dmy #' @importFrom utils download.file untar @@ -35,7 +35,7 @@ #' } #' get_linelist <- function(clean = TRUE, report_delay_only = FALSE) { - deprecate_warn( + deprecate_stop( when = "0.9.0", what = "covidregionaldata::get_linelist()", details = c( diff --git a/R/get_national_data.R b/R/get_national_data.R index bb5628e3..0645435c 100644 --- a/R/get_national_data.R +++ b/R/get_national_data.R @@ -18,7 +18,6 @@ #' @return A tibble with data related to cases, deaths, hospitalisations, #' recoveries and testing. #' @inheritParams get_regional_data -#' @importFrom lifecycle deprecated is_present deprecate_warn #' @family interface #' @seealso [WHO()], [ECDC()], [JHU()], [Google()] #' @export diff --git a/R/get_regional_data.R b/R/get_regional_data.R index f3bbb97d..34ae99a0 100644 --- a/R/get_regional_data.R +++ b/R/get_regional_data.R @@ -17,7 +17,6 @@ #' @inheritParams initialise_dataclass #' @return A tibble with data related to cases, deaths, hospitalisations, #' recoveries and testing stratified by regions within the given country. -#' @importFrom lifecycle deprecated is_present deprecate_warn #' @family interface #' @seealso [Italy()], [UK()] #' @export diff --git a/man/get_regional_data.Rd b/man/get_regional_data.Rd index de52bb4f..e825493b 100644 --- a/man/get_regional_data.Rd +++ b/man/get_regional_data.Rd @@ -13,8 +13,6 @@ get_regional_data( class = FALSE, verbose = TRUE, regions, - include_level_2_regions = deprecated(), - localise_regions = deprecated(), ... ) } @@ -47,13 +45,6 @@ messages and warnings be returned.} \item{regions}{A character vector of target regions to be assigned to the \code{target_regions} field and used to filter the returned data.} -\item{include_level_2_regions}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Boolean. If TRUE, returns data stratified by -level 2 regions. If FALSE, stratified by Level 1. Note that Level 2 region -data is not always available. In these cases the user will get a warning -and the Level 1 data will be returned.} - -\item{localise_regions}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Logical, defaults to TRUE. Should region names be localised.} - \item{...}{Additional arguments to pass to class specific functionality.} } \value{ From 2d31173f4a1e6011b3b8373acf24b4857382be19 Mon Sep 17 00:00:00 2001 From: Sam Abbott Date: Sat, 5 Feb 2022 19:10:36 +0000 Subject: [PATCH 7/9] update news --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index 0e5d98d8..d54d70be 100644 --- a/NEWS.md +++ b/NEWS.md @@ -24,6 +24,7 @@ This release is currently under development - `get_interventions_data()` has been depreciated and removed. - `get_info_covidregionaldata()` has been depreciated and removed. - The `country` argument to `get_national_data()` has been depreciated and removed. It's functionality can be replicated using the `countries` argument. +- `get_linelist()` has been updated to fail on use vs warn on use and will be removed from future versions of the package. # covidregionaldata 0.9.2 From e2079d2fb52d6d3aacba622689bfea4dd0e0e413 Mon Sep 17 00:00:00 2001 From: Sam Abbott Date: Sat, 5 Feb 2022 19:27:00 +0000 Subject: [PATCH 8/9] update package checking --- .github/workflows/R-CMD-check.yaml | 46 +++++ .github/workflows/check-full.yaml | 272 --------------------------- .github/workflows/lint.yaml | 49 +++++ .github/workflows/test-coverage.yaml | 59 ++++++ README.Rmd | 2 +- 5 files changed, 155 insertions(+), 273 deletions(-) create mode 100644 .github/workflows/R-CMD-check.yaml delete mode 100644 .github/workflows/check-full.yaml create mode 100644 .github/workflows/lint.yaml create mode 100644 .github/workflows/test-coverage.yaml diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 00000000..271d466e --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,46 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/master/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: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macOS-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-pandoc@v1 + + - uses: r-lib/actions/setup-r@v1 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v1 + with: + extra-packages: rcmdcheck + + - uses: r-lib/actions/check-r-package@v1 diff --git a/.github/workflows/check-full.yaml b/.github/workflows/check-full.yaml deleted file mode 100644 index 5e099a4c..00000000 --- a/.github/workflows/check-full.yaml +++ /dev/null @@ -1,272 +0,0 @@ ---- -# Github Actions workflow to check covidregionaldata -name: R-CMD-check - -'on': - push: - branches: - - master - schedule: - - cron: '0 0 * * 1' - pull_request: - branches: - - '*' - workflow_dispatch: - -jobs: - R-CMD-check: - runs-on: ${{ matrix.config.os }} - - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - - strategy: - fail-fast: true - matrix: - config: - - {os: macOS-latest, r: 'release'} - - {os: windows-latest, r: 'release'} - - {os: ubuntu-20.04, r: 'release'} - - {os: ubuntu-20.04, r: 'oldrel'} - - env: - R_REMOTES_NO_ERRORS_FROM_WARNINGS: true - RSPM: ${{ matrix.config.rspm }} - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v2 - - - uses: r-lib/actions/setup-r@v1 - with: - r-version: ${{ matrix.config.r }} - - - uses: r-lib/actions/setup-pandoc@v1 - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - if: runner.os != 'Windows' - uses: actions/cache@v2 - with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - - name: Install system dependencies - if: runner.os == 'Linux' - env: - RHUB_PLATFORM: linux-x86_64-ubuntu-gcc - run: | - while read -r cmd - do - eval sudo $cmd - done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') - sudo apt-get -y install libudunits2-dev libgdal-dev libqpdf-dev libcurl4-openssl-dev - shell: bash - - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("rcmdcheck") - shell: Rscript {0} - - - name: Session info - run: | - options(width = 100) - pkgs <- installed.packages()[, "Package"] - sessioninfo::session_info(pkgs, include_base = TRUE) - shell: Rscript {0} - - - name: Check - env: - _R_CHECK_CRAN_INCOMING_: false - _R_CHECK_DONTTEST_EXAMPLES_: false - _R_CHECK_FORCE_SUGGESTS_: false - run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") - shell: Rscript {0} - - - name: Show testthat output - if: always() - run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash - - - name: Upload check results - if: failure() - uses: actions/upload-artifact@v2 - with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check - - Lint: - runs-on: ubuntu-20.04 - - needs: [R-CMD-check] - - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v2 - - - uses: r-lib/actions/setup-r@v1 - - - uses: r-lib/actions/setup-pandoc@v1 - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - if: runner.os != 'Windows' - uses: actions/cache@v2 - with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - - name: Install system dependencies - if: runner.os == 'Linux' - env: - RHUB_PLATFORM: linux-x86_64-ubuntu-gcc - run: | - while read -r cmd - do - eval sudo $cmd - done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') - sudo apt-get -y install libudunits2-dev libgdal-dev libqpdf-dev libcurl4-openssl-dev - shell: bash - - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("lintr") - remotes::install_cran("sessioninfo") - remotes::install_local(".") - shell: Rscript {0} - - - name: Session info - run: | - options(width = 100) - pkgs <- installed.packages()[, "Package"] - sessioninfo::session_info(pkgs, include_base = TRUE) - shell: Rscript {0} - - - name: Lint - run: lintr::lint_package() - shell: Rscript {0} - - - test-coverage: - if: github.repository == 'epiforecasts/covidregionaldata' - runs-on: ubuntu-20.04 - - needs: [R-CMD-check] - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v2 - - - uses: r-lib/actions/setup-r@v1 - - - uses: r-lib/actions/setup-pandoc@v1 - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - if: runner.os != 'Windows' - uses: actions/cache@v2 - with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - - name: Install system dependencies - if: runner.os == 'Linux' - env: - RHUB_PLATFORM: linux-x86_64-ubuntu-gcc - run: | - while read -r cmd - do - eval sudo $cmd - done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') - sudo apt-get -y install libudunits2-dev libgdal-dev libqpdf-dev libcurl4-openssl-dev - shell: bash - - - name: Install dependencies - run: | - install.packages(c("remotes","sessioninfo")) - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("covr") - shell: Rscript {0} - - - name: Session info - run: | - options(width = 100) - pkgs <- installed.packages()[, "Package"] - sessioninfo::session_info(pkgs, include_base = TRUE) - shell: Rscript {0} - - - name: Test coverage - run: covr::codecov() - shell: Rscript {0} - - - pkgdown: - if: github.ref == 'refs/heads/master' && github.repository == 'epiforecasts/covidregionaldata' - runs-on: macOS-latest - - needs: [R-CMD-check, Lint, test-coverage] - - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v2 - - - uses: r-lib/actions/setup-r@v1 - - - uses: r-lib/actions/setup-pandoc@v1 - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - shell: Rscript {0} - - - name: Cache R packages - uses: actions/cache@v2 - with: - path: ${{ env.R_LIBS_USER }} - key: macOS-r-4.0-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: macOS-r-4.0-1- - - - name: Install dependencies - run: | - install.packages(c("remotes", "pkgbuild")) - remotes::install_deps(dependencies = TRUE) - remotes::install_dev("pkgdown") - shell: Rscript {0} - - - name: Install package - run: R CMD INSTALL . - - - name: Deploy package - run: | - git config --local user.email "actions@github.com" - git config --local user.name "GitHub Actions" - Rscript -e "pkgdown::deploy_to_branch(new_process = FALSE, clean = TRUE)" - shell: bash diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 00000000..041ee3c8 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,49 @@ +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + +name: lint + +jobs: + lint: + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@v1 + + - name: Query dependencies + run: | + install.packages('remotes') + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) + writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") + shell: Rscript {0} + + - name: Restore R package cache + uses: actions/cache@v2 + with: + path: ${{ env.R_LIBS_USER }} + key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} + restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + + - name: Install dependencies + run: | + install.packages(c("remotes")) + remotes::install_deps(dependencies = TRUE) + remotes::install_cran("lintr") + shell: Rscript {0} + + - name: Install package + run: R CMD INSTALL . + + - name: Lint + run: lintr::lint_package() + shell: Rscript {0} \ No newline at end of file diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 00000000..19db0001 --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,59 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/master/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: test-coverage + +jobs: + test-coverage: + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + NOT_CRAN: true + steps: + - name: cmdstan env vars + run: | + echo "CMDSTAN_PATH=${HOME}/.cmdstan" >> $GITHUB_ENV + shell: bash + - uses: n1hility/cancel-previous-runs@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@v1 + + - name: Query dependencies + run: | + install.packages('remotes') + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) + writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") + shell: Rscript {0} + + - name: Restore R package cache + uses: actions/cache@v2 + with: + path: ${{ env.R_LIBS_USER }} + key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} + restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + + - name: Install dependencies + run: | + install.packages(c("remotes")) + remotes::install_deps(dependencies = TRUE) + remotes::install_cran("covr") + install.packages("curl") + shell: Rscript {0} + + - name: Install package + run: R CMD INSTALL . + + - name: Test coverage + run: | + options(testRegions = TRUE) + covr::codecov() + shell: Rscript {0} \ No newline at end of file diff --git a/README.Rmd b/README.Rmd index a42bda15..04b68018 100644 --- a/README.Rmd +++ b/README.Rmd @@ -13,7 +13,7 @@ knitr::opts_chunk$set( # Subnational data for the COVID-19 outbreak -[![R-CMD-check](https://github.com/epiforecasts/covidregionaldata/workflows/R-CMD-check/badge.svg)](https://github.com/epiforecasts/covidregionaldata/actions) [![Codecov test coverage](https://codecov.io/gh/epiforecasts/covidregionaldata/branch/master/graph/badge.svg)](https://codecov.io/gh/epiforecasts/covidregionaldata?branch=master) [![Data status](https://img.shields.io/badge/Data-status-lightblue.svg?style=flat)](https://epiforecasts.io/covidregionaldata/articles/supported-countries.html) [![metacran downloads](http://cranlogs.r-pkg.org/badges/grand-total/covidregionaldata?color=ff69b4)](https://cran.r-project.org/package=covidregionaldata) + [![R-CMD-check](https://github.com/epiforecasts/covidregionaldata/workflows/R-CMD-check/badge.svg)](https://github.com/epiforecasts/covidregionaldata/actions) [![Codecov test coverage](https://codecov.io/gh/epiforecasts/covidregionaldata/branch/master/graph/badge.svg)](https://codecov.io/gh/epiforecasts/covidregionaldata?branch=master) [![Data status](https://img.shields.io/badge/Data-status-lightblue.svg?style=flat)](https://epiforecasts.io/covidregionaldata/articles/supported-countries.html) [![metacran downloads](http://cranlogs.r-pkg.org/badges/grand-total/covidregionaldata?color=ff69b4)](https://cran.r-project.org/package=covidregionaldata) [![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/epiforecasts/covidregionaldata/blob/master/LICENSE.md/) [![GitHub contributors](https://img.shields.io/github/contributors/epiforecasts/covidregionaldata)](https://github.com/epiforecasts/covidregionaldata/graphs/contributors) [![Discord](https://img.shields.io/discord/864828485981306890?logo=Discord)](https://discord.gg/9YPDDADVt3) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-yellow.svg)](https://makeapullrequest.com/) [![GitHub commits](https://img.shields.io/github/commits-since/epiforecasts/covidregionaldata/0.9.2.svg?color=orange)](https://GitHub.com/epiforecasts/covidregionaldata/commit/master/) From d1d64fba2271950eee9b34745c412a39849580b9 Mon Sep 17 00:00:00 2001 From: Sam Abbott Date: Sat, 5 Feb 2022 19:31:35 +0000 Subject: [PATCH 9/9] clean up tests --- R/shared-methods.R | 10 ++++++---- tests/testthat/test-get_national_data.R | 4 ---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/R/shared-methods.R b/R/shared-methods.R index 0433831e..8974d8ac 100644 --- a/R/shared-methods.R +++ b/R/shared-methods.R @@ -638,10 +638,12 @@ CountryDataClass <- R6::R6Class("CountryDataClass", } if (!is.null(self$target_regions)) { - self$target_regions <- countryname( - self$target_regions, - destination = "country.name.en", - warn = FALSE + self$target_regions <- suppressWarnings( + countryname( + self$target_regions, + destination = "country.name.en", + warn = FALSE + ) ) if (all(is.na(self$target_regions))) { stop("No countries found with target names") diff --git a/tests/testthat/test-get_national_data.R b/tests/testthat/test-get_national_data.R index 9133e4ce..de83e30e 100644 --- a/tests/testthat/test-get_national_data.R +++ b/tests/testthat/test-get_national_data.R @@ -26,10 +26,6 @@ test_get_national_data <- function(source) { countries = "rwfwf", source = source, verbose = FALSE )) - expect_warning(get_national_data( - countries = "Zimbabwe", source = source, - verbose = FALSE - )) expect_equal( true_steps, get_national_data(source = source, steps = TRUE, verbose = FALSE)