Skip to content

Commit

Permalink
Generated matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Jun 26, 2024
1 parent eae04db commit fb9b04c
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
54 changes: 53 additions & 1 deletion .github/workflows/versions-matrix/action.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,56 @@
json <- '{"include":[{"os": "macos-latest", "r": "release"}, {"os": "ubuntu-20.04", "r": "release"}, {"os": "ubuntu-22.04", "r": "devel", "http-user-agent": "release"}]}'
# - {os: macos-latest, r: 'release'}
#
# - {os: ubuntu-20.04, r: 'release'}
#
# # Use older ubuntu to maximise backward compatibility
# - {os: ubuntu-22.04, r: 'devel', http-user-agent: 'release'}
# - {os: ubuntu-22.04, r: 'release', covr: true, desc: 'with covr'}
# - {os: ubuntu-22.04, r: 'oldrel-1'}
#
# # Begin custom: R 3.6
# - {os: ubuntu-22.04, r: 'oldrel-2'}
# # End custom: R 3.6
#
# # Begin custom: R 3.5
# - {os: ubuntu-22.04, r: 'oldrel-3'}
# # End custom: R 3.5
#
# # Begin custom: R 3.4
# - {os: ubuntu-22.04, r: 'oldrel-4'}
# # End custom: R 3.4

# FIXME: Dynamic lookup by parsing https://svn.r-project.org/R/tags/
r_versions <- c("devel", paste0("4.", 4:0))
macos <- data.frame(os = "macos-latest", r = r_versions[2:3])
windows <- data.frame(os = "windows-latest", r = r_versions[1:3])
linux_devel <- data.frame(os = "ubuntu-22.04", r = r_versions[1], `http-user-agent` = "release", check.names = FALSE)
linux <- data.frame(os = "ubuntu-22.04", r = r_versions[-1])
covr <- data.frame(os = "ubuntu-22.04", r = r_versions[2], covr = "true", desc = "with covr")

include_list <- list(macos, windows, linux_devel, linux, covr)
print(include_list)

filter <- read.dcf("DESCRIPTION")[1,]["Config/gha/filter"]
if (!is.na(filter)) {
filter_expr <- parse(text = filter)[[1]]
subset_fun_expr <- bquote(function(x) subset(x, .(filter_expr)))
subset_fun <- eval(subset_fun_expr)
include_list <- lapply(include_list, subset_fun)
print(include_list)
}

to_json <- function(x) {
if (nrow(x) == 0) return(character())
parallel <- vector("list", length(x))
for (i in seq_along(x)) {
parallel[[i]] <- paste0('"', names(x)[[i]], '":"', x[[i]], '"')
}
paste0("{", do.call(paste, c(parallel, sep = ",")), "}")
}

configs <- unlist(lapply(include_list, to_json))
json <- paste0('{"include":[', paste(configs, collapse = ","), ']}')

if (Sys.getenv("GITHUB_OUTPUT") != "") {
writeLines(paste0("matrix=", json), Sys.getenv("GITHUB_OUTPUT"))
}
Expand Down
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
Config/gha/filter: os != "windows-latest"

0 comments on commit fb9b04c

Please sign in to comment.