Skip to content

Commit

Permalink
try fixing CMD check
Browse files Browse the repository at this point in the history
  • Loading branch information
FBartos committed May 23, 2024
1 parent 3d8454b commit c27190d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 45 deletions.
71 changes: 39 additions & 32 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,60 +16,68 @@ name: R-CMD-check

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

name: ${{ matrix.config.os }} (${{ matrix.config.r }})
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} (R ${{ matrix.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-latest, r: 'release'}
r: ['4.3.3']
os: [ubuntu-latest, macOS-latest, windows-latest]

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
R_REMOTES_UPGRADE: never
VDIFFR_RUN_TESTS: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
_R_CHECK_LENGTH_1_CONDITION_: TRUE #deprecated from R 4.2.0
_R_CHECK_MATRIX_DATA_: TRUE # only works from R 4.2.0 onwards

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

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}

- uses: r-lib/actions/setup-pandoc@v2
r-version: ${{ matrix.r }}

- name: Query dependencies
- name: Install system dependencies on macOS
if: runner.os == 'macOS'
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: Restore R package cache
uses: actions/cache@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
# see https://github.com/orgs/Homebrew/discussions/4612
unset HOMEBREW_NO_INSTALL_FROM_API
brew update
brew install --cask xquartz
brew install libarchive
shell: bash

- name: Install system dependencies on macOS specific to R devel
if: runner.os == 'macOS' && matrix.r == 'devel'
run: |
# ragg requires harfbuzz fribidi
# The dependencies of the two R packages below are required for compiling from source on Ubuntu, but macOS seems fine without them
# credentials (dependency of usethis) requires libgit2
# curl (dependency of usethis) requires openssl
brew install harfbuzz fribidi libgit2 openssl curl
shell: bash

- name: Install system dependencies on linux
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
sudo apt-get install libcurl4-openssl-dev
# ragg requires libharfbuzz-dev libfribidi-dev
# credentials (dependency of usethis) requires libgit2-dev
# curl (dependency of usethis) requires libcurl4-openssl-dev
# libicu (dependency of igraph or stringi...) requires libicu libicu-dev
sudo apt install libharfbuzz-dev libfribidi-dev libgit2-dev libcurl4-openssl-dev libicu*
shell: bash

- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: Check
if: runner.os != 'Windows'
env:
Expand All @@ -96,7 +104,6 @@ jobs:
check_dir = "check")
shell: Rscript {0}


- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
Expand Down
26 changes: 13 additions & 13 deletions tests/testthat/test-zcurve.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ test_that("z-curve EM can be fitted and reproduces OSC results", {
))

# plot
expect_doppelganger("z-curve EM", function()plot(fit.EM, main = "OSC (with EM)", annotation = TRUE, CI = TRUE))
expect_doppelganger("z-curve EM (ggplot)", suppressWarnings(plot(fit.EM, main = "OSC (with EM)", annotation = TRUE, CI = TRUE, plot_type = "ggplot")))
vdiffr::expect_doppelganger("z-curve EM", function()plot(fit.EM, main = "OSC (with EM)", annotation = TRUE, CI = TRUE))
vdiffr::expect_doppelganger("z-curve EM (ggplot)", suppressWarnings(plot(fit.EM, main = "OSC (with EM)", annotation = TRUE, CI = TRUE, plot_type = "ggplot")))

})
test_that("z-curve KD2 can be fitted and reproduces OSC results", {
Expand Down Expand Up @@ -100,8 +100,8 @@ test_that("z-curve KD2 can be fitted and reproduces OSC results", {
))

# plot
expect_doppelganger("z-curve KD2", function()plot(fit.KD2))
expect_doppelganger("z-curve KD2 (ggplot)", plot(fit.KD2, plot_type = "ggplot"))
vdiffr::expect_doppelganger("z-curve KD2", function()plot(fit.KD2))
vdiffr::expect_doppelganger("z-curve KD2 (ggplot)", plot(fit.KD2, plot_type = "ggplot"))

})
test_that("z-curve EM censoring works", {
Expand Down Expand Up @@ -132,8 +132,8 @@ test_that("z-curve EM censoring works", {
))

# plot
expect_doppelganger("z-curve mixed EM", function()plot(fit.mixed, CI = TRUE))
expect_doppelganger("z-curve mixed EM (ggplot)", plot(fit.mixed, CI = TRUE, plot_type = "ggplot"))
vdiffr::expect_doppelganger("z-curve mixed EM", function()plot(fit.mixed, CI = TRUE))
vdiffr::expect_doppelganger("z-curve mixed EM (ggplot)", plot(fit.mixed, CI = TRUE, plot_type = "ggplot"))


# censoring only
Expand All @@ -157,8 +157,8 @@ test_that("z-curve EM censoring works", {
))

# plot
expect_doppelganger("z-curve cens EM", function()plot(fit.cens, CI = TRUE))
expect_doppelganger("z-curve cens EM (ggplot)", plot(fit.cens, CI = TRUE, plot_type = "ggplot"))
vdiffr::expect_doppelganger("z-curve cens EM", function()plot(fit.cens, CI = TRUE))
vdiffr::expect_doppelganger("z-curve cens EM (ggplot)", plot(fit.cens, CI = TRUE, plot_type = "ggplot"))
})
test_that("z-curve clustered works", {

Expand Down Expand Up @@ -204,7 +204,7 @@ test_that("z-curve clustered works", {
"Q = -238.11, 95% CI[-269.95, -219.12]"
))

expect_doppelganger("z-curve clustered rounded", function(){
vdiffr::expect_doppelganger("z-curve clustered rounded", function(){
oldpar <- graphics::par(no.readonly = TRUE)
on.exit(graphics::par(mfrow = oldpar[["mfrow"]]))
par(mfrow = c(1, 2))
Expand Down Expand Up @@ -251,7 +251,7 @@ test_that("z-curve clustered works", {
"Q = -201.69, 95% CI[-219.18, -185.82]"
))

expect_doppelganger("z-curve clustered precise", function(){
vdiffr::expect_doppelganger("z-curve clustered precise", function(){
oldpar <- graphics::par(no.readonly = TRUE)
on.exit(graphics::par(mfrow = oldpar[["mfrow"]]))
par(mfrow = c(1, 2))
Expand Down Expand Up @@ -298,14 +298,14 @@ test_that("z-curve clustered works", {
"Q = -321.39, 95% CI[-361.78, -298.20]"
))

expect_doppelganger("z-curve clustered mixed", function(){
vdiffr::expect_doppelganger("z-curve clustered mixed", function(){
oldpar <- graphics::par(no.readonly = TRUE)
on.exit(graphics::par(mfrow = oldpar[["mfrow"]]))
par(mfrow = c(1, 2))
plot(fitb)
plot(fitw)
})

expect_doppelganger("z-curve clustered mixed (ggplot-1)", plot(fitb, plot_type = "ggplot"))
expect_doppelganger("z-curve clustered mixed (ggplot-2)", plot(fitw, plot_type = "ggplot"))
vdiffr::expect_doppelganger("z-curve clustered mixed (ggplot-1)", plot(fitb, plot_type = "ggplot"))
vdiffr::expect_doppelganger("z-curve clustered mixed (ggplot-2)", plot(fitw, plot_type = "ggplot"))
})

0 comments on commit c27190d

Please sign in to comment.