diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index af5accd..261e667 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,113 +1,63 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +# +# NOTE: This workflow is overkill for most R packages and +# check-standard.yaml is likely a better choice. +# usethis::use_github_action("check-standard") will install it. on: push: - branches: - - main - - master - - dev + branches: [main, master] pull_request: - branches: - - main - - master - - dev - schedule: - - cron: '0 8 * * 0' + branches: [main, master] name: R-CMD-check +permissions: read-all + jobs: R-CMD-check: - if: "!contains(github.event.head_commit.message, 'skip ci')" runs-on: ${{ matrix.config.os }} - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) strategy: fail-fast: false matrix: config: - - {os: macOS-latest, r: 'release'} + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} - - {os: ubuntu-latest, 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: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - {os: ubuntu-latest, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - {os: ubuntu-latest, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + # use 4.0 or 4.1 to check with rtools40's older compiler + - {os: windows-latest, r: 'oldrel-4'} + + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + - {os: ubuntu-latest, r: 'oldrel-2'} + - {os: ubuntu-latest, r: 'oldrel-3'} + - {os: ubuntu-latest, r: 'oldrel-4'} 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: r-lib/actions/setup-r@master - with: - r-version: ${{ matrix.config.r }} + - uses: actions/checkout@v4 - - uses: r-lib/actions/setup-pandoc@master + - uses: r-lib/actions/setup-pandoc@v2 - - 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@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: 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_REMOTE_: 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 + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true - - name: Upload check results - if: failure() - uses: actions/upload-artifact@master + - uses: r-lib/actions/setup-r-dependencies@v2 with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check + extra-packages: any::rcmdcheck + needs: check - - name: action-slack - if: failure() - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - uses: 8398a7/action-slack@v3.0.0 + - uses: r-lib/actions/check-r-package@v2 with: - status: ${{ job.status }} - author_name: "github action: ${{github.workflow}}" - fields: repo, ref, commit, author, message + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml deleted file mode 100644 index f0c5797..0000000 --- a/.github/workflows/coverage.yaml +++ /dev/null @@ -1,48 +0,0 @@ -on: - push: - branches: - - main - - master - pull_request: - branches: - - main - - master - -name: coverage - -jobs: - coverage: - if: "!contains(github.event.head_commit.message, 'skip ci')" - 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 - 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/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index a539056..c9f0165 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -1,59 +1,50 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - branches: - - main - - master + branches: [main, master] + pull_request: + branches: [main, master] + release: + types: [published] + workflow_dispatch: name: pkgdown +permissions: read-all + jobs: pkgdown: - if: "!contains(github.event.head_commit.message, 'skip ci')" - runs-on: macOS-latest + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write steps: - - uses: actions/checkout@v2 - - - uses: r-lib/actions/setup-r@master + - uses: actions/checkout@v4 - - 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} + - uses: r-lib/actions/setup-pandoc@v2 - - name: Cache R packages - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r@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_dev("pkgdown") - shell: Rscript {0} + use-public-rspm: true - - name: Install package - run: R CMD INSTALL . + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::pkgdown, local::. + needs: website - - 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)' + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + shell: Rscript {0} - - name: action-slack - if: failure() - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - uses: 8398a7/action-slack@v3.0.0 + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@v4.5.0 with: - status: ${{ job.status }} - author_name: "github action: pkgdown" - fields: repo, workflow, commit, message, author, action + clean: false + branch: gh-pages + folder: docs diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..fefc52e --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,61 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/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 + +permissions: read-all + +jobs: + test-coverage: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::covr, any::xml2 + needs: coverage + + - name: Test coverage + run: | + cov <- covr::package_coverage( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) + covr::to_cobertura(cov) + shell: Rscript {0} + + - uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }} + file: ./cobertura.xml + plugin: noop + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Show testthat output + if: always() + run: | + ## -------------------------------------------------------------------- + find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v4 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package diff --git a/DESCRIPTION b/DESCRIPTION index ad0fffd..0c66ac1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -48,4 +48,4 @@ VignetteBuilder: Encoding: UTF-8 Language: en-US Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.1 +RoxygenNote: 7.3.2 diff --git a/R/check.R b/R/check.R index cf6f75f..78692f2 100644 --- a/R/check.R +++ b/R/check.R @@ -65,7 +65,7 @@ check_flob_query <- function(x, slob = FALSE) { if(vld_false(slob)){ class(x) <- c("flob", "blob") - chk_flob(x) # this is a problem when x is a blob and blob = FALSE + flobr::chk_flob(x) # this is a problem when x is a blob and blob = FALSE } else if (vld_true(slob)){ class(x) <- "blob" flobr::chk_slob(x) @@ -74,9 +74,9 @@ check_flob_query <- function(x, slob = FALSE) { names(x) <- NULL } else { class(x) <- c("flob", "blob") - if(!vld_flob(x)){ + if(!flobr::vld_flob(x)){ class(x) <- c("blob") - chkor(flobr::chk_slob(x), chk_flob(x)) + chkor_vld(vld_slob(x), flobr::vld_flob(x)) class(x) <- "list" x <- blob::as_blob(x) names(x) <- NULL diff --git a/R/chk.R b/R/chk.R deleted file mode 100644 index c6c84fa..0000000 --- a/R/chk.R +++ /dev/null @@ -1,33 +0,0 @@ -# remove file once flobr 0.2.1 on CRAN -chk_exint <- function(x, x_name = NULL) { - if (vld_exint(x)) { - return(invisible()) - } - if (is.null(x_name)) x_name <- deparse_backtick_chk(substitute(x)) - - chk_s3_class(x, "exint", x_name = x_name) - chk_scalar(x, x_name = x_name) - chk_named(x, x_name = x_name) - chk_s3_class(x[[1]], "integer", x_name = p0("Element of ", x_name)) - chk_no_missing(x[[1]], x_name = p0("Element of ", x_name)) -} - -chk_flob <- function(x, old = FALSE, x_name = NULL) { - if (vld_flob(x, old = old)) { - return(invisible()) - } - - if (is.null(x_name)) x_name <- deparse_backtick_chk(substitute(x)) - - chk_s3_class(x, "flob", x_name = x_name) - chk_scalar(x, x_name = x_name) - - exint <- unlist(x) - exint <- try(unserialize(exint), silent = TRUE) - if (inherits(exint, "try-error")) { - abort_chk(x_name, " must be a blob of a serialized object.") - } - - if (!vld_false(old)) class(exint) <- "exint" - chk_exint(exint, x_name = paste("serialized element of", x_name)) -} diff --git a/R/dbflob.R b/R/dbflob.R index 373c7cf..f2365c9 100644 --- a/R/dbflob.R +++ b/R/dbflob.R @@ -24,7 +24,7 @@ #' DBI::dbReadTable(conn, "Table1") #' DBI::dbDisconnect(conn) write_flob <- function(flob, column_name, table_name, key, conn, exists = NA) { - chk_flob(flob) + flobr::chk_flob(flob) check_sqlite_connection(conn) check_table_name(table_name, conn) chk_lgl(exists) diff --git a/R/utils.R b/R/utils.R index a6bd54c..015ab23 100644 --- a/R/utils.R +++ b/R/utils.R @@ -8,7 +8,7 @@ parse_filename <- function(x, sep){ } collapse_flob <- function(x) { - chk_flob(x) + flobr::chk_flob(x) y <- glue_collapse(unlist(x), "") glue("x'{y}'") } diff --git a/R/vld.R b/R/vld.R index 7f4c204..869452d 100644 --- a/R/vld.R +++ b/R/vld.R @@ -1,11 +1,11 @@ -# remove file once flobr 0.2.1 on CRAN +# remove file once `flobr::vld_slob()` is on CRAN vld_exint <- function(x) { vld_s3_class(x, "exint") && vld_scalar(x) && vld_named(x) && vld_s3_class(x[[1]], "integer") && vld_not_any_na(x[[1]]) } -vld_flob <- function(x, old = FALSE) { - if (!(vld_s3_class(x, "flob") && vld_scalar(x))) { +vld_slob <- function(x) { + if (!(vld_s3_class(x, "blob") && vld_scalar(x) && vld_list(x))) { return(FALSE) } @@ -15,6 +15,6 @@ vld_flob <- function(x, old = FALSE) { return(FALSE) } - if (old) class(exint) <- "exint" + class(exint) <- "exint" vld_exint(exint) } diff --git a/README.Rmd b/README.Rmd index c6334f2..42112ff 100644 --- a/README.Rmd +++ b/README.Rmd @@ -17,9 +17,9 @@ knitr::opts_chunk$set( [![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) -[![R-CMD-check](https://github.com/poissonconsulting/dbflobr/workflows/R-CMD-check/badge.svg)](https://github.com/poissonconsulting/dbflobr/actions) -[![Codecov test coverage](https://codecov.io/gh/poissonconsulting/dbflobr/branch/master/graph/badge.svg)](https://app.codecov.io/gh/poissonconsulting/dbflobr?branch=master) -[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/license/mit/) +[![R-CMD-check](https://github.com/poissonconsulting/dbflobr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/poissonconsulting/dbflobr/actions/workflows/R-CMD-check.yaml) +[![Codecov test coverage](https://codecov.io/gh/poissonconsulting/dbflobr/graph/badge.svg)](https://app.codecov.io/gh/poissonconsulting/dbflobr) +[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) [![CRAN status](https://www.r-pkg.org/badges/version/dbflobr)](https://cran.r-project.org/package=dbflobr) ![CRAN downloads](https://cranlogs.r-pkg.org/badges/dbflobr) diff --git a/README.md b/README.md index a953f18..15ef6ce 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ -# dbflobr +# dbflobr \ [![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) -[![R-CMD-check](https://github.com/poissonconsulting/dbflobr/workflows/R-CMD-check/badge.svg)](https://github.com/poissonconsulting/dbflobr/actions) +[![R-CMD-check](https://github.com/poissonconsulting/dbflobr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/poissonconsulting/dbflobr/actions/workflows/R-CMD-check.yaml) [![Codecov test -coverage](https://codecov.io/gh/poissonconsulting/dbflobr/branch/master/graph/badge.svg)](https://app.codecov.io/gh/poissonconsulting/dbflobr?branch=master) +coverage](https://codecov.io/gh/poissonconsulting/dbflobr/graph/badge.svg)](https://app.codecov.io/gh/poissonconsulting/dbflobr) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) [![CRAN @@ -47,7 +47,7 @@ library(dbflobr) flob <- flobr::flob(system.file("extdata", "flobr.pdf", package = "flobr")) str(flob) #> List of 1 -#> $ /Library/Frameworks/R.framework/Versions/4.1/Resources/library/flobr/extdata/flobr.pdf: raw [1:133851] 58 0a 00 00 ... +#> $ /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/flobr/extdata/flobr.pdf: raw [1:133851] 58 0a 00 00 ... #> - attr(*, "class")= chr [1:2] "flob" "blob" # create a SQLite database connection @@ -93,8 +93,8 @@ DBI::dbDisconnect(conn) ## Inspiration -- [blob](https://github.com/tidyverse/blob) -- [flobr](https://github.com/poissonconsulting/flobr) +- [blob](https://github.com/tidyverse/blob) +- [flobr](https://github.com/poissonconsulting/flobr) ## Contribution diff --git a/tests/testthat/test-check.R b/tests/testthat/test-check.R index 994ce4a..dc4452a 100644 --- a/tests/testthat/test-check.R +++ b/tests/testthat/test-check.R @@ -107,7 +107,7 @@ test_that("check_flob_query", { expect_identical(check_flob_query(slob_obj, slob = TRUE), slob_obj) expect_identical(check_flob_query(slob_obj, slob = NA), slob_obj) - expect_error(check_flob_query("non-blob", slob = NA), "`x` must be a blob of a serialized object.") + expect_error(check_flob_query("non-blob", slob = TRUE), "`x` must be a blob of a serialized object.") # this is not ideal behavior expect_error(check_flob_query(slob_obj, slob = FALSE), "Serialized element of `x` must inherit from S3 class 'exint'.")