diff --git a/.Rbuildignore b/.Rbuildignore index 40f3a65..3902644 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -9,3 +9,4 @@ ^pkgdown$ \.o$ ^\.github$ +^codecov\.yml$ diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 66428ab..a3ac618 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,18 +1,10 @@ -# NOTE: This workflow is overkill for most R packages -# check-standard.yaml is likely a better choice -# usethis::use_github_action("check-standard") will install it. -# -# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. -# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions +# 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 + branches: [main, master] name: R-CMD-check @@ -26,83 +18,32 @@ jobs: fail-fast: false matrix: config: - - {os: macOS-latest, r: 'release'} + - {os: macos-latest, r: 'release'} - {os: windows-latest, r: 'release'} - - {os: windows-latest, r: '3.6'} - # We explicitly set the user agent for R devel to the current release version of R so RSPM serves the release binaries. - - {os: ubuntu-16.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest", http-user-agent: "R/4.0.0 (ubuntu-16.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } - - {os: ubuntu-16.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} 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 - - - uses: r-lib/actions/setup-tinytex@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", "16.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_: false - run: | - options(crayon.enabled = TRUE) - 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 + extra-packages: any::rcmdcheck + needs: check - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main + - uses: r-lib/actions/check-r-package@v2 with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check + upload-snapshots: true diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 3c908d3..ed7650c 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -1,48 +1,48 @@ +# 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 jobs: pkgdown: - 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: actions/checkout@v3 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-pandoc@v2 - - 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} + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true - - name: Cache R packages - 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::pkgdown, local::. + needs: website - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - install.packages("pkgdown", type = "binary") + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) shell: Rscript {0} - - name: Install package - run: R CMD INSTALL . - - - 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: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@v4.4.1 + with: + 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..2c5bb50 --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +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] + pull_request: + branches: [main, master] + +name: test-coverage + +jobs: + test-coverage: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v3 + + - 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 + needs: coverage + + - name: Test coverage + run: | + 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: Upload test results + if: failure() + uses: actions/upload-artifact@v3 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package diff --git a/.gitignore b/.gitignore index 31bd64c..8a37749 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ doc Meta /vignettes/lbfgsb3c.R -/vignettes/.Rhistory /src/lbfgsb3c.so -/src/.Rhistory -/.Rhistory +.Rhistory +docs +inst/doc diff --git a/DESCRIPTION b/DESCRIPTION index 86cb82b..f114924 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,12 +23,19 @@ Description: Interfacing to Nocedal et al. L-BFGS-B.3.0 License: GPL-2 Depends: R (>= 3.6) Imports: Rcpp (>= 0.12.3), numDeriv, methods -Suggests: optimx, microbenchmark, testthat, knitr, pkgbuild, rmarkdown, RcppArmadillo +Suggests: + knitr, + microbenchmark, + optimx, + pkgbuild, + RcppArmadillo, + rmarkdown, + testthat (>= 3.0.0) LinkingTo: Rcpp (>= 0.12.3), RcppArmadillo Encoding: UTF-8 VignetteBuilder: knitr NeedsCompilation: yes -RoxygenNote: 7.0.2 +RoxygenNote: 7.2.3 Author: Matthew L Fidler [aut, cre], John C Nash [aut], Ciyou Zhu [aut], @@ -36,3 +43,5 @@ Author: Matthew L Fidler [aut, cre], Jorge Nocedal [aut], Jose Luis Morales [aut] Packaged: 2020-02-26 20:18:51 UTC; john +URL: https://nlmixr2.github.io/lbfgsb3c/ +Config/testthat/edition: 3 diff --git a/README.md b/README.md index e319a70..1e74582 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ -[![R-CMD-check](https://github.com/nlmixrdevelopment/lbfgsb3c/workflows/R-CMD-check/badge.svg)](https://github.com/nlmixrdevelopment/lbfgsb3c/actions) + +[![R-CMD-check](https://github.com/nlmixr2/lbfgsb3c/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/nlmixr2/lbfgsb3c/actions/workflows/R-CMD-check.yaml) [![CRAN total downloads](https://cranlogs.r-pkg.org/badges/grand-total/lbfgsb3c)](https://cran.r-project.org/package=lbfgsb3c) [![CRAN total downloads](https://cranlogs.r-pkg.org/badges/lbfgsb3c)](https://cran.r-project.org/package=lbfgsb3c) +[![Codecov test coverage](https://codecov.io/gh/nlmixr2/lbfgsb3c/branch/main/graph/badge.svg)](https://app.codecov.io/gh/nlmixr2/lbfgsb3c?branch=main) + # libfgsb3c interface from C This is the fork of the libfgsb3 from cran with the following differences: diff --git a/_pkgdown.yml b/_pkgdown.yml index 6ef5f5a..9a05540 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1 +1,4 @@ -destination: docs +url: https://nlmixr2.github.io/lbfgsb3c/ +template: + bootstrap: 5 + diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..04c5585 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,14 @@ +comment: false + +coverage: + status: + project: + default: + target: auto + threshold: 1% + informational: true + patch: + default: + target: auto + threshold: 1% + informational: true diff --git a/tests/testthat.R b/tests/testthat.R index ee315a3..f22ae0d 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(lbfgsb3c) diff --git a/tests/testthat/test-bounds.R b/tests/testthat/test-bounds.R index c415d68..e4ae570 100644 --- a/tests/testthat/test-bounds.R +++ b/tests/testthat/test-bounds.R @@ -1,4 +1,3 @@ -context("Bounds") test_that("bounds test", { bt.f<-function(x){ sum(x*x) diff --git a/tests/testthat/test-cyq.R b/tests/testthat/test-cyq.R index 303fea9..329408b 100644 --- a/tests/testthat/test-cyq.R +++ b/tests/testthat/test-cyq.R @@ -82,7 +82,6 @@ nn <- c(2, 3, 5, 8) for (n in nn) { str <- paste0("Chebyquad in ", n, " parameters"); - context(str) test_that(str, { lower <- rep(-10, n) upper <- rep(10, n) @@ -109,5 +108,4 @@ for (n in nn) { round(ans$value, 3)) } }) - } diff --git a/tests/testthat/test-genrose.R b/tests/testthat/test-genrose.R index 7e4c4cd..18fe137 100644 --- a/tests/testthat/test-genrose.R +++ b/tests/testthat/test-genrose.R @@ -28,7 +28,7 @@ genrose.g <- function(x, gs = NULL) { gg } -context("Unconstrained Genrose test with gradient") +# Unconstrained Genrose test with gradient nn <- 100 xx <- rep(3, nn) @@ -41,7 +41,7 @@ test_that("100u", { }) -context("Unconstrained Genrose test without gradient") +# Unconstrained Genrose test without gradient ans100un <- lbfgsb3c(xx, genrose.f, gr = NULL, gs = 10) diff --git a/vignettes/.gitignore b/vignettes/.gitignore new file mode 100644 index 0000000..097b241 --- /dev/null +++ b/vignettes/.gitignore @@ -0,0 +1,2 @@ +*.html +*.R diff --git a/vignettes/lbfgsb3c.Rmd b/vignettes/lbfgsb3c.Rmd index 2ba0fc2..3b8eace 100644 --- a/vignettes/lbfgsb3c.Rmd +++ b/vignettes/lbfgsb3c.Rmd @@ -5,13 +5,12 @@ author: "John C Nash University of Ottawa, nashjc@uottawa.ca" date: "October 22, 2019" -output: - pdf_document +output: rmarkdown::html_vignette bibliography: lbfgsb3c.bib vignette: > %\VignetteIndexEntry{lbfgsb3c-nocompile} %\VignetteEngine{knitr::rmarkdown} - \usepackage[utf8]{inputenc} + %\VignetteEncoding{UTF-8} --- ```{r setup, include=FALSE}