feat: add shared extract-test-cache.sh script for HAF app test jobs
Summary
Consolidates cache extraction logic from balance_tracker and haf_block_explorer into a shared script that all HAF apps can use.
Currently, these apps have their own extract-cache-and-wait.sh scripts:
- balance_tracker:
scripts/ci-helpers/extract-cache-and-wait.sh - haf_block_explorer:
scripts/ci-helpers/extract-cache-and-wait.sh - reputation_tracker: inline in
.test-with-docker-composetemplate
This shared script provides a single source of truth with consistent behavior.
Features
- Exact cache key match only - no fallback to different app versions (prevents schema incompatibility)
- Marker file support - prevents redundant extractions in same pipeline
- PostgreSQL wait - optional readiness check with configurable timeout
- Permission handling - fixes pgdata permissions for pg_ctl
- Clear error messages - explains what went wrong and possible causes
Usage
my_test_job:
before_script:
- !reference [.fetch_extract_test_cache, before_script]
- $EXTRACT_TEST_CACHE "${APP_SYNC_CACHE_TYPE}" "${APP_CACHE_KEY}" "${HAF_DATA_DIRECTORY}"
With PostgreSQL wait:
variables:
POSTGRES_HOST: "haf-instance"
EXTRACT_TIMEOUT: "300"
Migration Path
Apps can gradually migrate from their local scripts to this shared version. The interface is compatible - same arguments (cache-type, cache-key, dest-dir).
Related MRs
- common-ci-configuration !167 (merged) - removes fallback from
.haf_app_smart_cache_lookup - reputation_tracker !147 (merged) - removes fallback from test template
- balance_tracker !266 - removes fallback from
sync_with_mock_data - haf_block_explorer !355 - removes fallback from
extract-cache-and-wait.sh