Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/validate-ondo-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Validate Ondo Tokenized Labels

on:
pull_request:

jobs:
validate-ondo-labels:
name: Validate Ondo Tokenized Labels
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get changed metadata files in this PR
id: changed
run: |
# List files added or modified in this PR vs the base branch
git diff --name-only --diff-filter=AM origin/${{ github.base_ref }}...HEAD \
| grep '^metadata/.*\.json$' > changed_metadata.txt || true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git diff failure skips validation

Medium Severity

The changed-metadata step pipes git diff into grep and ends with || true without pipefail. If git diff fails (for example when origin/${{ github.base_ref }} is missing or invalid), the step still succeeds, changed_metadata.txt stays empty, and the label check passes without validating any files.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 25db382. Configure here.

echo "Changed metadata files:"
cat changed_metadata.txt || echo "(none)"

- name: Check Ondo Tokenized metadata has a label file
run: |
set -euo pipefail

ERRORS=()

while IFS= read -r file; do
[ -f "$file" ] || continue

if python3 -c "import json,sys; d=json.load(open('$file')); sys.exit(0 if '(Ondo Tokenized)' in d.get('name','') else 1)" 2>/dev/null; then
# Derive expected label path:
# metadata/eip155:1/erc20:0xABC.json -> labels/eip155:1/erc20:0xABC.json
label_file="${file/metadata\//labels/}"

if [ ! -f "$label_file" ]; then
ERRORS+=("Missing label file for: $file (expected: $label_file)")
else
# Confirm labels array is non-empty
if ! python3 -c "
import json, sys
with open('$label_file') as f:
data = json.load(f)
if not data.get('labels'):
sys.exit(1)
" 2>/dev/null; then
ERRORS+=("Label file exists but has no labels: $label_file")
fi
fi
fi
done < changed_metadata.txt

if [ ${#ERRORS[@]} -gt 0 ]; then
echo ""
echo "❌ Validation failed — the following Ondo Tokenized metadata entries are missing a label file:"
echo ""
for err in "${ERRORS[@]}"; do
echo " • $err"
done
echo ""
echo "Every token whose name contains '(Ondo Tokenized)' must have a corresponding"
echo "label file under labels/ with at least one label (e.g. \"ondo\")."
echo ""
echo "To add a label, run:"
echo " npm run asset:set -- --caip <caip> --labels \"ondo\""
exit 1
fi

echo "✅ All Ondo Tokenized metadata entries in this PR have a valid label file."


Loading