Skip to content

Commit 347f9e2

Browse files
committed
now check if on github actions and provide specific path
1 parent a40a1b8 commit 347f9e2

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

R/internal-helpers.R

+22-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#' database on Windows. It is used in tests and vignettes.
77
#' @noRd
88
#' @keywords internal
9-
download_tzdata_on_windows <- function() {
9+
download_tzdata_on_windows <- function(tzdir = NULL) {
1010
if (.Platform$OS.type != "windows") {
1111
cli::cli_alert_info(
1212
"Timezone database is already provided by {(.Platform)$OS.type}"
@@ -15,9 +15,13 @@ download_tzdata_on_windows <- function() {
1515
}
1616

1717
# Define paths
18-
tzdata_path <- path.expand(
19-
file.path(Sys.getenv("USERPROFILE"), "Downloads", "tzdata")
20-
)
18+
if (is.null(tzdir)) {
19+
tzdata_path <- path.expand(
20+
file.path(Sys.getenv("USERPROFILE"), "Downloads", "tzdata")
21+
)
22+
} else {
23+
tzdata_path <- tzdir
24+
}
2125
tzdata_compressed <- file.path(tzdata_path, "tzdata.tar.gz")
2226

2327
# Create directory if it doesn't exist
@@ -48,3 +52,17 @@ download_tzdata_on_windows <- function() {
4852
utils::download.file(windows_zones_url, windows_zones_path, mode = "wb")
4953
return(tzdata_path)
5054
}
55+
56+
#' wrapper for download_tzdata_on_windows for GitHub Actions
57+
#' @noRd
58+
#' @keywords internal
59+
download_tzdata_on_windows_gha <- function() {
60+
if (Sys.getenv("RUNNER_OS") == "Windows") {
61+
return(download_tzdata_on_windows("C:/Users/runneradmin/Downloads/tzdata"))
62+
} else {
63+
cli::cli_alert_info(
64+
"Not running on Windows GitHub Action"
65+
)
66+
return(NULL)
67+
}
68+
}

tests/testthat/setup.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pcreek <- system.file(
66
sf::read_sf()
77

88
# --- Setup the testing environment.
9-
windows_tz_dir <- chewie:::download_tzdata_on_windows()
9+
windows_tz_dir <- chewie:::download_tzdata_on_windows_gha()
1010
aum <- options(arrow.unsafe_metadata = TRUE)
1111
temp_dir <- tempdir()
1212
old_chewie_cache <- chewie::chewie_get_cache()

vignettes/gedi-L1B-waveforms.Rmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ knitr::opts_chunk$set(
1212
collapse = TRUE,
1313
comment = "#>"
1414
)
15-
windows_tz_dir <- chewie:::download_tzdata_on_windows()
15+
windows_tz_dir <- chewie:::download_tzdata_on_windows_gha()
1616
options(arrow.unsafe_metadata = TRUE)
1717
options("chewie.testing" = TRUE)
1818
temp_dir <- tempdir()

0 commit comments

Comments
 (0)