Skip to content

Commit

Permalink
close update-actions / closes #47 (#48)
Browse files Browse the repository at this point in the history
* github actions updated

* reformat r-cmd-check

* graceful fail na ok to proceed / a ne jen downloader

* non routable IP address to test for timeout

* why aim for less than 100%?

* no aws in test coverage

* update ubuntu versions / it is not 2018 anymore

* cleanup of branch detritus / work is complete...
  • Loading branch information
jlacko authored Nov 9, 2022
1 parent 0765b3c commit 1a3edab
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 168 deletions.
62 changes: 15 additions & 47 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,64 +21,32 @@ jobs:
config:
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-18.04, r: '3.6'} # ancient, but PROJ 4.9.3 needs to be supported...
- {os: ubuntu-20.04, r: 'release'}
- {os: ubuntu-20.04, r: 'devel'}
- {os: ubuntu-22.04, r: 'release'}
- {os: ubuntu-22.04, r: 'devel'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- 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
- uses: r-lib/actions/setup-r-dependencies@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}
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true

- 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

69 changes: 25 additions & 44 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,60 +9,41 @@ name: test-coverage

jobs:
test-coverage:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-20.04, r: 'release'}

runs-on: ubuntu-latest
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
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}
use-public-rspm: true

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v2
- uses: r-lib/actions/setup-r-dependencies@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-
extra-packages: any::covr
needs: coverage

- 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
- name: Test coverage
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Test coverage
run: covr::codecov()
shell: Rscript {0}
- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
6 changes: 0 additions & 6 deletions R/downloader.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

.downloader <- function(file) {
network <- as.logical(Sys.getenv("NETWORK_UP", unset = TRUE)) # dummy variable to allow testing of network
aws <- as.logical(Sys.getenv("AWS_UP", unset = TRUE)) # dummy variable to allow testing of network

remote_path <- "https://rczechia.jla-data.net/" # remote archive

Expand All @@ -20,11 +19,6 @@
return(NULL)
}

if (!.ok_to_proceed(remote_file) | !aws) { # AWS bucket down
message("Data source broken.")
return(NULL)
}

# proceed to download via curl
message("RCzechia: downloading remote dataset.")
curl::curl_download(url = remote_file, destfile = local_file, quiet = T)
Expand Down
5 changes: 4 additions & 1 deletion R/ok_to_proceed.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
warning = function(w) conditionMessage(w)
)
}

is_response <- function(x) {
class(x) == "response"
}

network <- as.logical(Sys.getenv("NETWORK_UP", unset = TRUE)) # dummy variable to allow testing of network

