From 934531b6208d9a73c83efe382988be157e401f5c Mon Sep 17 00:00:00 2001 From: Will Curran-Groome Date: Fri, 10 Jul 2026 12:49:20 -0400 Subject: [PATCH 1/2] fix CI vignette failures: undefined api_key and missing cache directory - get_nhgis_crosswalk() referenced an api_key parameter that was never added to its signature; restore reading the key from IPUMS_API_KEY - crosswalk.Rmd now creates its tempdir cache directory before passing it to get_crosswalk(), which validate_cache_dir() requires to exist Co-Authored-By: Claude Fable 5 --- R/get_nhgis_crosswalk.R | 4 +--- vignettes/crosswalk.Rmd | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/R/get_nhgis_crosswalk.R b/R/get_nhgis_crosswalk.R index e2a8421..fa7af24 100644 --- a/R/get_nhgis_crosswalk.R +++ b/R/get_nhgis_crosswalk.R @@ -694,9 +694,7 @@ years 2010, 2014, and 2015 (not ", target_year, ").") stop(stringr::str_c( "There is no available crosswalk between the specified geographies and years.")) } - if (is.null(api_key) || api_key == "") { - api_key = Sys.getenv("IPUMS_API_KEY") - } + api_key = Sys.getenv("IPUMS_API_KEY") if (api_key == "") { stop( "API key required. Save your API key to the IPUMS_API_KEY environment diff --git a/vignettes/crosswalk.Rmd b/vignettes/crosswalk.Rmd index d768b9f..6eb4560 100644 --- a/vignettes/crosswalk.Rmd +++ b/vignettes/crosswalk.Rmd @@ -63,6 +63,7 @@ crosswalk. With no years specified, `get_crosswalk()` uses GeoCorr 2022 ## save fetched crosswalks to a directory so repeat requests read from disk; ## see the Caching section at the end of this vignette cache_dir <- file.path(tempdir(), "crosswalk-cache") +dir.create(cache_dir, recursive = TRUE, showWarnings = FALSE) county_to_puma <- get_crosswalk( source_geography = "county", From c3bd55fd077954a33ca25cb6f3f6fb56b312f52f Mon Sep 17 00:00:00 2001 From: Will Curran-Groome Date: Fri, 10 Jul 2026 13:30:53 -0400 Subject: [PATCH 2/2] fix remaining CI test failures: aiannh crosswalk_source and CENSUS_API_KEY skip - get_available_crosswalks(): the aiannh target rows were missing a crosswalk_source value, leaving NA and failing the column-type test - test-geoid_lengths.R: the CTData county 2020->2022 path fetches county GEOIDs via tidycensus, which requires CENSUS_API_KEY; split that case into its own test that skips when the key is unset (CI passes the secret but it is currently blank) Co-Authored-By: Claude Fable 5 --- R/get_crosswalk.R | 3 ++- tests/testthat/test-geoid_lengths.R | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/R/get_crosswalk.R b/R/get_crosswalk.R index 0d52106..4a4049d 100644 --- a/R/get_crosswalk.R +++ b/R/get_crosswalk.R @@ -709,7 +709,8 @@ get_available_crosswalks <- function() { source_geography = geocorr_2022_geographies, target_geography = "aiannh", source_year = 2022L, - target_year = 2022L) + target_year = 2022L, + crosswalk_source = "geocorr") geocorr_2022 <- dplyr::bind_rows(geocorr_2022, geocorr_2022_aiannh) diff --git a/tests/testthat/test-geoid_lengths.R b/tests/testthat/test-geoid_lengths.R index f3bfdbd..1b88075 100644 --- a/tests/testthat/test-geoid_lengths.R +++ b/tests/testthat/test-geoid_lengths.R @@ -163,7 +163,7 @@ test_that("GeoCorr 2018 congressional district crosswalks have correct-length GE test_that("CTData 2020-2022 crosswalks have correct-length GEOIDs", { skip_if_offline() - for (geog in c("tract", "block_group", "county")) { + for (geog in c("tract", "block_group")) { result <- get_crosswalk( source_geography = geog, target_geography = geog, @@ -173,6 +173,19 @@ test_that("CTData 2020-2022 crosswalks have correct-length GEOIDs", { } }) +test_that("CTData 2020-2022 county crosswalk has correct-length GEOIDs", { + skip_if_offline() + # the county path fetches 2020 county GEOIDs via tidycensus::get_acs() + skip_if(Sys.getenv("CENSUS_API_KEY") == "", "CENSUS_API_KEY not set") + + result <- get_crosswalk( + source_geography = "county", + target_geography = "county", + source_year = 2020, + target_year = 2022) + assert_geoid_lengths(result, label = "ctdata county") +}) + # ============================================================================== # NHGIS GEOID length tests # ==============================================================================