Skip to content

Commit 3adcaef

Browse files
committed
refactor: extract author verification logic to standalone script
- Create `.github/scripts/verify_authors.py` with additional checks - Verify GitHub handles exist and are valid - Check website and avatar URLs are accessible - Validate all registry.yaml authors are defined in authors.yaml - Update workflow to trigger on both authors.yaml and registry.yaml changes - Fix GitHub handle in authors.yaml (john-vajda → jpvajda, richmond-alake → RichmondAlake) - Standardize registry.yaml categories and fix typo (Aesthethics → Aesthetics)
1 parent 55c927b commit 3adcaef

4 files changed

Lines changed: 220 additions & 122 deletions

File tree

.github/scripts/verify_authors.py

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Verify authors.yaml and registry.yaml integrity:
4+
1. GitHub handles exist
5+
2. Website and avatar URLs are valid
6+
3. All registry.yaml authors are defined in authors.yaml
7+
"""
8+
9+
import yaml
10+
import requests
11+
import sys
12+
from pathlib import Path
13+
14+
15+
def check_github_handle(username):
16+
"""Check if a GitHub handle exists."""
17+
try:
18+
response = requests.head(f"https://github.com/{username}", timeout=10, allow_redirects=True)
19+
if response.status_code == 404:
20+
return False, "GitHub profile not found"
21+
elif response.status_code >= 400:
22+
return False, f"HTTP {response.status_code}"
23+
return True, None
24+
except requests.RequestException as e:
25+
return False, str(e)
26+
27+
28+
def check_url(url):
29+
"""Check if a URL is accessible."""
30+
# Skip x.com URLs as they block HEAD requests
31+
if 'x.com' in url:
32+
return True, "skipped (x.com)"
33+
34+
try:
35+
response = requests.head(url, timeout=10, allow_redirects=True)
36+
if response.status_code >= 400:
37+
return False, f"HTTP {response.status_code}"
38+
return True, None
39+
except requests.RequestException as e:
40+
return False, str(e)
41+
42+
43+
def main():
44+
# Load YAML files
45+
authors_path = Path(__file__).parent.parent.parent / "authors.yaml"
46+
registry_path = Path(__file__).parent.parent.parent / "registry.yaml"
47+
48+
with open(authors_path, 'r') as f:
49+
authors = yaml.safe_load(f)
50+
51+
with open(registry_path, 'r') as f:
52+
registry = yaml.safe_load(f)
53+
54+
failed_handles = []
55+
failed_urls = []
56+
missing_authors = []
57+
58+
# Step 1: Verify GitHub handles
59+
print("=== Verifying GitHub Handles ===\n")
60+
for username in authors.keys():
61+
print(f"Checking GitHub handle: {username}...")
62+
success, error = check_github_handle(username)
63+
if not success:
64+
failed_handles.append(f"{username} ({error})")
65+
print(f" ❌ {error}")
66+
else:
67+
print(f" ✓ OK")
68+
69+
# Step 2: Verify URLs
70+
print("\n=== Verifying Author URLs ===\n")
71+
for username, details in authors.items():
72+
print(f"Checking URLs for {username}...")
73+
74+
# Check website URL
75+
if 'website' in details:
76+
url = details['website']
77+
success, error = check_url(url)
78+
if not success:
79+
failed_urls.append(f"{username}.website: {url} ({error})")
80+
print(f" ❌ Website URL: {url} ({error})")
81+
elif error:
82+
print(f" ⊘ Website URL {error}: {url}")
83+
else:
84+
print(f" ✓ Website URL OK: {url}")
85+
86+
# Check avatar URL
87+
if 'avatar' in details:
88+
url = details['avatar']
89+
success, error = check_url(url)
90+
if not success:
91+
failed_urls.append(f"{username}.avatar: {url} ({error})")
92+
print(f" ❌ Avatar URL: {url} ({error})")
93+
elif error:
94+
print(f" ⊘ Avatar URL {error}: {url}")
95+
else:
96+
print(f" ✓ Avatar URL OK: {url}")
97+
98+
# Step 3: Verify registry authors exist in authors.yaml
99+
print("\n=== Verifying Registry Authors ===\n")
100+
registry_authors = set()
101+
for entry in registry:
102+
if 'authors' in entry:
103+
for author in entry['authors']:
104+
registry_authors.add(author)
105+
106+
print(f"Found {len(registry_authors)} unique authors in registry.yaml")
107+
108+
for author in sorted(registry_authors):
109+
if author not in authors:
110+
missing_authors.append(author)
111+
print(f" ❌ Author '{author}' not found in authors.yaml")
112+
else:
113+
print(f" ✓ {author}")
114+
115+
# Report results
116+
has_failures = False
117+
118+
if failed_handles:
119+
print("\n❌ The following GitHub handles failed verification:")
120+
for handle in failed_handles:
121+
print(f" - {handle}")
122+
has_failures = True
123+
124+
if failed_urls:
125+
print("\n❌ The following URLs failed verification:")
126+
for url in failed_urls:
127+
print(f" - {url}")
128+
has_failures = True
129+
130+
if missing_authors:
131+
print("\n❌ The following authors are in registry.yaml but not in authors.yaml:")
132+
for author in missing_authors:
133+
print(f" - {author}")
134+
has_failures = True
135+
136+
if has_failures:
137+
sys.exit(1)
138+
else:
139+
print("\n✓ All verifications passed successfully!")
140+
141+
142+
if __name__ == "__main__":
143+
main()
Lines changed: 5 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
name: Verify Authors URLs
1+
name: Verify Authors
22

33
on:
44
pull_request:
55
paths:
66
- 'authors.yaml'
7+
- 'registry.yaml'
78
push:
89
branches:
910
- main
1011
paths:
1112
- 'authors.yaml'
13+
- 'registry.yaml'
1214

1315
jobs:
1416
verify-urls:
@@ -26,56 +28,6 @@ jobs:
2628
run: |
2729
pip install pyyaml requests
2830
29-
- name: Verify author URLs
31+
- name: Verify authors and registry
3032
run: |
31-
python - <<'EOF'
32-
import yaml
33-
import requests
34-
import sys
35-
from urllib.parse import urlparse
36-
37-
# Load authors.yaml
38-
with open('authors.yaml', 'r') as f:
39-
authors = yaml.safe_load(f)
40-
41-
failed_urls = []
42-
43-
for username, details in authors.items():
44-
print(f"Checking URLs for {username}...")
45-
46-
# Check website URL if present
47-
if 'website' in details:
48-
url = details['website']
49-
try:
50-
response = requests.head(url, timeout=10, allow_redirects=True)
51-
if response.status_code >= 400:
52-
failed_urls.append(f"{username}.website: {url} (HTTP {response.status_code})")
53-
print(f" ❌ Website URL failed: {url} (HTTP {response.status_code})")
54-
else:
55-
print(f" ✓ Website URL OK: {url}")
56-
except requests.RequestException as e:
57-
failed_urls.append(f"{username}.website: {url} ({str(e)})")
58-
print(f" ❌ Website URL failed: {url} ({str(e)})")
59-
60-
# Check avatar URL if present
61-
if 'avatar' in details:
62-
url = details['avatar']
63-
try:
64-
response = requests.head(url, timeout=10, allow_redirects=True)
65-
if response.status_code >= 400:
66-
failed_urls.append(f"{username}.avatar: {url} (HTTP {response.status_code})")
67-
print(f" ❌ Avatar URL failed: {url} (HTTP {response.status_code})")
68-
else:
69-
print(f" ✓ Avatar URL OK: {url}")
70-
except requests.RequestException as e:
71-
failed_urls.append(f"{username}.avatar: {url} ({str(e)})")
72-
print(f" ❌ Avatar URL failed: {url} ({str(e)})")
73-
74-
if failed_urls:
75-
print("\n❌ The following URLs failed verification:")
76-
for url in failed_urls:
77-
print(f" - {url}")
78-
sys.exit(1)
79-
else:
80-
print("\n✓ All URLs verified successfully!")
81-
EOF
33+
python .github/scripts/verify_authors.py

authors.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ james-briggs:
3131
name: james-briggs
3232
website: https://github.com/James-Briggs
3333
avatar: https://avatars.githubusercontent.com/u/64431405?v=4
34-
john-vajda:
34+
jpvajda:
3535
name: john-vajda
36-
website: https://github.com/john-vajda
37-
avatar: https://github.com/john-vajda.png
36+
website: https://github.com/jpvajda
37+
avatar: https://github.com/jpvajda.png
3838
maheshmurag:
3939
name: Mahesh Murag
4040
website: https://github.com/maheshmurag
@@ -47,7 +47,7 @@ rgb-prithvi:
4747
name: Prithvi Rajasekaran
4848
website: https://x.com/rgb_prithvi
4949
avatar: https://avatars.githubusercontent.com/u/64937816
50-
richmond-alake:
50+
RichmondAlake:
5151
name: richmond-alake
52-
website: https://github.com/richmond-alake
53-
avatar: https://github.com/richmond-alake.png
52+
website: https://github.com/RichmondAlake
53+
avatar: https://github.com/RichmondAlake.png

0 commit comments

Comments
 (0)