Skip to content

Commit 3a06484

Browse files
author
Snehamit Shah
committed
Add publisher and license validation to skills
1 parent 86eb482 commit 3a06484

2 files changed

Lines changed: 90 additions & 2 deletions

File tree

‎.github/scripts/validate_skills.py‎

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env python3
2+
import os
3+
import re
4+
import sys
5+
import yaml
6+
7+
def validate_skill(skill_md_path):
8+
print(f"Checking {skill_md_path}...")
9+
try:
10+
with open(skill_md_path, "r", encoding="utf-8") as f:
11+
content = f.read()
12+
except Exception as e:
13+
print(f"Error reading {skill_md_path}: {e}")
14+
return False
15+
16+
# Extract frontmatter
17+
match = re.search(r"^---\n(.*?)\n---", content, re.DOTALL)
18+
if not match:
19+
print(f"Error: No YAML frontmatter found in {skill_md_path}")
20+
return False
21+
22+
try:
23+
frontmatter = yaml.safe_load(match.group(1))
24+
except Exception as e:
25+
print(f"Error parsing YAML in {skill_md_path}: {e}")
26+
return False
27+
28+
if not isinstance(frontmatter, dict):
29+
print(f"Error: Frontmatter in {skill_md_path} is not a dictionary")
30+
return False
31+
32+
errors = []
33+
34+
# Check license
35+
license = frontmatter.get("license")
36+
if license != "Apache-2.0":
37+
errors.append(f"Expected 'license: Apache-2.0', got '{license}'")
38+
39+
# Check metadata
40+
metadata = frontmatter.get("metadata")
41+
if not isinstance(metadata, dict):
42+
errors.append("Missing or invalid 'metadata' block")
43+
else:
44+
# Check publisher
45+
publisher = metadata.get("publisher")
46+
if publisher != "google":
47+
errors.append(f"Expected 'metadata.publisher: google', got '{publisher}'")
48+
49+
# Check version
50+
version = metadata.get("version")
51+
if not version:
52+
errors.append("Missing 'metadata.version'")
53+
elif not re.match(r"^v[0-9]+$", str(version)):
54+
errors.append(f"Invalid 'metadata.version' format '{version}'. Expected format like 'v1'")
55+
56+
if errors:
57+
for err in errors:
58+
print(f" FAILED: {err}")
59+
return False
60+
61+
print(" PASSED")
62+
return True
63+
64+
def main():
65+
skills_dir = "skills"
66+
if not os.path.exists(skills_dir):
67+
print(f"Error: {skills_dir} directory not found")
68+
sys.exit(1)
69+
70+
failed = False
71+
for root, _, files in os.walk(skills_dir):
72+
for file in files:
73+
if file == "SKILL.md":
74+
skill_md_path = os.path.join(root, file)
75+
if not validate_skill(skill_md_path):
76+
failed = True
77+
78+
if failed:
79+
sys.exit(1)
80+
else:
81+
print("All skills validated successfully.")
82+
83+
if __name__ == "__main__":
84+
main()

‎.github/workflows/skills-validate.yml‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ jobs:
3737
with:
3838
python-version: "3.11"
3939

40-
- name: Install skills-ref
40+
- name: Install dependencies
4141
run: |
4242
pip install "git+https://github.com/agentskills/agentskills.git#subdirectory=skills-ref"
43+
pip install pyyaml
4344
44-
- name: Validate Skills
45+
- name: Validate Skills Spec (skills-ref)
4546
run: |
4647
failed=0
4748
for skill_dir in skills/*/; do
@@ -54,3 +55,6 @@ jobs:
5455
fi
5556
done
5657
exit $failed
58+
59+
- name: Validate Required Metadata (publisher & license)
60+
run: python .github/scripts/validate_skills.py

0 commit comments

Comments
 (0)