diff --git a/.Rbuildignore b/.Rbuildignore index 01c8a9e0..b4c6482c 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,5 @@ ^httr2\.Rproj$ ^\.Rproj\.user$ ^LICENSE\.md$ +^codecov\.yml$ +^\.github$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 00000000..2d19fc76 --- /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 00000000..259ccc05 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,112 @@ +# 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 +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + +name: R-CMD-check + +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: windows-latest, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/latest"} + - {os: ubuntu-18.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } + - {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + - {os: ubuntu-18.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + - {os: ubuntu-18.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + - {os: ubuntu-18.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + - {os: ubuntu-18.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + + env: + RSPM: ${{ matrix.config.rspm }} + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@v1 + id: install-r + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + + - uses: r-lib/actions/setup-pandoc@v1 + + - name: Install pak and query dependencies + run: | + install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/") + saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds") + shell: Rscript {0} + + - name: Restore R package cache + uses: actions/cache@v2 + with: + path: | + ${{ env.R_LIBS_USER }}/* + !${{ env.R_LIBS_USER }}/pak + key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }} + restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1- + + - name: Install system dependencies + if: runner.os == 'Linux' + run: | + pak::local_system_requirements(execute = TRUE) + pak::pkg_system_requirements("rcmdcheck", execute = TRUE) + shell: Rscript {0} + + - name: Install dependencies + run: | + pak::local_install_dev_deps(upgrade = TRUE) + pak::pkg_install("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 + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@main + with: + name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results + path: check + + - name: Don't use tar from old Rtools to store the cache + if: ${{ runner.os == 'Windows' && startsWith(steps.install-r.outputs.installed-r-version, '3.6' ) }} + shell: bash + run: echo "C:/Program Files/Git/usr/bin" >> $GITHUB_PATH diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 00000000..9ee741ab --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,59 @@ +on: + push: + branches: + - main + - master + +name: pkgdown + +jobs: + pkgdown: + runs-on: ubuntu-18.04 + env: + RSPM: https://packagemanager.rstudio.com/cran/__linux__/bionic/latest + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@v1 + id: install-r + + - uses: r-lib/actions/setup-pandoc@v1 + + - name: Install pak and query dependencies + run: | + install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/") + saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds") + shell: Rscript {0} + + - name: Restore R package cache + uses: actions/cache@v2 + with: + path: | + ${{ env.R_LIBS_USER }}/* + !${{ env.R_LIBS_USER }}/pak + key: ubuntu-18.04-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }} + restore-keys: ubuntu-18.04-${{ steps.install-r.outputs.installed-r-version }}-1- + + - name: Install system dependencies + if: runner.os == 'Linux' + run: | + pak::local_system_requirements(execute = TRUE) + pak::pkg_system_requirements("pkgdown", execute = TRUE) + shell: Rscript {0} + + - name: Install dependencies + run: | + pak::local_install_dev_deps(upgrade = TRUE, dependencies = c("all", "Config/Needs/website")) + pak::pkg_install("pkgdown") + shell: Rscript {0} + + - name: Install package + run: R CMD INSTALL . + + - name: Build and deploy pkgdown site + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)' diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml new file mode 100644 index 00000000..e5edf9f7 --- /dev/null +++ b/.github/workflows/pr-commands.yaml @@ -0,0 +1,55 @@ +on: + issue_comment: + types: [created] +name: Commands +jobs: + document: + if: startsWith(github.event.comment.body, '/document') + name: document + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + - uses: r-lib/actions/pr-fetch@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - uses: r-lib/actions/setup-r@v1 + - name: Install dependencies + run: Rscript -e 'install.packages(c("remotes", "roxygen2"))' -e 'remotes::install_deps(dependencies = TRUE)' + - name: Document + run: Rscript -e 'roxygen2::roxygenise()' + - name: commit + run: | + git config --local user.email "actions@github.com" + git config --local user.name "GitHub Actions" + git add man/\* NAMESPACE + git commit -m 'Document' + - uses: r-lib/actions/pr-push@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + style: + if: startsWith(github.event.comment.body, '/style') + name: style + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + - uses: r-lib/actions/pr-fetch@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - uses: r-lib/actions/setup-r@v1 + - name: Install dependencies + run: Rscript -e 'install.packages("styler")' + - name: Style + run: Rscript -e 'styler::style_pkg()' + - name: commit + run: | + git config --local user.email "actions@github.com" + git config --local user.name "GitHub Actions" + git add \*.R + git commit -m 'Style' + - uses: r-lib/actions/pr-push@v1 + 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 00000000..548afa52 --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,56 @@ +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + +name: test-coverage + +jobs: + test-coverage: + runs-on: ubuntu-18.04 + env: + RSPM: https://packagemanager.rstudio.com/cran/__linux__/bionic/latest + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@v1 + id: install-r + + - name: Install pak and query dependencies + run: | + install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/") + saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds") + shell: Rscript {0} + + - name: Restore R package cache + uses: actions/cache@v2 + with: + path: | + ${{ env.R_LIBS_USER }}/* + !${{ env.R_LIBS_USER }}/pak + key: ubuntu-18.04-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }} + restore-keys: ubuntu-18.04-${{ steps.install-r.outputs.installed-r-version }}-1- + + - name: Install system dependencies + if: runner.os == 'Linux' + run: | + pak::local_system_requirements(execute = TRUE) + pak::pkg_system_requirements("covr", execute = TRUE) + shell: Rscript {0} + + - name: Install dependencies + run: | + pak::local_install_dev_deps(upgrade = TRUE) + pak::pkg_install("covr") + shell: Rscript {0} + + - name: Test coverage + run: covr::codecov() + shell: Rscript {0} diff --git a/DESCRIPTION b/DESCRIPTION index cab1720a..7cf76c7e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -27,5 +27,6 @@ Imports: Suggests: testthat (>= 3.0.0), jsonlite, - xml2 + xml2, + covr Config/testthat/edition: 3 diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..04c55859 --- /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