Skip to content

Commit 3411b17

Browse files
akarivclaude
andcommitted
CI: download and preprocess real data so data-dependent tests actually run
Previously the workflow only ran pytest against the committed YAML files, so every test gated on a preprocessed checkpoint (or a downloads/ directory) silently skipped rather than running - not a meaningful gate. Now the workflow downloads all configured years, builds the parquet checkpoint, and regenerates the pending-headers report before running pytest, so the full data-dependent suite (duplicate-header detection, unresolved-header gating, year-over-year coverage, etc.) actually executes. Downloads and the checkpoint are cached (CBS's historical workbooks are effectively immutable, and the checkpoint cache key is invalidated whenever extraction-relevant code changes) to keep repeat runs fast. The download step is best-effort (continue-on-error) so a transient network hiccup doesn't hard-fail a run that already has a viable cached checkpoint - the job only fails outright if neither a checkpoint nor any downloaded data is available at all. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 22fbcb7 commit 3411b17

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

.github/workflows/lamas-tests.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,51 @@ jobs:
2525
- name: Install lamas package
2626
run: pip install -e "Lamas/[dev]"
2727

28+
# CBS's historical workbooks (1999-2024) are effectively immutable once published, so this
29+
# cache almost always hits and the download step below becomes a no-op (download_excel
30+
# skips any file that already exists). Bump the key suffix if a genuine re-download is ever
31+
# needed (e.g. downloader.py's year range changes).
32+
- name: Cache downloaded workbooks
33+
uses: actions/cache@v4
34+
with:
35+
path: Lamas/downloads
36+
key: lamas-downloads-v1
37+
38+
# Best-effort: a transient network hiccup hitting CBS's site shouldn't hard-fail the whole
39+
# job if we already have a viable checkpoint from cache (see the "Ensure test data is
40+
# available" step below, which is the one that actually enforces data availability).
41+
- name: Download all configured years
42+
run: lamas download
43+
continue-on-error: true
44+
45+
# Invalidated whenever code that affects extraction changes (sheet config, preprocessing
46+
# logic, or the downloaded files themselves), so a real bug fix always gets re-checked
47+
# against fresh data rather than serving a stale, possibly-buggy checkpoint from cache.
48+
- name: Cache preprocessed checkpoint
49+
uses: actions/cache@v4
50+
with:
51+
path: Lamas/.cache
52+
key: lamas-checkpoint-${{ hashFiles('Lamas/downloads/**', 'Lamas/lamas/preprocess.py', 'Lamas/lamas/sheet_config.py', 'Lamas/data/sheet_config.yaml') }}
53+
54+
# Ensures the data-dependent tests in test_quality_report.py actually RUN instead of
55+
# silently skipping: either a fresh/cached checkpoint already exists, or we build one from
56+
# whatever was downloaded (even a partial set, if the download step above hit a snag) - only
57+
# fail outright if there's truly nothing to build a checkpoint from at all.
58+
- name: Ensure test data is available (checkpoint or fresh download)
59+
run: |
60+
if [ -f Lamas/.cache/preprocessed.parquet ]; then
61+
echo "Using cached checkpoint"
62+
elif [ -n "$(ls -A Lamas/downloads 2>/dev/null)" ]; then
63+
echo "No cached checkpoint - preprocessing downloaded workbooks"
64+
lamas preprocess
65+
else
66+
echo "::error::No downloaded workbooks and no cached checkpoint - cannot run data-dependent tests"
67+
exit 1
68+
fi
69+
70+
- name: Regenerate pending-headers report
71+
run: lamas map-headers
72+
2873
- name: Run pytest
2974
# -rA surfaces captured stdout for EVERY outcome, including PASSED - several tests in
3075
# test_quality_report.py (near-duplicate canonicals, naming-convention violations) are

0 commit comments

Comments
 (0)