Skip to content

Commit

Permalink
fix version parsing of 'release' in action output
Browse files Browse the repository at this point in the history
  • Loading branch information
vandenman committed Jun 28, 2024
1 parent 0d27f0b commit e215108
Show file tree
Hide file tree
Showing 5 changed files with 1,453 additions and 151 deletions.
45 changes: 41 additions & 4 deletions R/github_actions_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ get_jasp_repos <- function() {
repos <- setdiff(repos, c("jaspTools", "jaspColumnEncoder", "jaspResults", "jaspCommon",
"jaspPredictiveAnalytics", "jaspQMLComponents",
"jaspBase", "jaspGraphs", "jaspTestModule", "jaspModuleTemplate",
"jaspCommonLib", "jaspModuleInstaller", "jaspQMLControlsPlugin"))
"jaspCommonLib", "jaspModuleInstaller", "jaspQMLControlsPlugin", "jaspIrtStanModels"))

# sort: first the common modules, then the rest alphabetically
common_modules <- c("jaspDescriptives", "jaspTTests", "jaspAnova", "jaspMixedModels", "jaspRegression", "jaspFrequencies", "jaspFactor")
Expand Down Expand Up @@ -141,11 +141,48 @@ get_action_data_as_tib <- function(repos, force = FALSE, enable_cache = identica
rversions <- unique(gsub("unit-tests / (.*)-latest \\(R (.*)\\)", "\\2", tib_results$name))
oses <- c("windows", "macOS", "ubuntu")

all_combinations <- expand.grid(oses, sort(package_version(rversions), decreasing = TRUE))
# rversions can have nonnumeric-values, e.g.,
non_numeric_versions <- grep(x = rversions, pattern = "^[[:digit:]]+", invert = TRUE)
if (length(non_numeric_versions) > 0) {

resolved_versions <- vapply(non_numeric_versions, \(v) {
tryCatch({
# this is based on the API of r-hub, see https://github.com/r-lib/actions/blob/fbafc3bc4ba114e72680c71e835c59b022606c46/setup-r/src/installer.ts#L750
jsonlite::fromJSON(paste0("https://api.r-hub.io/rversions/resolve/", rversions[v], "/windows"))[["version"]]
}, error = function(e) "failed to resolve")
}, FUN.VALUE = character(1L))

}

rversions2 <- rversions
rversions2[non_numeric_versions] <- resolved_versions
rversions_order <- order(package_version(rversions2), decreasing = TRUE)

# if we want to show "R-release (4.4.1)
# rversions3 <- rversions
# rversions3[non_numeric_versions] <- paste0(rversions[non_numeric_versions], " (", resolved_versions, ")")

all_combinations <- expand.grid(oses, rversions2[rversions_order])

level_order <- paste0(all_combinations[[1]], " R-", as.character(all_combinations[[2]]))

level_order <- intersect(level_order, tib_results$name_clean)
tib_results$name_clean <- factor(tib_results$name_clean, levels = rev(level_order))
if (length(non_numeric_versions) > 0) {

name_clean <- tib_results$name_clean
for (idx in non_numeric_versions) {
idx2 <- endsWith(name_clean, rversions[idx])
name_clean[idx2] <- gsub(paste0(rversions[idx], "$"), rversions2[idx], name_clean[idx2])
}

level_order <- intersect(level_order, name_clean)
tib_results$name_clean <- factor(name_clean, levels = rev(level_order))
} else {

level_order <- intersect(level_order, tib_results$name_clean)
tib_results$name_clean <- factor(tib_results$name_clean, levels = rev(level_order))

}


return(tib_results)

Expand Down
4 changes: 3 additions & 1 deletion inst/runningFile.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ htmltools::save_html(htmltools::tagList(
htmltools::div(p_collapsed_runs),
htmltools::div(p_individual_runs)
), file = f)
system2("xdg-open", f)

if (interactive())
system2("xdg-open", f)

gh::gh_rate_limit()

Loading

0 comments on commit e215108

Please sign in to comment.