-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathhpc-carpentry_lessons.R
76 lines (64 loc) · 1.71 KB
/
hpc-carpentry_lessons.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
source("R/utils.R")
LIFE_CYCLE_TAGS <- c("pre-alpha", "alpha", "beta", "stable")
# The tags below will be filtered out in the json
COMMON_TAGS <- c(
"carpentries",
"carpentries-incubator",
"carpentries-lesson",
"carpentryconnect",
"data-carpentry",
"datacarpentry",
"education",
"lesson"
)
check_missing_repo_info <- function(.d, field) {
if (any(!nzchar(.d[[field]]))) {
paste0(
"Missing repo ", sQuote(field), " for: \n",
paste0(" - ", .d$repo_url[!nzchar(.d[[field]])], collapse = "\n"),
"\n"
)
}
}
check_repo_info <- function(.d, fields) {
tryCatch({
out <- purrr::map(
fields, ~ check_missing_repo_info(.d, .)
)
msgs <- purrr::keep(out, ~ !is.null(.))
if (length(msgs)) {
stop(msgs, call. = FALSE)
}
cli::cli_alert_success("No issues detected!")
},
error = function(err) {
stop(err$message, call. = FALSE)
})
}
make_community_lessons_feed <- function(path, ...) {
carp_inc <- get_org_topics("carpentries-incubator")
hpc_carp <- get_org_topics("hpc-carpentry")
res <- dplyr::bind_rows(carp_inc, hpc_carp) %>%
dplyr::select(-private) %>%
dplyr::filter(grepl("hpc-carpentry", github_topics)) %>%
dplyr::filter(grepl("lesson", github_topics)) %>%
extract_tag(
life_cycle_tag,
LIFE_CYCLE_TAGS,
approach = "include",
allow_multiple = FALSE,
allow_empty = FALSE
) %>%
extract_tag(
lesson_tags,
COMMON_TAGS,
approach = "exclude",
allow_multiple = TRUE,
allow_empty = TRUE
)
## checks
check_repo_info(res, c("description", "rendered_site"))
res %>%
jsonlite::write_json(path = path)
}
make_community_lessons_feed("_data/hpc_lessons.json")