-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (78 loc) · 3.24 KB
/
Copy pathvalidate.yml
File metadata and controls
91 lines (78 loc) · 3.24 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
name: Validate content files
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run validator
run: node _meta/validate.mjs
- name: Check CODEOWNERS drift
run: |
node _meta/build-codeowners.mjs
if ! git diff --exit-code .github/CODEOWNERS; then
echo "::error::.github/CODEOWNERS is out of date. Run 'node _meta/build-codeowners.mjs' locally and commit the result."
exit 1
fi
- name: Check index.json drift
run: |
node _meta/build-index.mjs
if ! git diff --exit-code _meta/index.json; then
echo "::error::_meta/index.json is out of date. Run 'node _meta/build-index.mjs' locally and commit the result."
exit 1
fi
- name: ShellCheck install.sh + uninstall.sh + test-install.sh
if: hashFiles('tools/*.sh') != ''
run: |
if ! command -v shellcheck >/dev/null 2>&1; then
sudo apt-get install -y shellcheck
fi
shellcheck tools/install.sh tools/uninstall.sh tools/test-install.sh
- name: Install/uninstall smoke test
if: hashFiles('tools/install.sh') != ''
run: bash tools/test-install.sh
- name: Plugin manifests + slash-command frontmatter
if: hashFiles('.claude-plugin/marketplace.json') != ''
run: |
set -e
# marketplace.json: valid JSON
jq -e . .claude-plugin/marketplace.json > /dev/null
# Each declared plugin source must exist and have a valid plugin.json
jq -r '.plugins[].source' .claude-plugin/marketplace.json | while read -r src; do
plugin_json="${src}/.claude-plugin/plugin.json"
if [ ! -f "${plugin_json}" ]; then
echo "::error::marketplace.json declares plugin source ${src} but ${plugin_json} doesn't exist"
exit 1
fi
jq -e . "${plugin_json}" > /dev/null \
|| { echo "::error::${plugin_json} is not valid JSON"; exit 1; }
# Every slash command in the plugin must have YAML frontmatter with `description:`
cmd_dir="${src}/commands"
if [ -d "${cmd_dir}" ]; then
find "${cmd_dir}" -maxdepth 1 -name "*.md" -print | while read -r cmd; do
# Has --- ... --- block?
if ! awk 'BEGIN{c=0} /^---$/{c++} END{exit (c<2)}' "${cmd}"; then
echo "::error::${cmd}: missing YAML frontmatter (--- ... --- block)"
exit 1
fi
# Has description: field inside frontmatter?
if ! awk 'BEGIN{c=0;ok=0} /^---$/{c++; next} c==1 && /^description:[[:space:]]/{ok=1} END{exit !ok}' "${cmd}"; then
echo "::error::${cmd}: frontmatter missing required 'description' field"
exit 1
fi
done
fi
done
echo "Plugin manifests + slash command frontmatter checks passed."