style: apply air and prettier formatting repo-wide
This commit is contained in:
parent
cf851c1c30
commit
251bba8f23
1 changed files with 555 additions and 259 deletions
|
|
@ -1,15 +1,21 @@
|
|||
library(httr2, quietly = TRUE)
|
||||
|
||||
forgejo_base <- "https://git.devxy.io/api/v1"
|
||||
repo <- "devxy/build-cran-binaries"
|
||||
platform <- Sys.getenv("PLATFORM")
|
||||
arch <- Sys.getenv("ARCH")
|
||||
token <- Sys.getenv("FORGEJO_TOKEN")
|
||||
output_file <- Sys.getenv("REBUILD_PKG_LIST", "/tmp/rebuild_pkgs.txt")
|
||||
repo <- "devxy/build-cran-binaries"
|
||||
platform <- Sys.getenv("PLATFORM")
|
||||
arch <- Sys.getenv("ARCH")
|
||||
token <- Sys.getenv("FORGEJO_TOKEN")
|
||||
output_file <- Sys.getenv("REBUILD_PKG_LIST", "/tmp/rebuild_pkgs.txt")
|
||||
|
||||
if (nchar(platform) == 0) stop("PLATFORM env var is not set")
|
||||
if (nchar(arch) == 0) stop("ARCH env var is not set")
|
||||
if (nchar(token) == 0) stop("FORGEJO_TOKEN env var is not set")
|
||||
if (nchar(platform) == 0) {
|
||||
stop("PLATFORM env var is not set")
|
||||
}
|
||||
if (nchar(arch) == 0) {
|
||||
stop("ARCH env var is not set")
|
||||
}
|
||||
if (nchar(token) == 0) {
|
||||
stop("FORGEJO_TOKEN env var is not set")
|
||||
}
|
||||
|
||||
os_family <- if (grepl("^ubuntu", platform)) {
|
||||
"Ubuntu"
|
||||
|
|
@ -21,12 +27,16 @@ os_family <- if (grepl("^ubuntu", platform)) {
|
|||
platform
|
||||
}
|
||||
|
||||
issue_title <- sprintf("Missing package binaries for latest version (%s)", os_family)
|
||||
issue_title <- sprintf(
|
||||
"Missing package binaries for latest version (%s)",
|
||||
os_family
|
||||
)
|
||||
cat(sprintf("Searching for issue: %s\n", issue_title))
|
||||
|
||||
search_url <- sprintf(
|
||||
"%s/repos/%s/issues?type=issues&state=open&q=%s&limit=50",
|
||||
forgejo_base, repo,
|
||||
forgejo_base,
|
||||
repo,
|
||||
utils::URLencode(issue_title, reserved = TRUE)
|
||||
)
|
||||
search_resp <- request(search_url) |>
|
||||
|
|
@ -34,7 +44,9 @@ search_resp <- request(search_url) |>
|
|||
req_perform()
|
||||
|
||||
issues <- resp_body_json(search_resp, simplifyVector = FALSE)
|
||||
match_idx <- which(vapply(issues, function(x) x$title, character(1)) == issue_title)
|
||||
match_idx <- which(
|
||||
vapply(issues, function(x) x$title, character(1)) == issue_title
|
||||
)
|
||||
|
||||
if (length(match_idx) == 0) {
|
||||
cat("No matching issue found - nothing to rebuild\n")
|
||||
|
|
@ -55,7 +67,10 @@ lines <- strsplit(body, "\n", fixed = TRUE)[[1]]
|
|||
plat_header <- sprintf("## %s", platform)
|
||||
plat_idx <- which(lines == plat_header)
|
||||
if (length(plat_idx) == 0) {
|
||||
cat(sprintf("No section found for platform %s - nothing to rebuild\n", platform))
|
||||
cat(sprintf(
|
||||
"No section found for platform %s - nothing to rebuild\n",
|
||||
platform
|
||||
))
|
||||
writeLines(character(0), output_file)
|
||||
q("no")
|
||||
}
|
||||
|
|
@ -64,7 +79,11 @@ if (length(plat_idx) == 0) {
|
|||
arch_pattern <- sprintf("^### %s ", arch)
|
||||
arch_idx <- which(grepl(arch_pattern, lines) & seq_along(lines) > plat_idx[1])
|
||||
if (length(arch_idx) == 0) {
|
||||
cat(sprintf("No section found for arch %s under %s - nothing to rebuild\n", arch, platform))
|
||||
cat(sprintf(
|
||||
"No section found for arch %s under %s - nothing to rebuild\n",
|
||||
arch,
|
||||
platform
|
||||
))
|
||||
writeLines(character(0), output_file)
|
||||
q("no")
|
||||
}
|
||||
|
|
@ -82,6 +101,11 @@ pkg_lines <- section_lines[grepl("^- ", section_lines)]
|
|||
pkgs <- sub("^- ([^ ]+) \\(.*\\)$", "\\1", pkg_lines)
|
||||
pkgs <- pkgs[nchar(pkgs) > 0 & pkgs != "_None_"]
|
||||
|
||||
cat(sprintf("Found %d rebuildable packages for %s/%s\n", length(pkgs), platform, arch))
|
||||
cat(sprintf(
|
||||
"Found %d rebuildable packages for %s/%s\n",
|
||||
length(pkgs),
|
||||
platform,
|
||||
arch
|
||||
))
|
||||
writeLines(pkgs, output_file)
|
||||
cat(sprintf("Wrote package list to %s\n", output_file))
|
||||
|
|
|
|||
Loading…
Reference in a new issue