-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (96 loc) · 3.75 KB
/
Copy pathvalidate-plugins.yml
File metadata and controls
118 lines (96 loc) · 3.75 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Validate Plugins
on:
pull_request:
paths:
- 'plugins/**'
- '.github/plugin/marketplace.json'
- '.github/workflows/validate-plugins.yml'
push:
branches:
- main
paths:
- 'plugins/**'
- '.github/plugin/marketplace.json'
jobs:
validate-json:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Validate .github/plugin/marketplace.json
run: |
python -m json.tool .github/plugin/marketplace.json > /dev/null
echo "✓ .github/plugin/marketplace.json is valid JSON"
- name: Validate all plugin.json files
run: |
for file in $(find plugins -name "plugin.json"); do
python -m json.tool "$file" > /dev/null
echo "✓ $file is valid JSON"
done
- name: Check required fields
run: |
python3 << 'EOF'
import json
import glob
required_fields = ["name", "displayName", "description", "version", "publisher"]
for plugin_file in glob.glob("plugins/**/plugin.json", recursive=True):
with open(plugin_file, 'r') as f:
plugin = json.load(f)
for field in required_fields:
if field not in plugin:
print(f"❌ {plugin_file}: Missing required field '{field}'")
exit(1)
print(f"✓ {plugin_file}: All required fields present")
print("\n✓ All validations passed!")
EOF
- name: Validate plugin names are unique
run: |
python3 << 'EOF'
import json
import glob
names = {}
for plugin_file in glob.glob("plugins/**/plugin.json", recursive=True):
with open(plugin_file, 'r') as f:
plugin = json.load(f)
name = plugin.get("name")
if name in names:
print(f"❌ Duplicate plugin name '{name}' in {plugin_file} and {names[name]}")
exit(1)
names[name] = plugin_file
print("✓ All plugin names are unique")
EOF
- name: Validate plugin versions match marketplace.json
run: |
python3 << 'EOF'
import json
import glob
import sys
with open(".github/plugin/marketplace.json", "r") as f:
marketplace = json.load(f)
marketplace_versions = {
p["name"]: p["version"] for p in marketplace.get("plugins", [])
}
errors = []
for plugin_file in glob.glob("plugins/**/plugin.json", recursive=True):
with open(plugin_file, "r") as f:
plugin = json.load(f)
name = plugin.get("name")
plugin_version = plugin.get("version")
marketplace_version = marketplace_versions.get(name)
if marketplace_version is None:
errors.append(
f"❌ {plugin_file}: plugin '{name}' not found in marketplace.json"
)
elif plugin_version != marketplace_version:
errors.append(
f"❌ {plugin_file}: version '{plugin_version}' does not match "
f"marketplace.json version '{marketplace_version}' for plugin '{name}'"
)
else:
print(f"✓ {plugin_file}: version '{plugin_version}' matches marketplace.json")
if errors:
for error in errors:
print(error)
sys.exit(1)
print("\n✓ All plugin versions match marketplace.json")
EOF