-
Notifications
You must be signed in to change notification settings - Fork 3
145 lines (113 loc) · 4.42 KB
/
test-ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
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