Skip to content

Test on GHA

Test on GHA #475

Workflow file for this run

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@v4
- 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: |
options(repos = c(CRAN = "https://cloud.r-project.org"))
library(magrittr)
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 <- jsonlite::read_json("https://ropensci.r-universe.dev/api/packages") %>%
lapply("[[", "Package") %>%
unlist()
ropenscireviewtools <- jsonlite::read_json("https://ropenscireviewtools.r-universe.dev/api/packages") %>%
lapply("[[", "Package") %>%
unlist()
# R-lib packages
rlib <- jsonlite::read_json("https://r-lib.r-universe.dev/api/packages") %>%
lapply("[[", "Package") %>%
unlist()
# R-forge packages
rforge <- jsonlite::read_json("https://r-forge.r-universe.dev/api/packages") %>%
lapply("[[", "Package") %>%
unlist()
# R-Studio packages
rstudio <- jsonlite::read_json("https://rstudio.r-universe.dev/api/packages") %>%
lapply("[[", "Package") %>%
unlist()
# rspatial packages
rspatial <- jsonlite::read_json("https://r-spatial.r-universe.dev/api/packages") %>%
lapply("[[", "Package") %>%
unlist()
# My universes packages
dieghernan <- jsonlite::read_json("https://dieghernan.r-universe.dev/api/packages") %>%
lapply("[[", "Package") %>%
unlist()
ropenspain <- jsonlite::read_json("https://ropenspain.r-universe.dev/api/packages") %>%
lapply("[[", "Package") %>%
unlist()
ropengov <- jsonlite::read_json("https://ropengov.r-universe.dev/api/packages") %>%
lapply("[[", "Package") %>%
unlist()
# 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_init <- setdiff(all, instpack)
# Install
options(repos = c(
ropensci = "https://ropensci.r-universe.dev",
ropenscireviewtools = "https://ropensci-review-tools.r-universe.dev",
RSPM = "https://packagemanager.posit.co/cran/latest",
CRAN = "https://cloud.r-project.org"
))
# Check packages available
pakav <- as.data.frame(available.packages(repos = getOption("repos")))
toinstall <- toinstall_init[toinstall_init %in% pakav$Package]
message("Installing ", length(toinstall), " packages")
install.packages(toinstall)
shell: Rscript {0}
- name: Test GHA
run: |
# Run the tests
source("tests/testthat/test_ci/test-new.R")
shell: Rscript {0}
# Report on success
- name: Report success
shell: bash
run: |
# OK :)
cat ./tests/testthat/test_ci/results.md >$GITHUB_STEP_SUMMARY