-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (79 loc) · 2.79 KB
/
validate-metadata.yml
File metadata and controls
94 lines (79 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Validate Metadata Files
on:
push:
branches:
- main
- dev
paths:
- '.zenodo.json'
- 'CITATION.cff'
- '.github/workflows/validate-metadata.yml'
pull_request:
paths:
- '.zenodo.json'
- 'CITATION.cff'
- '.github/workflows/validate-metadata.yml'
jobs:
validate-zenodo:
name: 🛡️ Validate Zenodo Metadata
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout code
uses: actions/checkout@v4
- name: 🛡️ Validate Zenodo JSON
uses: vsoch/zenodo-validator@main
with:
path: '.zenodo.json'
validate-citation:
name: 📝 Validate CITATION.cff
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout code
uses: actions/checkout@v4
- name: 🐍 Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: false
- name: 📝 Validate CITATION.cff
run: uvx cffconvert --validate
validate-json-syntax:
name: 🔍 Validate JSON Syntax
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout code
uses: actions/checkout@v4
- name: 🔍 Check JSON Syntax
run: |
echo "Validating .zenodo.json syntax..."
python3 -c "
import json
import sys
try:
with open('.zenodo.json', 'r') as f:
data = json.load(f)
# Basic validation checks
required_fields = ['title', 'upload_type', 'publication_type', 'creators', 'description']
missing = [field for field in required_fields if field not in data]
if missing:
print(f'❌ Missing required fields: {missing}')
sys.exit(1)
# Check creators format
if not isinstance(data.get('creators'), list) or len(data['creators']) == 0:
print('❌ creators must be a non-empty array')
sys.exit(1)
for creator in data['creators']:
if 'name' not in creator:
print(f'❌ Creator missing name field: {creator}')
sys.exit(1)
print('✅ .zenodo.json is valid')
print(f'✅ Title: {data[\"title\"]}')
print(f'✅ Type: {data[\"upload_type\"]}/{data[\"publication_type\"]}')
print(f'✅ Creators: {len(data[\"creators\"])}')
print(f'✅ License: {data.get(\"license\", \"Not specified\")}')
except json.JSONDecodeError as e:
print(f'❌ Invalid JSON: {e}')
sys.exit(1)
except Exception as e:
print(f'❌ Validation error: {e}')
sys.exit(1)
"