Skip to content

Commit

Permalink
Merge pull request #42 from billdenney/housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi authored Aug 4, 2024
2 parents 2b2aecd + 6b080d3 commit 83f825f
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 65 deletions.
20 changes: 5 additions & 15 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# 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]
pull_request:
branches: [main, master]

name: R-CMD-check
name: R-CMD-check.yaml

permissions: read-all

jobs:
R-CMD-check:
Expand All @@ -23,26 +21,17 @@ jobs:
matrix:
config:
- {os: macos-latest, r: 'release'}

- {os: windows-latest, r: 'release'}
# Use 3.6 to trigger usage of RTools35
- {os: windows-latest, r: '3.6'}
# use 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: '4.1'}

- {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:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

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

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

Expand All @@ -60,3 +49,4 @@ jobs:
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
10 changes: 7 additions & 3 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ on:
types: [published]
workflow_dispatch:

name: pkgdown
name: pkgdown.yaml

permissions: read-all

jobs:
pkgdown:
Expand All @@ -19,8 +21,10 @@ jobs:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

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

Expand All @@ -39,7 +43,7 @@ jobs:

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.4.1
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ on:
issue_comment:
types: [created]

name: Commands
name: pr-commands.yaml

permissions: read-all

jobs:
document:
Expand All @@ -13,8 +15,10 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/pr-fetch@v2
with:
Expand Down Expand Up @@ -50,8 +54,10 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/pr-fetch@v2
with:
Expand Down
25 changes: 18 additions & 7 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ on:
pull_request:
branches: [main, master]

name: test-coverage
name: test-coverage.yaml

permissions: read-all

jobs:
test-coverage:
Expand All @@ -15,36 +17,45 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
- 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
extra-packages: any::covr, any::xml2
needs: coverage

- name: Test coverage
run: |
covr::codecov(
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
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
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ Description: Parse dates automatically, without the need of
License: GPL-2
Suggests:
covr,
testthat,
testthat (>= 3.0.0),
withr
URL: https://github.com/gaborcsardi/parsedate
BugReports: https://github.com/gaborcsardi/parsedate/issues
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
Encoding: UTF-8
Config/testthat/edition: 3
3 changes: 1 addition & 2 deletions R/parsedate-package.r
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
#' a specific ISO 8601 format.
#' }
#'
#' @docType package
#' @name parsedate-package
#' @useDynLib parsedate, .registration = TRUE, .fixes = "C_"

NULL
"_PACKAGE"

## Some simple utility functions. We used to take them from lubridate,
## but that brings in plyr, Rcpp, etc. Better to keep dependencies light.
Expand Down
3 changes: 1 addition & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ output: github_document
[![R build status](https://github.com/gaborcsardi/parsedate/workflows/R-CMD-check/badge.svg)](https://github.com/gaborcsardi/parsedate/actions)
[![](https://www.r-pkg.org/badges/version/parsedate)](https://www.r-pkg.org/pkg/parsedate)
[![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/parsedate)](https://r-pkg.org/pkg/parsedate)
[![Codecov test coverage](https://codecov.io/gh/gaborcsardi/parsedate/branch/main/graph/badge.svg)](https://app.codecov.io/gh/gaborcsardi/parsedate?branch=main)
[![R-CMD-check](https://github.com/gaborcsardi/parsedate/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/gaborcsardi/parsedate/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/gaborcsardi/parsedate/graph/badge.svg)](https://app.codecov.io/gh/gaborcsardi/parsedate)
<!-- badges: end -->

This R package has three functions for dealing with dates.
Expand Down
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@ status](https://github.com/gaborcsardi/parsedate/workflows/R-CMD-check/badge.svg
[![CRAN RStudio mirror
downloads](https://cranlogs.r-pkg.org/badges/parsedate)](https://r-pkg.org/pkg/parsedate)
[![Codecov test
coverage](https://codecov.io/gh/gaborcsardi/parsedate/branch/main/graph/badge.svg)](https://app.codecov.io/gh/gaborcsardi/parsedate?branch=main)
[![R-CMD-check](https://github.com/gaborcsardi/parsedate/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/gaborcsardi/parsedate/actions/workflows/R-CMD-check.yaml)
coverage](https://codecov.io/gh/gaborcsardi/parsedate/graph/badge.svg)](https://app.codecov.io/gh/gaborcsardi/parsedate)
<!-- badges: end -->

This R package has three functions for dealing with dates.

- `parse_iso_8601` recognizes and parses all valid ISO 8601 date and
time formats. It can also be used as an ISO 8601 validator.
- `parse_date` can parse a date when you don’t know which format it is
in. First it tries all ISO 8601 formats. Then it tries git’s
versatile date parser. Lastly, it tries `as.POSIXct`.
- `format_iso_8601` formats a date (and time) in specific ISO 8601
format.
- `parse_iso_8601` recognizes and parses all valid ISO 8601 date and
time formats. It can also be used as an ISO 8601 validator.
- `parse_date` can parse a date when you don’t know which format it is
in. First it tries all ISO 8601 formats. Then it tries git’s versatile
date parser. Lastly, it tries `as.POSIXct`.
- `format_iso_8601` formats a date (and time) in specific ISO 8601
format.

## Limitations

Expand All @@ -39,13 +38,13 @@ parse_date("april 15 1971")
parse_date("april 15 1969")
```

## [1] "2022-04-15 UTC"
## [1] "2024-04-15 UTC"

``` r
parse_date("april 15 2110")
```

## [1] "2022-04-15 UTC"
## [1] "2024-04-15 UTC"

## Parsing ISO 8601 dates

Expand Down Expand Up @@ -214,13 +213,13 @@ parse_date("11/12/99")
parse_date("03/20")
```

## [1] "2022-03-20 UTC"
## [1] "2024-03-20 UTC"

``` r
parse_date("12")
```

## [1] "2022-01-12 UTC"
## [1] "2024-08-12 UTC"

But not for this, because this is ISO 8601.

Expand Down
9 changes: 9 additions & 0 deletions man/parsedate-package.Rd

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

10 changes: 10 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# This file is part of the standard setup for testthat.
# It is recommended that you do not modify it.
#
# Where should you do additional test configuration?
# Learn more about the roles of various files in:
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview
# * https://testthat.r-lib.org/articles/special-files.html

library(testthat)
library(parsedate)

test_check("parsedate")

# Package-specific modifications below here

run <- function(tz) {
source("testthat/helper.R")
withr::local_timezone(tz)
Expand Down
15 changes: 7 additions & 8 deletions tests/testthat/test-corner-cases.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

context("Dates and empty strings")
# Dates and empty strings ----

test_that("Bug #10 is fixed", {

Expand All @@ -21,7 +20,7 @@ test_that("Empty strings are replaced by NAs", {
actual <- parse_date(dates)

expect_equal(expected, actual)

})

test_that("White-space string is replaced by NAs", {
Expand All @@ -31,7 +30,7 @@ test_that("White-space string is replaced by NAs", {
actual <- parse_date(date)

expect_equal(expected, actual)

})

test_that("White-spaces are gracefully removed", {
Expand All @@ -41,18 +40,18 @@ test_that("White-spaces are gracefully removed", {
actual <- parse_date(date)

expect_equal(expected, actual)

})


test_that("Non-sensical input is removed", {

date <- "?=)(!$§#$%"
expected <- .POSIXct(NA_real_, "UTC")
actual <- parse_date(date)

expect_equal(expected, actual)

})

test_that("Approx parameter is passed on", {
Expand Down
5 changes: 2 additions & 3 deletions tests/testthat/test-git.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

context("Git dates")
# Git dates ----

test_that("Filling in is correct", {

Expand Down Expand Up @@ -30,7 +29,7 @@ test_that("Issue #3 is resolved", {
d1 <- parse_date("20070809 14:35:42")
d2 <- parse_date("2007-08-09 14:35:42")
expect_equal(d1, d2)

})

test_that("Issue #4 is resolved", {
Expand Down
Loading

0 comments on commit 83f825f

Please sign in to comment.