|
27 | 27 | - name: Validate JSON structure |
28 | 28 | run: | |
29 | 29 | echo "🔍 Validating JSON syntax..." |
30 | | - python -m json.tool lngal_data.json > /dev/null |
| 30 | + python3 -m json.tool lngal_data.json > /dev/null |
31 | 31 | echo "✅ JSON syntax is valid" |
32 | 32 |
|
33 | 33 | echo "🔍 Checking required fields..." |
|
38 | 38 | fi |
39 | 39 |
|
40 | 40 | # Check that there's at least one category |
41 | | - category_count=$(python -c "import json; data=json.load(open('lngal_data.json')); print(len(data.get('categories', [])))") |
| 41 | + category_count=$(python3 -c "import json; data=json.load(open('lngal_data.json')); print(len(data.get('categories', [])))") |
42 | 42 | if [ "$category_count" -eq 0 ]; then |
43 | 43 | echo "❌ No categories found in JSON" |
44 | 44 | exit 1 |
|
47 | 47 | echo "✅ Found $category_count categories" |
48 | 48 | echo "✅ JSON structure validation passed" |
49 | 49 |
|
| 50 | + - name: Validate project links |
| 51 | + run: | |
| 52 | + echo "🔍 Validating project links format..." |
| 53 | + python3 -c " |
| 54 | + import json |
| 55 | + import sys |
| 56 | +
|
| 57 | + with open('lngal_data.json', 'r') as f: |
| 58 | + data = json.load(f) |
| 59 | +
|
| 60 | + errors = [] |
| 61 | + total_links = 0 |
| 62 | +
|
| 63 | + for category in data.get('categories', []): |
| 64 | + for item in category.get('items', []): |
| 65 | + project_name = item.get('project_name', 'Unknown') |
| 66 | + links = item.get('links', []) |
| 67 | +
|
| 68 | + for i, link in enumerate(links): |
| 69 | + total_links += 1 |
| 70 | + # Check if link is an object |
| 71 | + if not isinstance(link, dict): |
| 72 | + errors.append(f'❌ {project_name}: Link {i+1} is not an object') |
| 73 | + continue |
| 74 | + # Check required fields |
| 75 | + if 'type' not in link: |
| 76 | + errors.append(f'❌ {project_name}: Link {i+1} missing \"type\" field') |
| 77 | + elif not isinstance(link['type'], str) or not link['type'].strip(): |
| 78 | + errors.append(f'❌ {project_name}: Link {i+1} \"type\" field is empty or not a string') |
| 79 | +
|
| 80 | + if 'url' not in link: |
| 81 | + errors.append(f'❌ {project_name}: Link {i+1} missing \"url\" field') |
| 82 | + elif not isinstance(link['url'], str) or not link['url'].strip(): |
| 83 | + errors.append(f'❌ {project_name}: Link {i+1} \"url\" field is empty or not a string') |
| 84 | + else: |
| 85 | + url = link['url'].strip() |
| 86 | + # Basic URL format validation |
| 87 | + if not (url.startswith('http://') or url.startswith('https://')): |
| 88 | + errors.append(f'❌ {project_name}: Link {i+1} URL must start with http:// or https://') |
| 89 | +
|
| 90 | + if errors: |
| 91 | + print(f'Found {len(errors)} link validation errors:') |
| 92 | + for error in errors: |
| 93 | + print(error) |
| 94 | + sys.exit(1) |
| 95 | + else: |
| 96 | + print(f'✅ All {total_links} project links are properly formatted') |
| 97 | + " |
| 98 | + echo "✅ Project links validation passed" |
| 99 | +
|
50 | 100 | - name: Test HTML validity |
51 | 101 | run: | |
52 | 102 | echo "🔍 Checking HTML structure..." |
|
0 commit comments