Skip to content

Commit

Permalink
Merge pull request #5 from jrdnbradford/extra-checks
Browse files Browse the repository at this point in the history
Comply with `extrachecks` (#4)
  • Loading branch information
jrdnbradford authored Sep 5, 2024
2 parents 1b37cc5 + 605fef3 commit 8eb2f2a
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 68 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/check-no-suggests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 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 only directly installs "hard" dependencies, i.e. Depends,
# Imports, and LinkingTo dependencies. Notably, Suggests dependencies are never
# installed, with the exception of testthat, knitr, and rmarkdown. The cache is
# never used to avoid accidentally restoring a cache containing a suggested
# dependency.
on:
push:
branches: [main]
pull_request:
branches: [main]

name: check-no-suggests.yaml

permissions: read-all

jobs:
check-no-suggests:
runs-on: ${{ matrix.config.os }}

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

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

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- 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-r-dependencies@v2
with:
dependencies: '"hard"'
cache: false
extra-packages: |
any::rcmdcheck
any::testthat
any::knitr
any::rmarkdown
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
12 changes: 6 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ Package: readMDTable
Title: Read Markdown Tables into Tibbles
Version: 0.0.0.9000
Authors@R:
person("Jordan", "Bradford", , "jrdnbradford@gmail.com", role = c("aut", "cre"))
person("Jordan", "Bradford", , "jrdnbradford@gmail.com", role = c("aut", "cre", "cph"))
Description: Read markdown tables from a string, file, or URL into tibbles.
Imports:
httr,
lubridate,
readr,
stringr
URL: https://github.com/jrdnbradford/readMDTable, https://jrdnbradford.github.io/readMDTable
stringr,
tibble
URL: https://github.com/jrdnbradford/readMDTable, https://jrdnbradford.github.io/readMDTable/
BugReports: https://github.com/jrdnbradford/readMDTable/issues
License: GPL (>= 3)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Suggests:
lubridate,
tibble,
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
2 changes: 2 additions & 0 deletions R/source_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#' @return Character vectors of markdown table
#'
#' @keywords internal
#'
#' @noRd
source_file <- function(file) {
if (file.exists(file)) {
markdown_table <- read_file(file)
Expand Down
2 changes: 2 additions & 0 deletions R/warn_md_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#' @param lines Character vector provided by `source_file`
#'
#' @keywords internal
#'
#' @noRd
warn_md_table <- function(lines) {
# Remove the last line if it's empty
if (length(lines) > 0 && lines[length(lines)] == "") {
Expand Down
4 changes: 2 additions & 2 deletions man/readMDTable-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 0 additions & 24 deletions man/source_file.Rd

This file was deleted.

18 changes: 0 additions & 18 deletions man/warn_md_table.Rd

This file was deleted.

32 changes: 14 additions & 18 deletions tests/testthat/test-read_md_table.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
library(tibble)
library(lubridate)


test_that("read_md_table can read simple markdown table from file", {
md_file <- test_path("testmd", "simple.md")
md <- read_md_table(md_file, show_col_types = FALSE)

expected_tibble <- tribble(
expected_tibble <- tibble::tribble(
~Name, ~Age, ~City, ~Date,
"Alice", 30, "New York", ymd("2021/01/08"),
"Bob", 25, "Los Angeles", ymd("2023/07/22"),
"Carol", 27, "Chicago", ymd("2022/11/01")
"Alice", 30, "New York", lubridate::ymd("2021/01/08"),
"Bob", 25, "Los Angeles", lubridate::ymd("2023/07/22"),
"Carol", 27, "Chicago", lubridate::ymd("2022/11/01")
)

expect_identical(expected_tibble, md)
Expand All @@ -21,10 +17,10 @@ test_that("read_md_table can handle missing values in markdown table from file",
md_file <- test_path("testmd", "missing-values.md")
md <- read_md_table(md_file, show_col_types = FALSE)

expected_tibble <- tribble(
expected_tibble <- tibble::tribble(
~Name, ~Age, ~City, ~Date,
"Alice", 30, NA, ymd("2021/01/08"),
"Bob", 25, "Los Angeles", ymd("2023/07/22"),
"Alice", 30, NA, lubridate::ymd("2021/01/08"),
"Bob", 25, "Los Angeles", lubridate::ymd("2023/07/22"),
"Carol", 27, "Chicago", NA,
)

Expand All @@ -36,10 +32,10 @@ test_that("read_md_table can read messy markdown table from file", {
md_file <- test_path("testmd", "messy.md")
md <- read_md_table(md_file, show_col_types = FALSE)

expected_tibble <- tribble(
expected_tibble <- tibble::tribble(
~Name, ~Age, ~City, ~Date,
"Alice", 30, NA, ymd("2021/01/08"),
"Bob", 25, "Los Angeles", ymd("2023/07/22"),
"Alice", 30, NA, lubridate::ymd("2021/01/08"),
"Bob", 25, "Los Angeles", lubridate::ymd("2023/07/22"),
"Carol", 27, "Chicago", NA,
)

Expand All @@ -52,11 +48,11 @@ test_that("read_md_table can read messy markdown table from string", {
")
md <- read_md_table(md_string, show_col_types = FALSE)

expected_tibble <- tribble(
expected_tibble <- tibble::tribble(
~Name, ~Age, ~City, ~Date,
"Alice", 30, "New York", ymd("2021/01/08"),
"Bob", 25, "Los Angeles", ymd("2023/07/22"),
"Carol", 27, "Chicago", ymd("2022/11/01")
"Alice", 30, "New York", lubridate::ymd("2021/01/08"),
"Bob", 25, "Los Angeles", lubridate::ymd("2023/07/22"),
"Carol", 27, "Chicago", lubridate::ymd("2022/11/01")
)

expect_identical(expected_tibble, md)
Expand Down

0 comments on commit 8eb2f2a

Please sign in to comment.