forked from diegoecab/oci-deal-accelerator
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=<n>`. 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) <noreply@anthropic.com>
This commit is contained in:
@@ -61,8 +61,9 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
python3 tools/refresh_sku_catalog.py --discover -v 2>&1 \
|
python3 tools/refresh_sku_catalog.py --discover -v 2>&1 \
|
||||||
| tee /tmp/discover.log
|
| tee /tmp/discover.log
|
||||||
NEW_COUNT=$(grep -oE '^[0-9]+ SKUs present in API' /tmp/discover.log \
|
NEW_COUNT=$(sed -n 's/^DISCOVER_MISSING_COUNT=\([0-9]\+\)$/\1/p' \
|
||||||
| head -1 | awk '{print $1}' || echo "0")
|
/tmp/discover.log | tail -1)
|
||||||
|
echo "Parsed new_count='${NEW_COUNT}'"
|
||||||
echo "new_count=${NEW_COUNT:-0}" >> $GITHUB_OUTPUT
|
echo "new_count=${NEW_COUNT:-0}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Upload logs as artifact
|
- name: Upload logs as artifact
|
||||||
|
|||||||
@@ -385,6 +385,8 @@ def discover_catalog(verbose=False):
|
|||||||
|
|
||||||
missing = discover_missing_skus(api_map, sku_map, verbose=verbose)
|
missing = discover_missing_skus(api_map, sku_map, verbose=verbose)
|
||||||
print_missing_skus(missing, limit=None if verbose else 40)
|
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
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user