Skip to content

Commit 0b364c9

Browse files
committed
Mock download function for v1 metadata in GitHub Actions to bypass IP blocking
1 parent 475274c commit 0b364c9

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

tools/generate_data_availability_plot.R

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@ cat("Output path:", output_path, "\n")
2929

3030
# --- Fetch available data ---
3131
cat("Fetching v1 (2020-2021) metadata...\n")
32+
33+
# In GitHub Actions, MITMS blocks the IP, causing the XML download to fail.
34+
# We mock the download function to fetch from the Internet Archive instead.
35+
if (Sys.getenv("GITHUB_ACTIONS") == "true") {
36+
orig_fn <- spanishoddata:::spod_get_latest_v1_file_list
37+
assignInNamespace(
38+
"spod_get_latest_v1_file_list",
39+
function(data_dir = spanishoddata:::spod_get_data_dir(), xml_url = "https://opendata-movilidad.mitma.es/RSS.xml", quiet = FALSE) {
40+
orig_fn(data_dir, "https://web.archive.org/web/20240703091554id_/https://opendata-movilidad.mitma.es/RSS.xml", quiet)
41+
},
42+
ns = "spanishoddata"
43+
)
44+
}
45+
3246
v1 <- tryCatch(
3347
spod_available_data(ver = 1, use_s3 = FALSE, quiet = TRUE),
3448
error = function(e) {

0 commit comments

Comments
 (0)