diff --git a/.Rbuildignore b/.Rbuildignore index 60d7fd8..dc20cc2 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -4,3 +4,5 @@ ^LICENSE\.md$ ^\.travis\.yml$ ^codecov\.yml$ +^\.github$ +^CRAN-SUBMISSION$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..562fe0f --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,51 @@ +# 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: + +name: R-CMD-check.yaml + +permissions: read-all + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + + 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: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml new file mode 100644 index 0000000..2edd93f --- /dev/null +++ b/.github/workflows/pr-commands.yaml @@ -0,0 +1,85 @@ +# 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: + issue_comment: + types: [created] + +name: pr-commands.yaml + +permissions: read-all + +jobs: + document: + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }} + name: document + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/pr-fetch@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::roxygen2 + needs: pr-document + + - name: Document + run: roxygen2::roxygenise() + shell: Rscript {0} + + - name: commit + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add man/\* NAMESPACE + git commit -m 'Document' + + - uses: r-lib/actions/pr-push@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + style: + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }} + name: style + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/pr-fetch@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - uses: r-lib/actions/setup-r@v2 + + - name: Install dependencies + run: install.packages("styler") + shell: Rscript {0} + + - name: Style + run: styler::style_pkg() + shell: Rscript {0} + + - name: commit + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add \*.R + git commit -m 'Style' + + - uses: r-lib/actions/pr-push@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..e050312 --- /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: + +name: test-coverage.yaml + +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 if error if not on PR, or if on PR and token is given + fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }} + 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/.gitignore b/.gitignore index 807ea25..9b83777 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .Rproj.user .Rhistory .RData +*.Rproj diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ccef59f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r - -language: R -cache: packages - -r: - - release - - devel - -after_success: - - Rscript -e 'covr::codecov()' diff --git a/DESCRIPTION b/DESCRIPTION index 0f73b42..3d26bc2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,15 +1,17 @@ Package: formulops Title: Mathematical Operations on R Formula -Version: 0.5.0 +Version: 0.5.1 Authors@R: person("Bill", "Denney", email="wdenney@humanpredictions.com", role=c("aut", "cre"), comment=c(ORCID="0000-0002-5759-428X")) Description: Perform mathematical operations on R formula (add, subtract, multiply, etc.) and substitute parts of formula. Depends: R (>= 3.5) License: GPL-3 Encoding: UTF-8 -LazyData: true -RoxygenNote: 7.0.2 +RoxygenNote: 7.3.2 Suggests: covr, - testthat -URL: https://github.com/billdenney/formulops -BugReports: https://github.com/billdenney/formulops/issues + spelling, + testthat (>= 3.0.0) +URL: https://github.com/humanpred/formulops +BugReports: https://github.com/humanpred/formulops/issues +Config/testthat/edition: 3 +Language: en-US diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..2210277 --- /dev/null +++ b/NEWS.md @@ -0,0 +1,7 @@ +# formulops 0.5.1 + +* Move to a different GitHub repository and general housekeeping (no functional differences) + +# formulops 0.5.0 + +* Initial CRAN version diff --git a/README.md b/README.md index 74880c2..03a9ad4 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # formulops -[![Travis build status](https://travis-ci.org/billdenney/formulops.svg?branch=master)](https://travis-ci.org/billdenney/formulops) -[![Codecov test coverage](https://codecov.io/gh/billdenney/formulops/branch/master/graph/badge.svg)](https://codecov.io/gh/billdenney/formulops?branch=master) [![CRAN status](https://www.r-pkg.org/badges/version/formulops)](https://CRAN.R-project.org/package=formulops) +[![R-CMD-check](https://github.com/humanpred/formulops/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/humanpred/formulops/actions/workflows/R-CMD-check.yaml) +[![Codecov test coverage](https://codecov.io/gh/humanpred/formulops/graph/badge.svg)](https://app.codecov.io/gh/humanpred/formulops) The goal of formulops is to assist with formula modification in R treating diff --git a/codecov.yml b/codecov.yml index 8f36b6c..04c5585 100644 --- a/codecov.yml +++ b/codecov.yml @@ -6,7 +6,9 @@ coverage: default: target: auto threshold: 1% + informational: true patch: default: target: auto threshold: 1% + informational: true diff --git a/formulops.Rproj b/formulops.Rproj deleted file mode 100644 index d848a9f..0000000 --- a/formulops.Rproj +++ /dev/null @@ -1,16 +0,0 @@ -Version: 1.0 - -RestoreWorkspace: No -SaveWorkspace: No -AlwaysSaveHistory: Default - -EnableCodeIndexing: Yes -Encoding: UTF-8 - -AutoAppendNewline: Yes -StripTrailingWhitespace: Yes - -BuildType: Package -PackageUseDevtools: Yes -PackageInstallArgs: --no-multiarch --with-keep.source -PackageRoxygenize: rd,collate,namespace diff --git a/inst/WORDLIST b/inst/WORDLIST new file mode 100644 index 0000000..5cc68a2 --- /dev/null +++ b/inst/WORDLIST @@ -0,0 +1,2 @@ +CMD +Codecov diff --git a/man/formula_side.Rd b/man/formula_side.Rd index 27e8f12..b6547eb 100644 --- a/man/formula_side.Rd +++ b/man/formula_side.Rd @@ -23,9 +23,9 @@ Extract formula parts } \section{Functions}{ \itemize{ -\item \code{get_lhs}: Extract the left hand side (NULL for one-sided +\item \code{get_lhs()}: Extract the left hand side (NULL for one-sided formula). -\item \code{get_rhs}: Extract the right hand side. -}} +\item \code{get_rhs()}: Extract the right hand side. +}} diff --git a/man/substituting_formula.Rd b/man/substituting_formula.Rd index 1f1d2a6..7421919 100644 --- a/man/substituting_formula.Rd +++ b/man/substituting_formula.Rd @@ -32,9 +32,9 @@ Formula are substituted in order. Substitutions may not have the } \section{Functions}{ \itemize{ -\item \code{as_substituting_formula}: Generate and check substituting_formula -}} +\item \code{as_substituting_formula()}: Generate and check substituting_formula +}} \examples{ foo <- substituting_formula(y~x1+x2, x1~x3*x4, x2~x5/x6+x7) as.formula(foo) diff --git a/tests/spelling.R b/tests/spelling.R new file mode 100644 index 0000000..6713838 --- /dev/null +++ b/tests/spelling.R @@ -0,0 +1,3 @@ +if(requireNamespace('spelling', quietly = TRUE)) + spelling::spell_check_test(vignettes = TRUE, error = FALSE, + skip_on_cran = TRUE) diff --git a/tests/testthat.R b/tests/testthat.R index 5e5a968..952b13d 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -1,3 +1,11 @@ +# 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(formulops) diff --git a/tests/testthat/test-formula_math.R b/tests/testthat/test-formula_math.R index 407072f..cc6b361 100644 --- a/tests/testthat/test-formula_math.R +++ b/tests/testthat/test-formula_math.R @@ -1,5 +1,3 @@ -context("Math and modification for formulae") - test_that("modify_formula tests its inputs", { expect_error( modify_formula(a~b, find=list(), replace=quote(c)), @@ -134,75 +132,75 @@ test_that("op_formula adds parentheses correctly to all combinations of one- and expect_equal( op_formula("*", ~c+d, ~g+h), ~(c+d)*(g+h) - ) + ) expect_equal( op_formula("*", ~c, ~g+h), ~c*(g+h) - ) + ) expect_equal( op_formula("*", ~c+d, ~g), ~(c+d)*g - ) + ) expect_equal( op_formula("*", ~c, ~g), ~c*g - ) + ) # two-sided expect_equal( op_formula("*", a+b~c+d, e+f~g+h), (a+b)*(e+f)~(c+d)*(g+h) - ) + ) expect_equal( op_formula("*", b~c+d, e+f~g+h), b*(e+f)~(c+d)*(g+h) - ) + ) expect_equal( op_formula("*", a+b~c, e+f~g+h), (a+b)*(e+f)~c*(g+h) - ) + ) expect_equal( op_formula("*", a+b~c+d, f~g+h), (a+b)*f~(c+d)*(g+h) - ) + ) expect_equal( op_formula("*", a+b~c+d, e+f~h), (a+b)*(e+f)~(c+d)*h - ) + ) # Mixed one- and two-sided expect_equal( op_formula("*", ~c, e~g), e~c*g - ) + ) expect_equal( op_formula("*", ~c, e+f~g), e+f~c*g - ) + ) expect_equal( op_formula("*", ~c, e~g+h), e~c*(g+h) - ) + ) expect_equal( op_formula("*", ~c, e+f~g+h), e+f~c*(g+h) - ) + ) expect_equal( op_formula("*", ~c+d, e~g), e~(c+d)*g - ) + ) expect_equal( op_formula("*", ~c+d, e+f~g), e+f~(c+d)*g - ) + ) expect_equal( op_formula("*", ~c+d, e~g+h), e~(c+d)*(g+h) - ) + ) expect_equal( op_formula("*", ~c+d, e+f~g+h), e+f~(c+d)*(g+h) - ) + ) }) test_that("Ops and convenience functions are equal", { diff --git a/tests/testthat/test-formula_side.R b/tests/testthat/test-formula_side.R index 1509150..a3b885a 100644 --- a/tests/testthat/test-formula_side.R +++ b/tests/testthat/test-formula_side.R @@ -1,5 +1,3 @@ -context("formula_side") - test_that("get_lhs works", { expect_equal( get_lhs(a~b), diff --git a/tests/testthat/test-simplify_parens.R b/tests/testthat/test-simplify_parens.R index 896b401..335fb17 100644 --- a/tests/testthat/test-simplify_parens.R +++ b/tests/testthat/test-simplify_parens.R @@ -1,5 +1,3 @@ -context("simplify_parens") - test_that("simplify_parens doesn't change things that shouldn't change", { expect_equal(simplify_parens(~a), ~a) expect_equal(simplify_parens(a~b), a~b) diff --git a/tests/testthat/test-substituting_formula.R b/tests/testthat/test-substituting_formula.R index eb362ea..b9498e1 100644 --- a/tests/testthat/test-substituting_formula.R +++ b/tests/testthat/test-substituting_formula.R @@ -1,5 +1,3 @@ -context("substituting_formla") - test_that("error checks work", { expect_error( as_substituting_formula(a~b, 1), @@ -30,11 +28,11 @@ test_that("error checks work", { test_that("formula are created correctly", { expect_equal( - formula(substituting_formula(a~b, b~c*d, d~e+f)), + formula(substituting_formula(a~b, b~c*d, d~(e+f))), a~c*(e+f) ) expect_equal( - as.formula(substituting_formula(a~b, b~c*d, d~e+f), env=emptyenv()), + as.formula(substituting_formula(a~b, b~c*d, d~(e+f)), env=emptyenv()), `environment<-`(a~c*(e+f), emptyenv()) ) })