From 9b4d04cf34a52566e0ddb9d1702b30f5db9fe7a2 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 24 Apr 2026 12:43:06 -0300 Subject: [PATCH] Make discover count machine-readable for CI parsing The workflow's grep-on-free-text approach was fragile: local run correctly extracted 162, but in the CI run the 'Open issue' step was skipped, meaning new_count ended up as 0 after parsing. Likely causes: stdout buffering, color codes, or shell differences between local and the Gitea runner's shell. Fix: tools/refresh_sku_catalog.py --discover now emits a deterministic last-line marker `DISCOVER_MISSING_COUNT=`. The workflow parses that with sed (anchored, unambiguous) instead of the human-facing summary line. Also added a diagnostic echo so the parsed value shows up in CI logs for future debugging. Co-Authored-By: Claude Opus 4.7 (1M context) --- .gitea/workflows/sku-catalog-refresh.yaml | 5 +++-- tools/refresh_sku_catalog.py | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/sku-catalog-refresh.yaml b/.gitea/workflows/sku-catalog-refresh.yaml index 31d19e7..7a358f2 100644 --- a/.gitea/workflows/sku-catalog-refresh.yaml +++ b/.gitea/workflows/sku-catalog-refresh.yaml @@ -61,8 +61,9 @@ jobs: run: | python3 tools/refresh_sku_catalog.py --discover -v 2>&1 \ | tee /tmp/discover.log - NEW_COUNT=$(grep -oE '^[0-9]+ SKUs present in API' /tmp/discover.log \ - | head -1 | awk '{print $1}' || echo "0") + NEW_COUNT=$(sed -n 's/^DISCOVER_MISSING_COUNT=\([0-9]\+\)$/\1/p' \ + /tmp/discover.log | tail -1) + echo "Parsed new_count='${NEW_COUNT}'" echo "new_count=${NEW_COUNT:-0}" >> $GITHUB_OUTPUT - name: Upload logs as artifact diff --git a/tools/refresh_sku_catalog.py b/tools/refresh_sku_catalog.py index 3d50009..0038480 100644 --- a/tools/refresh_sku_catalog.py +++ b/tools/refresh_sku_catalog.py @@ -385,6 +385,8 @@ def discover_catalog(verbose=False): missing = discover_missing_skus(api_map, sku_map, verbose=verbose) print_missing_skus(missing, limit=None if verbose else 40) + # Machine-readable summary for CI/automation — always last line on stdout. + print("\nDISCOVER_MISSING_COUNT={}".format(len(missing))) return 0