Skip to content

Commit

Permalink
[CI] Reduce building images (supporting R versions) (#624)
Browse files Browse the repository at this point in the history
Resolve #614

Reduce the number of images to be built according to the following new
standard:

- All patch versions associated with the last 2 minor versions (release
and oldrel)
- All minor versions R >= 4.0
  • Loading branch information
eitsupi authored Apr 2, 2023
2 parents f650245 + 806be3c commit 3e683e8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

### Changes in pre-built images

- New standards for R versions of images for routine builds. ([#624](https://github.com/rocker-org/rocker-versioned2/pull/624))
- All patch versions associated with the last 2 minor versions (release and oldrel)
- All minor versions R >= 4.0
- `rocker/binder`'s default command is changed from `jupyter notebook` to `jupyter lab`.
([#628](https://github.com/rocker-org/rocker-versioned2/pull/628))

Expand Down
30 changes: 23 additions & 7 deletions build/make-matrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,36 @@ library(tidyselect)
df_args <- fs::dir_ls(path = "bakefiles", regexp = "/\\d+\\.\\d+\\.\\d+\\.docker-bake.json$") |>
tibble::as_tibble() |>
dplyr::rowwise() |>
dplyr::summarise(
dplyr::reframe(
r_version = stringr::str_extract(value, "\\d+\\.\\d+\\.\\d+"),
group = unlist(purrr::map(value, .get_group_names)),
r_major_minor_version = readr::parse_number(r_version),
r_patch_version = as.integer(stringr::str_extract(r_version, "\\d+$")),
.groups = "drop"
group = unlist(purrr::map(value, .get_group_names))
) |>
dplyr::arrange(r_major_minor_version, r_patch_version) |>
dplyr::select(!tidyselect::matches("r_.+_version"))
dplyr::arrange(R_system_version(r_version))

supported_versions <- df_args |>
dplyr::select(r_version) |>
dplyr::distinct() |>
dplyr::mutate(
sys_ver = R_system_version(r_version),
major = sys_ver$major,
minor = sys_ver$minor,
patch = sys_ver$patch
) |>
dplyr::mutate(
supported = (patch == dplyr::last(patch)),
.by = c(major, minor)
) |>
dplyr::mutate(
major_minor = numeric_version(paste0(major, ".", minor)),
supported = supported | (major_minor >= nth(unique(major_minor), -2))
) |>
dplyr::filter(supported) |>
dplyr::pull(r_version)

message("\nstart writing matrix files.")

df_args |>
dplyr::filter(r_version %in% supported_versions) |>
.write_matrix("build/matrix/all.json")

df_args |>
Expand Down
2 changes: 1 addition & 1 deletion build/matrix/all.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"r_version": ["4.0.0", "4.0.1", "4.0.2", "4.0.3", "4.0.4", "4.0.5", "4.1.0", "4.1.1", "4.1.2", "4.1.3", "4.2.0", "4.2.1", "4.2.2", "4.2.3"],
"r_version": ["4.0.5", "4.1.0", "4.1.1", "4.1.2", "4.1.3", "4.2.0", "4.2.1", "4.2.2", "4.2.3"],
"group": ["default"],
"include": [
{
Expand Down

0 comments on commit 3e683e8

Please sign in to comment.