-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscrape-checks.R
48 lines (36 loc) · 2.02 KB
/
scrape-checks.R
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
check_url <- "https://cran.r-project.org/web/checks/check_summary_by_package.html"
check_results <- rvest::read_html(check_url) |>
rvest::html_node("table") |>
rvest::html_table()
# create a look up table to map the scraped flavor names to the flavor values
flavor_names <- c("r-devel-linux-x86_64-debian-clang", "r-devel-linux-x86_64-debian-gcc", "r-devel-linux-x86_64-fedora-clang", "r-devel-linux-x86_64-fedora-gcc", "r-devel-windows-x86_64", "r-patched-linux-x86_64", "r-release-linux-x86_64", "r-release-macos-arm64", "r-release-macos-x86_64", "r-release-windows-x86_64", "r-oldrel-macos-arm64", "r-oldrel-macos-x86_64", "r-oldrel-windows-x86_64")
check_names <- c("r-develLinuxx86_64(Debian Clang)", "r-develLinuxx86_64(Debian GCC)", "r-develLinuxx86_64(Fedora Clang)", "r-develLinuxx86_64(Fedora GCC)", "r-develWindowsx86_64", "r-patchedLinuxx86_64", "r-releaseLinuxx86_64", "r-releasemacOSarm64", "r-releasemacOSx86_64", "r-releaseWindowsx86_64", "r-oldrelmacOSarm64", "r-oldrelmacOSx86_64", "r-oldrelWindowsx86_64")
# create lookup vector
flavor_lu <- setNames(flavor_names, check_names)
# tidy up the results
cli::cli_alert_info("Tidying results")
check_long <- check_results |>
tidyr::pivot_longer(
cols = -c("Package", "Version", "Priority", "Maintainer"),
names_to = "check_env",
values_to = "check_status"
) |>
dplyr::mutate(flavor = flavor_lu[check_env]) |>
dplyr::select(-check_env) |>
dplyr::rename_with(heck::to_snek_case) |>
dplyr::select(package, version, maintainer, flavor, check_status, priority) |>
tidyr::nest(results = -c("package", "maintainer", "priority"))
# split by row
splits <- split(check_long, check_long$package)
# convert each row to json
cli::cli_inform("Converting checks to json")
pkg_check_status <- lapply(
splits,
\(.x) jsonify::to_json(unclass(.x), unbox = TRUE)
)
# write the results to json
for (pkg in names(pkg_check_status)) {
fp <- file.path("docs", paste0(pkg, ".json"))
cli::cli_inform(c("*" = "writing {.file {fp}}"))
writeLines(pkg_check_status[[pkg]], fp)
}