Skip to content

Commit

Permalink
use appropriate tests for success, and make sure greta is installed o…
Browse files Browse the repository at this point in the history
…n R CMD Check
  • Loading branch information
njtierney committed Dec 11, 2024
1 parent 627b407 commit c0f1ed7
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 27 deletions.
118 changes: 93 additions & 25 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,49 +1,117 @@
# 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
schedule:
- cron: '1 23 * * Sun'

name: R-CMD-check

defaults:
run:
shell: Rscript {0}

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

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

name: ${{ matrix.os }}, tf-${{ matrix.tf }}, R-${{ matrix.r}}
timeout-minutes: 30
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'}
include:
- {os: 'ubuntu-latest' , tf: 'default', r: 'release'}
- {os: 'windows-latest', tf: 'default', r: 'release'}
- {os: 'macOS-latest' , tf: 'default', r: 'release'}

runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.tf == 'nightly' || contains(matrix.tf, 'rc') || matrix.r == 'devel' }}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: 'true'
R_COMPILE_AND_INSTALL_PACKAGES: 'never'
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

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

- uses: r-lib/actions/setup-r@v2
id: setup-r
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
r-version: ${{ matrix.r }}
Ncpus: '2L'
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check
- uses: r-lib/actions/setup-pandoc@v2

- name: Get Date
id: get-date
shell: bash
run: |
echo "::set-output name=year-week::$(date -u "+%Y-%U")"
echo "::set-output name=date::$(date -u "+%F")"
- uses: r-lib/actions/check-r-package@v2
- name: Restore R package cache
uses: actions/cache@v2
id: r-package-cache
with:
upload-snapshots: true
path: ${{ env.R_LIBS_USER }}
key: ${{ matrix.os }}-${{ steps.setup-r.outputs.installed-r-version }}-${{ steps.get-date.outputs.year-week }}-1

- name: Install remotes
if: steps.r-package-cache.outputs.cache-hit != 'true'
run: install.packages("remotes")

- name: Install system dependencies
if: runner.os == 'Linux'
shell: bash
run: |
. /etc/os-release
while read -r cmd
do
echo "$cmd"
sudo $cmd
done < <(Rscript -e "writeLines(remotes::system_requirements('$ID-$VERSION_ID'))")
- name: Install package + deps
run: remotes::install_local(dependencies = TRUE, force = TRUE)

- name: Install greta deps
run: |
library(greta)
greta::install_greta_deps(timeout = 50)
- name: Situation Report on greta install
run: greta::greta_sitrep()

- name: Install rcmdcheck
run: remotes::install_cran("rcmdcheck")

- name: Check
run: rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'warning', check_dir = 'check')

- name: Show testthat output
if: always()
shell: bash
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true

- 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') }}
shell: bash
run: echo "C:/Program Files/Git/usr/bin" >> $GITHUB_PATH

- name: Check on single core machine
if: runner.os != 'Windows'
env:
R_PARALLELLY_AVAILABLE_CORES: 1
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran", "--no-multiarch"))

- name: Session info
run: |
options(width = 100)
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
18 changes: 18 additions & 0 deletions tests/testthat/_snaps/check-formula.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# check_if_formula works

Code
check_if_formula("potato")
Condition
Error:
! Input must be a formula
We see that `formula` has class, <character>.

---

Code
check_if_formula("y~x")
Condition
Error:
! Input must be a formula
We see that `formula` has class, <character>.

4 changes: 2 additions & 2 deletions tests/testthat/test-check-formula.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ test_that("check_if_formula works", {
error = TRUE,
check_if_formula("y~x")
)
expect_success(
expect_no_error(
check_if_formula(y~x)
)
expect_success(
expect_no_error(
check_if_formula(y~s(x))
)
})

0 comments on commit c0f1ed7

Please sign in to comment.