Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug CI failures #441

Merged
merged 8 commits into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
^vignettes/articles$
^LICENSE\.md$
^blog$
^_pkgdown\.yml$
4 changes: 2 additions & 2 deletions R/board_datatxt.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ datatxt_refresh_index <- function(board) {
}

fs::dir_create(fs::path_dir(local_index))
yaml::write_yaml(current_index, local_index)
write_yaml(current_index, local_index)
}


Expand Down Expand Up @@ -527,7 +527,7 @@ board_manifest_load <- function(manifest) {
}

board_manifest_create <- function(index, file) {
yaml::write_yaml(index, file)
write_yaml(index, file)
}

pin_entries_to_dataframe <- function(entries) {
Expand Down
2 changes: 1 addition & 1 deletion R/board_github.R
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ board_pin_create.pins_board_github <- function(board, path, name, metadata, ...)

names(datatxt$filenames) <- datatxt$path

yaml::write_yaml(datatxt, file_path)
write_yaml(datatxt, file_path)
}

# create upload definition of remote-path/local-path
Expand Down
5 changes: 4 additions & 1 deletion R/board_local.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ board_browse.pins_board_local <- function(board, ...) {

#' @export
pin_list.pins_board_local <- function(board, ...) {
fs::path_file(fs::dir_ls(board$path, type = "directory"))
dir <- fs::dir_ls(board$path, type = "directory")
metadata <- fs::path(dir, "data.txt")

fs::path_file(dir[fs::file_exists(metadata)])
}

#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/board_rsconnect.R
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ read_cache <- function(path) {
update_cache <- function(path, key, value) {
cache <- read_cache(path)
cache[[key]] <- value
yaml::write_yaml(cache, path)
write_yaml(cache, path)

value
}
Expand Down
2 changes: 1 addition & 1 deletion R/board_rsconnect_bundle.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ rsc_bundle <- function(board, name, path, metadata, x = NULL, bundle_path = temp
fs::file_copy(path, fs::path(bundle_path, fs::path_file(path)))

# * data.txt (used to retrieve pins)
yaml::write_yaml(metadata, fs::path(bundle_path, "data.txt"))
write_yaml(metadata, fs::path(bundle_path, "data.txt"))

# * index.html
rsc_bundle_preview_create(board, name, metadata, path = bundle_path, x = x)
Expand Down
2 changes: 1 addition & 1 deletion R/meta.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ read_meta <- function(path) {

write_meta <- function(x, path) {
path <- fs::path(path, "data.txt")
yaml::write_yaml(x, path)
write_yaml(x, path)
}

# pin metadata ------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions R/pin_manifest.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pin_manifest_get <- function(path) {
pin_manifest_update <- function(path, manifest) {
data_txt <- file.path(path, "data.txt")

manifest <- yaml::write_yaml(manifest, data_txt)
manifest <- write_yaml(manifest, data_txt)

manifest
}
Expand All @@ -33,7 +33,7 @@ pin_manifest_create <- function(path, metadata, files) {
entries[sapply(entries, is.null)] <- NULL

fs::dir_create(path)
yaml::write_yaml(entries, file.path(path, "data.txt"))
write_yaml(entries, file.path(path, "data.txt"))
}

# retrieve a list of files to download
Expand Down
2 changes: 1 addition & 1 deletion R/pin_registry.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pin_registry_read <- function(board) {
pin_registry_write <- function(board, entries) {
stopifnot(is.board(board))

yaml::write_yaml(unname(entries), pin_registry_path(board, "data.txt"))
write_yaml(unname(entries), pin_registry_path(board, "data.txt"))
}

# Lock registry file to prevent multi-process race conditions
Expand Down
20 changes: 20 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,23 @@ ui_loud <- function() {
}

github_raw <- function(x) paste0("https://raw.githubusercontent.com/", x)

write_yaml <- function(x, path) {
x <- to_utf8(x)
yaml::write_yaml(x, path)
}

# On Windows, yaml::write_yaml() crashes with Latin1 data
# https://github.com/viking/r-yaml/issues/90
to_utf8 <- function(x) {
if (is.list(x)) {
if (!is.null(names(x))) {
names(x) <- enc2utf8(names(x))
}
lapply(x, to_utf8)
} else if (is.character(x)) {
enc2utf8(x)
} else {
x
}
}
13 changes: 13 additions & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
test_that("write_yaml can write non-UTF8 data", {
str <- "fa\xE7ile"
Encoding(str) <- "latin1"

x <- list(str)
names(x) <- str

path <- tempfile()
write_yaml(x, path)

y <- yaml::read_yaml(path)
expect_equal(y, list("fa\u00e7ile" = "fa\u00e7ile"))
})