# First check internet connection
if (!curl::has_internet()) {
if (!curl::has_internet() | !network) {
message("No internet connection.")
return(FALSE)
}
Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/test-1-casti.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ test_that("městské části", {
expect_message(casti(), "internet") # zpráva o chybějícím internetu
Sys.setenv("NETWORK_UP" = TRUE)

Sys.setenv("AWS_UP" = FALSE)
expect_message(casti(), "source") # zpráva o spadlém AWS
Sys.setenv("AWS_UP" = TRUE)

expect_true(is.data.frame(casti()))

expect_s3_class(casti(), "sf")
Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/test-1-chr-uzemi.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ test_that("chráněná území", {
expect_message(chr_uzemi(), "internet") # zpráva o chybějícím internetu
Sys.setenv("NETWORK_UP" = TRUE)

Sys.setenv("AWS_UP" = FALSE)
expect_message(chr_uzemi(), "source") # zpráva o spadlém AWS
Sys.setenv("AWS_UP" = TRUE)

expect_true(is.data.frame(chr_uzemi()))

expect_s3_class(chr_uzemi(), "sf")
Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/test-1-kraje.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ test_that("kraje", {
expect_message(kraje(), "internet") # zpráva o chybějícím internetu
Sys.setenv("NETWORK_UP" = TRUE)

Sys.setenv("AWS_UP" = FALSE)
expect_message(kraje(), "source") # zpráva o spadlém AWS
Sys.setenv("AWS_UP" = TRUE)

expect_true(is.data.frame(kraje()))
expect_true(is.data.frame(kraje("low")))
expect_true(is.data.frame(kraje("high")))
Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/test-1-lesy.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ test_that("lesy", {
expect_message(lesy(), "internet") # zpráva o chybějícím internetu
Sys.setenv("NETWORK_UP" = TRUE)

Sys.setenv("AWS_UP" = FALSE)
expect_message(lesy(), "source") # zpráva o spadlém AWS
Sys.setenv("AWS_UP" = TRUE)

expect_true(is.data.frame(lesy()))

expect_s3_class(lesy(), "sf")
Expand Down
8 changes: 0 additions & 8 deletions tests/testthat/test-1-obce.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ test_that("obce body", {
expect_message(obce_body(), "internet") # zpráva o chybějícím internetu
Sys.setenv("NETWORK_UP" = TRUE)

Sys.setenv("AWS_UP" = FALSE)
expect_message(obce_body(), "source") # zpráva o spadlém AWS
Sys.setenv("AWS_UP" = TRUE)

expect_true(is.data.frame(obce_body()))

expect_s3_class(obce_body(), "sf")
Expand All @@ -38,10 +34,6 @@ test_that("obce polygony", {
expect_message(obce_polygony(), "internet") # zpráva o chybějícím internetu
Sys.setenv("NETWORK_UP" = TRUE)

Sys.setenv("AWS_UP" = FALSE)
expect_message(obce_polygony(), "source") # zpráva o spadlém AWS
Sys.setenv("AWS_UP" = TRUE)

expect_true(is.data.frame(obce_polygony()))

expect_s3_class(obce_polygony(), "sf")
Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/test-1-okresy.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ test_that("okresy", {
expect_message(okresy(), "internet") # zpráva o chybějícím internetu
Sys.setenv("NETWORK_UP" = TRUE)

Sys.setenv("AWS_UP" = FALSE)
expect_message(okresy(), "source") # zpráva o spadlém AWS
Sys.setenv("AWS_UP" = TRUE)

expect_true(is.data.frame(okresy()))
expect_true(is.data.frame(okresy("low")))
expect_true(is.data.frame(okresy("high")))
Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/test-1-orp.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ test_that("ORP", {
expect_message(orp_polygony(), "internet") # zpráva o chybějícím internetu
Sys.setenv("NETWORK_UP" = TRUE)

Sys.setenv("AWS_UP" = FALSE)
expect_message(orp_polygony(), "source") # zpráva o spadlém AWS
Sys.setenv("AWS_UP" = TRUE)

expect_true(is.data.frame(orp_polygony()))

expect_s3_class(orp_polygony(), "sf")
Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/test-1-relief.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ test_that("reliéf", {
expect_message(vyskopis(), "internet") # zpráva o chybějícím internetu
Sys.setenv("NETWORK_UP" = TRUE)

Sys.setenv("AWS_UP" = FALSE)
expect_message(vyskopis(), "source") # zpráva o spadlém AWS
Sys.setenv("AWS_UP" = TRUE)

expect_s4_class(vyskopis(), "RasterLayer")
expect_s4_class(vyskopis("actual"), "RasterLayer")
expect_s4_class(vyskopis("rayshaded"), "RasterLayer")
Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/test-1-republika.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ test_that("republika", {
expect_message(republika(), "internet") # zpráva o chybějícím internetu
Sys.setenv("NETWORK_UP" = TRUE)

Sys.setenv("AWS_UP" = FALSE)
expect_message(republika(), "source") # zpráva o spadlém AWS
Sys.setenv("AWS_UP" = TRUE)

expect_true(is.data.frame(republika()))
expect_true(is.data.frame(republika("low")))
expect_true(is.data.frame(republika("high")))
Expand Down
8 changes: 0 additions & 8 deletions tests/testthat/test-1-transport.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ test_that("silnice", {
expect_message(silnice(), "internet") # zpráva o chybějícím internetu
Sys.setenv("NETWORK_UP" = TRUE)

Sys.setenv("AWS_UP" = FALSE)
expect_message(silnice(), "source") # zpráva o spadlém AWS
Sys.setenv("AWS_UP" = TRUE)

expect_true(is.data.frame(silnice()))

expect_s3_class(silnice(), "sf")
Expand All @@ -40,10 +36,6 @@ test_that("železnice", {
expect_message(zeleznice(), "internet") # zpráva o chybějícím internetu
Sys.setenv("NETWORK_UP" = TRUE)

Sys.setenv("AWS_UP" = FALSE)
expect_message(zeleznice(), "source") # zpráva o spadlém AWS
Sys.setenv("AWS_UP" = TRUE)

expect_true(is.data.frame(zeleznice()))

expect_s3_class(zeleznice(), "sf")
Expand Down
10 changes: 0 additions & 10 deletions tests/testthat/test-1-vodstvo.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ test_that("vodní plochy", {
expect_message(plochy(), "internet") # zpráva o chybějícím internetu
Sys.setenv("NETWORK_UP" = TRUE)

Sys.setenv("AWS_UP" = FALSE)
expect_message(plochy(), "source") # zpráva o spadlém AWS
Sys.setenv("AWS_UP" = TRUE)

expect_true(is.data.frame(plochy()))

expect_s3_class(plochy(), "sf")
Expand All @@ -38,19 +34,13 @@ test_that("řeky", {
expect_message(reky(), "internet") # zpráva o chybějícím internetu
Sys.setenv("NETWORK_UP" = TRUE)

Sys.setenv("AWS_UP" = FALSE)
expect_message(reky(), "source") # zpráva o spadlém AWS
Sys.setenv("AWS_UP" = TRUE)

expect_error(reky(NA)) # parametr je povinný
expect_error(reky(resolution = "bflm")) # nezámé rozlišení
expect_error(reky(resolution = 42)) # nezámé rozlišení
expect_error(reky(resolution = NA)) # nezámé rozlišení
expect_error(reky("bflm")) # neznámý scope
expect_error(reky(c("Praha", "Brno"))) # moc řek...



expect_true(is.data.frame(reky()))
expect_true(is.data.frame(reky(resolution = "high")))
expect_true(is.data.frame(reky(resolution = "low")))
Expand Down
8 changes: 0 additions & 8 deletions tests/testthat/test-1-volby.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ test_that("obvody senátu", {
expect_message(senat_obvody(), "internet") # zpráva o chybějícím internetu
Sys.setenv("NETWORK_UP" = TRUE)

Sys.setenv("AWS_UP" = FALSE)
expect_message(senat_obvody(), "source") # zpráva o spadlém AWS
Sys.setenv("AWS_UP" = TRUE)

expect_true(is.data.frame(senat_obvody()))
expect_true(is.data.frame(senat_obvody("low")))
expect_true(is.data.frame(senat_obvody("high")))
Expand Down Expand Up @@ -50,10 +46,6 @@ test_that("volební okrsky", {
expect_message(volebni_okrsky(), "internet") # zpráva o chybějícím internetu
Sys.setenv("NETWORK_UP" = TRUE)

Sys.setenv("AWS_UP" = FALSE)
expect_message(volebni_okrsky(), "source") # zpráva o spadlém AWS
Sys.setenv("AWS_UP" = TRUE)

expect_true(is.data.frame(volebni_okrsky()))
expect_true(is.data.frame(volebni_okrsky("low")))
expect_true(is.data.frame(volebni_okrsky("high")))
Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/test-1-zip-codes.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ test_that("PSČ", {
expect_message(zip_codes(), "internet") # zpráva o chybějícím internetu
Sys.setenv("NETWORK_UP" = TRUE)

Sys.setenv("AWS_UP" = FALSE)
expect_message(zip_codes(), "source") # zpráva o spadlém AWS
Sys.setenv("AWS_UP" = TRUE)

expect_true(is.data.frame(zip_codes()))
expect_true(is.data.frame(zip_codes("low")))
expect_true(is.data.frame(zip_codes("high")))
Expand Down
Loading

0 comments on commit 1a3edab

Please sign in to comment.