Repository navigation
117 lines (104 loc) · 3.97 KB
/
Copy pathci.yml
File metadata and controls
117 lines (104 loc) · 3.97 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
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install pyyaml
run: pip install pyyaml
- name: Validate YAML frontmatter in markdown files
run: |
python3 -c "
import yaml, sys, os
failed = False
for root, dirs, files in os.walk('.'):
if '.git' in root:
continue
for f in files:
if not f.endswith('.md'):
continue
path = os.path.join(root, f)
with open(path) as fh:
content = fh.read()
if not content.startswith('---\n'):
continue
end = content.find('\n---\n', 4)
if end == -1:
continue
frontmatter = content[4:end]
try:
yaml.safe_load(frontmatter)
except yaml.YAMLError as e:
print(f'FAIL: {path}')
print(f' {e}')
failed = True
if failed:
sys.exit(1)
print('All markdown frontmatter is valid YAML')
"
- name: ShellCheck
run: |
find . -name '*.sh' -not -path './.git/*' -print0 | xargs -0 shellcheck
- name: Validate marketplace + plugin manifests
run: |
python3 -c "
import json, os, re, sys
KEBAB = re.compile(r'^[a-z0-9]+(-[a-z0-9]+)*$')
failed = False
seen = set()
with open('.claude-plugin/marketplace.json') as fh:
market = json.load(fh)
for entry in market.get('plugins', []):
name = entry.get('name')
source = entry.get('source', '')
plugin_dir = os.path.normpath(source)
if not os.path.isdir(plugin_dir):
print(f'FAIL: {name}: source dir missing: {plugin_dir}')
failed = True
continue
manifest_path = os.path.join(plugin_dir, '.claude-plugin', 'plugin.json')
if not os.path.isfile(manifest_path):
print(f'FAIL: {name}: plugin.json missing: {manifest_path}')
failed = True
continue
with open(manifest_path) as fh:
plugin = json.load(fh)
pname = plugin.get('name')
if not pname or not KEBAB.match(pname):
print(f'FAIL: {manifest_path}: name not kebab-case: {pname!r}')
failed = True
if pname != name:
print(f'FAIL: {manifest_path}: name {pname!r} != marketplace entry {name!r}')
failed = True
if pname in seen:
print(f'FAIL: duplicate plugin name: {pname!r}')
failed = True
seen.add(pname)
# a malformed hooks.json fails the plugin's load for every user who has it enabled
hooks_path = os.path.join(plugin_dir, 'hooks', 'hooks.json')
if os.path.isfile(hooks_path):
try:
with open(hooks_path) as fh:
hooks = json.load(fh)
if not isinstance(hooks.get('hooks'), dict):
raise ValueError('top-level \"hooks\" must be an object')
except (OSError, ValueError) as e:
print(f'FAIL: {hooks_path}: {e}')
failed = True
if failed:
sys.exit(1)
print(f'All {len(seen)} plugin manifest(s) valid')
"
- name: Run shell tests
run: |
shopt -s nullglob
tests=(tests/test-*.sh)
if [ ${#tests[@]} -eq 0 ]; then
echo 'No shell tests present'
exit 0
fi
for t in "${tests[@]}"; do bash "$t"; done