Skip to content

Commit ac2b5a7

Browse files
Fix CI by skipping visual tests when vdiffr is not available (#4192)
* Skip visual tests when vdiffr is not available * Add tweak to skip ggsave tests * Update CMD-ckeck.yml * Add http-user-agent * Fix a comment * Require vdiffr except when it's explicitly disabled
1 parent 6b8dba0 commit ac2b5a7

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ jobs:
2424
config:
2525
- {os: windows-latest, r: '4.0', vdiffr: true, xref: true}
2626
- {os: macOS-latest, r: '4.0', vdiffr: true, xref: true}
27-
- {os: ubuntu-16.04, r: 'devel', vdiffr: false, xref: true, cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
28-
- {os: ubuntu-16.04, r: '4.0', vdiffr: true, xref: true, cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
29-
- {os: ubuntu-16.04, r: '3.6', vdiffr: false, xref: true, cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
30-
- {os: ubuntu-16.04, r: '3.5', vdiffr: false, xref: true, cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
31-
- {os: ubuntu-16.04, r: '3.4', vdiffr: false, xref: true, cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
32-
- {os: ubuntu-16.04, r: '3.3', vdiffr: false, xref: true, cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
33-
- {os: ubuntu-16.04, r: '3.2', vdiffr: false, xref: false, cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
27+
- {os: ubuntu-16.04, r: 'devel', vdiffr: false, xref: true, 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"}
28+
- {os: ubuntu-16.04, r: '4.0', vdiffr: true, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
29+
- {os: ubuntu-16.04, r: '3.6', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
30+
- {os: ubuntu-16.04, r: '3.5', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
31+
- {os: ubuntu-16.04, r: '3.4', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
32+
- {os: ubuntu-16.04, r: '3.3', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
33+
- {os: ubuntu-16.04, r: '3.2', vdiffr: false, xref: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
3434

3535
env:
3636
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
37-
CRAN: ${{ matrix.config.cran }}
37+
RSPM: ${{ matrix.config.rspm }}
3838
# don't treat missing suggested packages as error
3939
_R_CHECK_FORCE_SUGGESTS_: false
4040
# Some packages might unavailable on the older versions, so let's ignore xref warnings
@@ -49,6 +49,7 @@ jobs:
4949
- uses: r-lib/actions/setup-r@master
5050
with:
5151
r-version: ${{ matrix.config.r }}
52+
http-user-agent: ${{ matrix.config.http-user-agent }}
5253

5354
- uses: r-lib/actions/setup-pandoc@master
5455

@@ -68,12 +69,11 @@ jobs:
6869

6970
- name: Install system dependencies on Linux
7071
if: runner.os == 'Linux'
71-
env:
72-
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
7372
run: |
74-
Rscript -e "remotes::install_github('r-hub/sysreqs')"
75-
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
76-
sudo -s eval "$sysreqs"
73+
while read -r cmd
74+
do
75+
eval sudo $cmd
76+
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "16.04"))')
7777
7878
- name: Install system dependencies on macOS
7979
if: runner.os == 'macOS'

tests/testthat/helper-vdiffr.R

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,14 @@
22
# - VDIFFR_RUN_TESTS is "false" (on Travis CI with older versions and dev version of R)
33
# - CI is not set (on CRAN)
44

5-
expect_doppelganger <- vdiffr::expect_doppelganger
5+
if (requireNamespace("vdiffr", quietly = TRUE)) {
6+
expect_doppelganger <- vdiffr::expect_doppelganger
7+
} else {
8+
# If vdiffr is not available and visual tests are not explicitly disabled, raise error.
9+
if (!identical(Sys.getenv("VDIFFR_RUN_TESTS"), "false")) {
10+
abort("vdiffr is not installed")
11+
}
12+
13+
# Otherwise, assign a dummy function
14+
expect_doppelganger <- function(...) skip("vdiffr is not installed.")
15+
}

tests/testthat/test-ggsave.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ test_that("ggsave restores previous graphics device", {
2929
})
3030

3131
test_that("ggsave uses theme background as image background", {
32+
# FIXME: This should check svglite, but, at the time of writing this, there's already a binary
33+
# package of svglite, and it can be installed even if the dependency is not available, surprisingly...
34+
skip_if_not_installed("systemfonts")
35+
3236
path <- tempfile()
3337
on.exit(unlink(path))
3438
p <- ggplot(mtcars, aes(disp, mpg)) +

0 commit comments

Comments
 (0)