From a87bfcc274681cc729602542a5a4214015ef5c1c Mon Sep 17 00:00:00 2001 From: dieghernan Date: Thu, 24 Dec 2020 00:26:25 +0100 Subject: [PATCH 1/5] Check on local - OK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > checking package dependencies ... NOTE Suggests orphaned package: 'ggmap' 0 errors √ | 0 warnings √ | 1 note x --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 37a4dd1..0287043 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -14,5 +14,5 @@ URL: https://github.com/rOpenSpain/caRtociudad License: GPL-3 LazyLoad: yes LazyData: yes -RoxygenNote: 6.0.1 +RoxygenNote: 7.1.1 ByteCompile: yes From de034b30368713c908b04c29474dad358da3b461 Mon Sep 17 00:00:00 2001 From: dieghernan Date: Thu, 24 Dec 2020 00:34:45 +0100 Subject: [PATCH 2/5] rostemplate implemented Test locally - OK --- .Rbuildignore | 3 + .github/.gitignore | 3 + .github/workflows/roscron-check-standard.yaml | 86 +++++++++++++++++++ .github/workflows/rostemplate-gh-pages.yaml | 50 +++++++++++ _pkgdown.yml | 8 ++ 5 files changed, 150 insertions(+) create mode 100644 .github/.gitignore create mode 100644 .github/workflows/roscron-check-standard.yaml create mode 100644 .github/workflows/rostemplate-gh-pages.yaml create mode 100644 _pkgdown.yml diff --git a/.Rbuildignore b/.Rbuildignore index 4434527..c29683b 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,6 @@ ^\.travis\.yml$ ^.*\.Rproj$ ^\.Rproj\.user$ +^\.github$ +^docs$ +^_pkgdown\.yml$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..0ce1091 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1,3 @@ +*.html +R-version +depends.Rds diff --git a/.github/workflows/roscron-check-standard.yaml b/.github/workflows/roscron-check-standard.yaml new file mode 100644 index 0000000..a8a6caa --- /dev/null +++ b/.github/workflows/roscron-check-standard.yaml @@ -0,0 +1,86 @@ +# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. +# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + schedule: + - cron: '30 08 1 * *' + +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: windows-latest, r: 'release'} + - {os: macOS-latest, r: 'release'} + - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + + 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@master + with: + r-version: ${{ matrix.config.r }} + + - uses: r-lib/actions/setup-pandoc@master + + - 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' + run: | + while read -r cmd + do + eval sudo $cmd + done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') + + - name: Install dependencies + run: | + remotes::install_deps(dependencies = TRUE) + remotes::install_cran("rcmdcheck") + shell: Rscript {0} + + - name: Check + env: + _R_CHECK_CRAN_INCOMING_REMOTE_: false + run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") + shell: Rscript {0} + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@main + with: + name: ${{ runner.os }}-r${{ matrix.config.r }}-results + path: check diff --git a/.github/workflows/rostemplate-gh-pages.yaml b/.github/workflows/rostemplate-gh-pages.yaml new file mode 100644 index 0000000..bc4ae69 --- /dev/null +++ b/.github/workflows/rostemplate-gh-pages.yaml @@ -0,0 +1,50 @@ +on: + push: + branches: + - main + - master + +name: rostemplate-gh-pages + +jobs: + rostemplate-gh-pages: + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@master + + - uses: r-lib/actions/setup-pandoc@master + + - name: Query dependencies + run: | + install.packages('remotes') + install.packages('devtools') + 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 + 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: | + remotes::install_deps(dependencies = TRUE) + remotes::install_github("ropenspain/rostemplate", dependencies = TRUE, force = TRUE) + + 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)' diff --git a/_pkgdown.yml b/_pkgdown.yml new file mode 100644 index 0000000..2bae2f6 --- /dev/null +++ b/_pkgdown.yml @@ -0,0 +1,8 @@ +template: + package: rostemplate + +authors: + Carlos J. Gil Bellosta: + href: https://www.datanalytics.com/ + Luz Frías: + href: https://github.com/koldLight From e77a9df60f96a754703b40cd594ed6f84069ca50 Mon Sep 17 00:00:00 2001 From: dieghernan Date: Thu, 24 Dec 2020 00:46:38 +0100 Subject: [PATCH 3/5] Moved cron to 8:00 am first day of month I guess previous checks failed due to API endpoint (maintenance or API limits). Check changed to 8:00 to avoid working hours --- .github/workflows/roscron-check-standard.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/roscron-check-standard.yaml b/.github/workflows/roscron-check-standard.yaml index a8a6caa..1aaadca 100644 --- a/.github/workflows/roscron-check-standard.yaml +++ b/.github/workflows/roscron-check-standard.yaml @@ -10,7 +10,7 @@ on: - main - master schedule: - - cron: '30 08 1 * *' + - cron: '00 08 1 * *' name: R-CMD-check From 5dc6da06df4ab33f7a5b3414410030ae133e1718 Mon Sep 17 00:00:00 2001 From: dieghernan Date: Mon, 26 Jul 2021 13:41:35 +0200 Subject: [PATCH 4/5] Update to testthat v3 Also update actions and adds coverage --- .github/workflows/roscron-check-standard.yaml | 15 +++--- .github/workflows/rostemplate-gh-pages.yaml | 2 +- .github/workflows/test-coverage.yaml | 47 ++++++++++++++++ DESCRIPTION | 41 +++++++++----- tests/testthat/test-caRtociudad.R | 54 +++++++++---------- 5 files changed, 111 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/test-coverage.yaml diff --git a/.github/workflows/roscron-check-standard.yaml b/.github/workflows/roscron-check-standard.yaml index 1aaadca..e8d2215 100644 --- a/.github/workflows/roscron-check-standard.yaml +++ b/.github/workflows/roscron-check-standard.yaml @@ -12,6 +12,8 @@ on: schedule: - cron: '00 08 1 * *' + + name: R-CMD-check jobs: @@ -26,8 +28,8 @@ jobs: config: - {os: windows-latest, r: 'release'} - {os: macOS-latest, r: 'release'} - - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: ubuntu-latest, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: ubuntu-latest, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true @@ -50,9 +52,8 @@ jobs: 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 + - name: Restore R package cache + uses: actions/cache@v2.1.6 with: path: ${{ env.R_LIBS_USER }} key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} @@ -75,7 +76,9 @@ jobs: - name: Check env: _R_CHECK_CRAN_INCOMING_REMOTE_: false - run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") + run: | + options(crayon.enabled = TRUE) + rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") shell: Rscript {0} - name: Upload check results diff --git a/.github/workflows/rostemplate-gh-pages.yaml b/.github/workflows/rostemplate-gh-pages.yaml index bc4ae69..fcf7c31 100644 --- a/.github/workflows/rostemplate-gh-pages.yaml +++ b/.github/workflows/rostemplate-gh-pages.yaml @@ -27,7 +27,7 @@ jobs: shell: Rscript {0} - name: Cache R packages - uses: actions/cache@v2 + uses: actions/cache@v2.1.6 with: path: ${{ env.R_LIBS_USER }} key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..588d16b --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,47 @@ +on: + push: + branches: + - master + - main + pull_request: + branches: + - master + - main + +name: test-coverage + +jobs: + test-coverage: + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@master + + - uses: r-lib/actions/setup-pandoc@master + + - 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 + uses: actions/cache@v2.1.6 + 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: | + remotes::install_deps(dependencies = TRUE) + remotes::install_cran("covr") + shell: Rscript {0} + + - name: Test coverage + run: covr::codecov() + shell: Rscript {0} diff --git a/DESCRIPTION b/DESCRIPTION index 0287043..9a3071e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,18 +1,33 @@ -Package: caRtociudad Type: Package +Package: caRtociudad Title: Interface to Cartociudad API Version: 0.6.2 -Date: 2018-05-13 -Encoding: UTF-8 -Authors@R: c(person("Carlos J.", "Gil Bellosta", email="cgb@datanalytics.com", role=c('cre', 'aut')), - person("Luz", "Frías", email = "luzfrias@gmail.com", role = "aut")) -Description: Access to Cartociudad cartography API, which provides mapping and other related services for Spain. -Imports: httr, jsonlite, xml2, plyr, geosphere, sp -Depends: R (>= 3.0.0) -Suggests: ggmap, testthat -URL: https://github.com/rOpenSpain/caRtociudad +Authors@R: + c(person(given = "Carlos J.", + family = "Gil Bellosta", + role = c("cre", "aut"), + email = "cgb@datanalytics.com"), + person(given = "Luz", + family = "Frías", + role = "aut", + email = "luzfrias@gmail.com")) +Description: Access to Cartociudad cartography API, which provides mapping + and other related services for Spain. License: GPL-3 -LazyLoad: yes -LazyData: yes -RoxygenNote: 7.1.1 +URL: https://github.com/rOpenSpain/caRtociudad +Depends: + R (>= 3.0.0) +Imports: + geosphere, + httr, + jsonlite, + plyr, + sp, + xml2 +Suggests: + ggmap, + testthat (>= 3.0.0) ByteCompile: yes +Config/testthat/edition: 3 +Encoding: UTF-8 +RoxygenNote: 7.1.1 diff --git a/tests/testthat/test-caRtociudad.R b/tests/testthat/test-caRtociudad.R index a48b327..bee6f1d 100644 --- a/tests/testthat/test-caRtociudad.R +++ b/tests/testthat/test-caRtociudad.R @@ -1,46 +1,44 @@ -context("requests") - test_that("cartociudad_geocode returns the location of a full address", { result <- cartociudad_geocode("plaza de cascorro 11, 28005 madrid") - expect_that(nrow(result) > 0, is_true()) + expect_true(nrow(result) > 0) }) test_that("get_cartociudad_map returns a map for a valid location", { map <- cartociudad_get_map(c(40.41137, -3.707168), 1) - expect_that(map, is_a("raster")) - expect_that(map, is_a("ggmap")) + expect_s3_class(map, "raster") + expect_s3_class(map, "ggmap") }) test_that("get_cartociudad_location_info returns info for a valid location", { result <- cartociudad_get_location_info(40.473219, -3.7227241) - expect_that(!is.null(result$seccion), is_true()) - expect_that(!is.null(result$distrito), is_true()) - expect_that(!is.null(result$provincia), is_true()) - expect_that(!is.null(result$municipio), is_true()) - expect_that(!is.null(result$ref.catastral), is_true()) - expect_that(!is.null(result$url.ref.catastral), is_true()) - expect_that(!is.null(result$tipo), is_true()) - expect_that(!is.null(result$tipo.via), is_true()) - expect_that(!is.null(result$nombre.via), is_true()) - expect_that(!is.null(result$num.via), is_true()) - expect_that(!is.null(result$num.via.id), is_true()) - expect_that(!is.null(result$cod.postal), is_true()) + expect_true(!is.null(result$seccion)) + expect_true(!is.null(result$distrito)) + expect_true(!is.null(result$provincia)) + expect_true(!is.null(result$municipio)) + expect_true(!is.null(result$ref.catastral)) + expect_true(!is.null(result$url.ref.catastral)) + expect_true(!is.null(result$tipo)) + expect_true(!is.null(result$tipo.via)) + expect_true(!is.null(result$nombre.via)) + expect_true(!is.null(result$num.via)) + expect_true(!is.null(result$num.via.id)) + expect_true(!is.null(result$cod.postal)) }) test_that("cartociudad_reverse_geocode returns an address for a valid location", { result <- cartociudad_reverse_geocode(40.473219, -3.7227241) - expect_that(!is.null(result$tipo), is_true()) - expect_that(!is.null(result$tipo.via), is_true()) - expect_that(!is.null(result$nombre.via), is_true()) - expect_that(!is.null(result$num.via), is_true()) - expect_that(!is.null(result$num.via.id), is_true()) - expect_that(!is.null(result$municipio), is_true()) - expect_that(!is.null(result$provincia), is_true()) - expect_that(!is.null(result$cod.postal), is_true()) + expect_true(!is.null(result$tipo)) + expect_true(!is.null(result$tipo.via)) + expect_true(!is.null(result$nombre.via)) + expect_true(!is.null(result$num.via)) + expect_true(!is.null(result$num.via.id)) + expect_true(!is.null(result$municipio)) + expect_true(!is.null(result$provincia)) + expect_true(!is.null(result$cod.postal)) }) test_that("get_cartociudad_user_agent returns the package name and github repo url", { @@ -49,12 +47,12 @@ test_that("get_cartociudad_user_agent returns the package name and github repo u httr::stop_for_status(result) user.agent <- httr::content(result)$"user-agent" - expect_that(length(grep("caRtociudad/[0-9.]+", user.agent)) == 1, is_true()) - expect_that(length(grep("github.com/rOpenSpain/caRtociudad", user.agent)) == 1, is_true()) + expect_true(length(grep("caRtociudad/[0-9.]+", user.agent)) == 1) + expect_true(length(grep("github.com/rOpenSpain/caRtociudad", user.agent)) == 1) }) test_that("cartociudad_get_area with valid parameters returns a polygon", { result <- cartociudad_get_area(40.3930144, -3.6596683, 500) - expect_that(nrow(result) > 2, is_true()) + expect_true(nrow(result) > 2) }) From 8737978ed5d06964f192f0d50bb4d85a22f3cedb Mon Sep 17 00:00:00 2001 From: dieghernan Date: Mon, 26 Jul 2021 21:57:08 +0200 Subject: [PATCH 5/5] Run don't run on pkgdown --- .github/workflows/rostemplate-gh-pages.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rostemplate-gh-pages.yaml b/.github/workflows/rostemplate-gh-pages.yaml index fcf7c31..0055f98 100644 --- a/.github/workflows/rostemplate-gh-pages.yaml +++ b/.github/workflows/rostemplate-gh-pages.yaml @@ -47,4 +47,4 @@ jobs: 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)' + Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE, clean = TRUE, run_dont_run = TRUE)'