Test on GHA #331
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 5 * * 2,5' | |
name: Test on GHA | |
jobs: | |
test-ci: | |
runs-on: ${{ matrix.config.os }} | |
name: ${{ matrix.config.os }} (${{ matrix.config.r }}) | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- {os: windows-latest, r: 'release'} | |
- {os: macOS-latest, r: 'release'} | |
#- {os: ubuntu-latest, r: 'release'} | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: r-lib/actions/setup-pandoc@v2 | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
use-public-rspm: true | |
install-r: true | |
- uses: r-lib/actions/setup-r-dependencies@v2 | |
with: | |
cache-version: 'gha' | |
extra-packages: | | |
local::. | |
any::devtools | |
any::remotes | |
any::tidymodels | |
any::tidyverse | |
any::ctv | |
- name: Install packages | |
run: | | |
# Install core packages of all views | |
options(repos = c( | |
CRAN = "https://cloud.r-project.org" | |
)) | |
allviews <- ctv::available.views() | |
packs <- lapply(seq_len(length(allviews)), function(x) { | |
df <- allviews[[x]]$packagelist | |
tibble::add_column(df, view = allviews[[x]]$name) | |
}) | |
packs <- dplyr::bind_rows(packs) | |
core <- dplyr::filter(packs, core == TRUE) | |
# Selected views with several packages | |
sel_views <- packs[packs$view %in% c("TimeSeries", "Distributions"), ] | |
# rOpenSci packages from r-universe | |
ropensci <- unlist(jsonlite::read_json("https://ropensci.r-universe.dev/packages")) | |
ropenscireviewtools <- unlist( | |
jsonlite::read_json("https://ropenscireviewtools.r-universe.dev/packages") | |
) | |
# R-lib packages | |
rlib <- unlist(jsonlite::read_json("https://r-lib.r-universe.dev/packages")) | |
# R-forge packages | |
rforge <- unlist(jsonlite::read_json("https://r-forge.r-universe.dev/packages")) | |
# R-Studio packages | |
rstudio <- unlist(jsonlite::read_json("https://rstudio.r-universe.dev/packages")) | |
# rspatial packages | |
rspatial <- unlist(jsonlite::read_json("https://r-spatial.r-universe.dev/packages")) | |
# My universes packages | |
dieghernan <- unlist(jsonlite::read_json("https://dieghernan.r-universe.dev/packages")) | |
ropenspain <- unlist(jsonlite::read_json("https://ropenspain.r-universe.dev/packages")) | |
ropengov <- unlist(jsonlite::read_json("https://ropengov.r-universe.dev/packages")) | |
# Gather packages | |
all <- sort(unique(c( | |
core$name, sel_views$name, ropensci, ropenscireviewtools, rlib, rforge, rstudio, rspatial, | |
dieghernan, ropenspain, ropengov | |
))) | |
# Check packages not installed yet | |
instpack <- as.character(installed.packages()[, "Package"]) | |
toinstall <- setdiff(all, instpack) | |
# Install | |
options(repos = c( | |
ropensci = "https://ropensci.r-universe.dev", | |
ropenscireviewtools = "https://ropensci-review-tools.r-universe.dev", | |
RSPM = "https://packagemanager.rstudio.com/all/latest", | |
CRAN = "https://cloud.r-project.org" | |
)) | |
message("Installing ", length(toinstall)," packages: ", paste0(toinstall, collapse = ",")) | |
install.packages(toinstall, | |
dependencies = TRUE, | |
verbose = TRUE, quiet = TRUE | |
) | |
# Update binary | |
# update.packages(type = "binary") | |
shell: Rscript {0} | |
- name: Test GHA | |
run: | | |
# Load package | |
devtools::load_all() | |
# Run the tests | |
testthat::test_dir("tests/testthat/test_ci") | |
shell: Rscript {0} | |
# Report on success | |
- name: Report success | |
shell: bash | |
run: | | |
# OK :) | |
cat ./tests/testthat/test_ci/_snaps/full_cff.md >$GITHUB_STEP_SUMMARY | |