Skip to content

Commit 541e14b

Browse files
committed
WIP
1 parent 139ae46 commit 541e14b

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

run.R

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,27 @@ authenticate <- function(url) {
113113
get_packit_token_service(url, github_token)
114114
}
115115

116+
run <- function(url, token, ref_name, sha, entry) {
117+
if (!is.na(Sys.getenv("CI", NA))) {
118+
cli::cli_text("::group::Running {entry$name}")
119+
withr::defer(cli::cli_text("::endgroup::"))
120+
}
121+
cli::cli_rule("Running {entry$name}")
122+
123+
task_id <- task_run(url, token, ref_name, sha, entry$name)
124+
task_wait(url, token, task_id)
125+
status <- task_status(url, token, task_id, include_logs = TRUE)
126+
127+
cli::cli_verbatim(unlist(status$logs))
128+
129+
if (status$status != "COMPLETE") {
130+
cli::cli_abort("Task failed")
131+
} else {
132+
cli::cli_alert_success("Report ran successfully and produced packet {.href {status$packetId}")
133+
cli::cli_alert_info("Packit is available at {.url {packet_url}}")
134+
}
135+
}
136+
116137
main <- function(args = commandArgs(trailingOnly = TRUE)) {
117138
url <- args[[1]]
118139
input <- args[[2]]
@@ -124,14 +145,7 @@ main <- function(args = commandArgs(trailingOnly = TRUE)) {
124145
data <- yaml::read_yaml(file = input)
125146

126147
for (entry in data) {
127-
task_id <- task_run(url, token, ref_name, sha, entry$name)
128-
task_wait(url, token, task_id)
129-
status <- task_status(url, token, task_id, include_logs = TRUE)
130-
writeLines(unlist(status$logs))
131-
132-
if (status$status != "COMPLETE") {
133-
cli::cli_abort("Task failed")
134-
}
148+
run(url, token, ref_name, sha, entry)
135149
}
136150
}
137151

0 commit comments

Comments
 (0)