Skip to content

Commit

Permalink
Merge pull request #53 from wlandau/main
Browse files Browse the repository at this point in the history
use <pre> to render YAML in HTML to preserve indentation
  • Loading branch information
wlandau authored Dec 7, 2024
2 parents a1231f9 + 7ec7e95 commit 5c065f3
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 21 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: multiverse.internals
Title: Internal Infrastructure for R-multiverse
Description: R-multiverse requires this internal infrastructure package to
automate contribution reviews and populate universes.
Version: 0.3.3
Version: 0.3.4
License: MIT + file LICENSE
URL:
https://r-multiverse.org/multiverse.internals/,
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# multiverse.internals 0.3.4

* Use `<pre>` to render YAML in HTML.

# multiverse.internals 0.3.3

* Remove a superfluous text replacement in status system.
Expand Down
40 changes: 21 additions & 19 deletions R/interpret_status.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interpret_title <- function(issue, package) {
if (is.character(issue$remote_hash)) {
title <- paste(title, "remote hash", issue$remote_hash)
}
paste0(title, " since ", issue$date, ".")
paste0(title, " since ", issue$date, ".<br><br>")
}

interpret_advisories <- function(issue) {
Expand All @@ -46,8 +46,8 @@ interpret_advisories <- function(issue) {
return(character(0L))
}
paste0(
"<br><br>Found the following advisories in the ",
"R Consortium Advisory Database:<br><br>",
"Found the following advisories in the ",
"R Consortium Advisory Database:<br>",
as.character(yaml_html(advisories))
)
}
Expand All @@ -59,12 +59,12 @@ interpret_checks <- function(issue) {
}
checks$url <- sprintf("<a href=\"%s\">%s</a>", checks$url, checks$url)
paste0(
"<br><br>Not all checks succeeded on R-universe. ",
"Not all checks succeeded on R-universe. ",
"The following output shows the check status on each enforced platform ",
"and version of R. The GitHub Actions URL links to the check logs ",
"on all platforms that R-universe runs.",
"Visit that URL to see specific details ",
"on the check failures.<br><br>",
"on the check failures.<br>",
as.character(yaml_html(checks))
)
}
Expand All @@ -77,36 +77,38 @@ interpret_dependencies <- function(issue, package) {
direct <- names(dependencies)[lengths(dependencies) < 1L]
indirect <- setdiff(names(dependencies), direct)
text <- paste0(
"<br><br>One or more dependencies have issues. Packages ",
"One or more strong R package dependencies have issues: ",
paste(names(dependencies), collapse = ", "),
" are causing problems upstream. "
"."
)
if (length(direct)) {
text <- paste0(
text,
ifelse(length(direct) == 1L, "Dependency ", "Dependencies "),
ifelse(length(direct) == 1L, " Dependency ", " Dependencies "),
paste(direct, collapse = ", "),
ifelse(length(direct) == 1L, " is ", " are "),
"explicitly mentioned in 'Depends:', 'Imports:', or 'LinkingTo:' ",
"in the DESCRIPTION of ",
"in the DESCRIPTION file of ",
package,
". "
"."
)
}
if (length(indirect)) {
text <- paste0(
text,
ifelse(length(indirect) == 1L, "Package ", "Packages "),
ifelse(length(indirect) == 1L, " Dependency ", " Dependencies "),
paste(indirect, collapse = ", "),
ifelse(length(indirect) == 1L, " is ", " are "),
"not part of 'Depends:', 'Imports:', or 'LinkingTo:' ",
"in the DESCRIPTION of ",
"in the DESCRIPTION file of ",
package,
", but ",
ifelse(length(indirect) == 1L, "it is", "they are"),
" upstream of one or more direct dependencies:<br><br>",
" upstream of one or more strong direct dependencies:<br>",
as.character(yaml_html(dependencies[indirect]))
)
} else {
text <- paste0(text, "<br><br>")
}
text
}
Expand All @@ -117,7 +119,7 @@ interpret_licenses <- function(issue, package) {
return(character(0L))
}
paste(
"<br><br>Package",
"Package",
package,
"declares license",
shQuote(license),
Expand All @@ -126,7 +128,7 @@ interpret_licenses <- function(issue, package) {
"(c.f. https://en.wikipedia.org/wiki/Free_and_open-source_software).",
"Each package contributed to R-multiverse must have a valid",
"open-source license to protect the intellectual property",
"rights of the package owners."
"rights of the package owners.<br><br>"
)
}

Expand All @@ -136,7 +138,7 @@ interpret_remotes <- function(issue) {
return(character(0L))
}
paste0(
"<br><br>Package releases should not use the 'Remotes:' field. Found:",
"Package releases should not use the 'Remotes:' field. Found:<br>",
as.character(yaml_html(remotes))
)
}
Expand All @@ -147,16 +149,16 @@ interpret_versions <- function(issue) {
return(character(0L))
}
paste0(
"<br><br>The version number of the current release ",
"The version number of the current release ",
"should be highest version of all the releases so far. ",
"Here is the current version of the package, ",
"the highest version number ever recorded by R-multiverse, ",
"and the latest remote hash of each:<br><br>",
"and the latest remote hash of each:<br>",
as.character(yaml_html(versions))
)
}

yaml_html <- function(x) {
out <- yaml::as.yaml(x, line.sep = "\n")
gsub(pattern= "\n", replacement = "<br>", x = out)
out <- sprintf("<pre>%s</pre>", out)
}
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ POSIXlt
WASM
cron
FOSS
YAML
63 changes: 62 additions & 1 deletion tests/testthat/test-interpret_status.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ test_that("interpret_status() checks etc.", {
issues$tidypolars$dependencies <- list(x = "y")
expect_true(
grepl(
"One or more dependencies have issues",
"One or more strong R package dependencies have issues",
interpret_status("tidypolars", issues)
)
)
Expand Down Expand Up @@ -230,3 +230,64 @@ test_that("interpret_status() with complicated dependency problems", {
)
)
})

test_that("interpret_status(): check these interactively", {
skip_if_offline()
issues <- list(
bad = list(
checks = list(
url = "https://github.com/12103194809",
issues = list(
`linux x86_64 R-4.5.0` = "WARNING",
`mac aarch64 R-4.4.2` = "WARNING",
`mac x86_64 R-4.4.2` = "WARNING",
`win x86_64 R-4.4.2` = "WARNING"
)
),
descriptions = list(
license = "non-standard",
advisories <- c("link1", "link2", "link3"),
remotes = "markvanderloo/tinytest/pkg"
),
dependencies = list(
nanonext = "mirai",
mirai = list(),
a = list(),
b = c("x", "yasdf", "z")
),
versions = list(
version_current = "1.0.0",
hash_current = "hash_1.0.0-modified",
version_highest = "1.0.0",
hash_highest = "hash_1.0.0"
)
)
)
issues$bad2 <- issues$bad
issues$bad2$dependencies <- list(
nanonext = "mirai",
b = c("x", "yasdf", "z")
)
issues$bad3 <- issues$bad
issues$bad3$dependencies <- list(
nanonext = list(),
b = list()
)
issues$bad4 <- issues$bad
issues$bad4$dependencies <- list(
nanonext = "mirai"
)
issues$bad5 <- issues$bad
issues$bad5$dependencies <- list(
nanonext = list()
)
temp <- tempfile(fileext = ".html")
on.exit(unlink(temp))
for (package in names(issues)) {
text <- interpret_status(package, issues)
expect_true(grepl("found issues", text))
writeLines(text, temp)
# browseURL(temp) # nolint
# browser() # nolint
}
})

0 comments on commit 5c065f3

Please sign in to comment.