-
Notifications
You must be signed in to change notification settings - Fork 9
117 lines (97 loc) · 3.4 KB
/
validate-plugin-templates.yml
File metadata and controls
117 lines (97 loc) · 3.4 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: Validate Plugin Templates
on:
push:
branches:
- main
- "renovate/**"
pull_request:
paths:
- "plugin-templates/**"
- ".github/workflows/validate-plugin-templates.yml"
jobs:
find-templates:
name: Find plugin templates
runs-on: ubuntu-latest
outputs:
templates: ${{ steps.find-templates.outputs.templates }}
steps:
- uses: actions/checkout@v5
- name: Find template directories
id: find-templates
run: |
templates=$(find plugin-templates -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "templates=$templates" >> $GITHUB_OUTPUT
validate:
name: Validate ${{ matrix.template }}
runs-on: ubuntu-latest
needs: find-templates
strategy:
fail-fast: false
matrix:
template: ${{ fromJSON(needs.find-templates.outputs.templates) }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v6
with:
node-version: "24"
- name: Validate manifest.json
run: |
manifest_path="plugin-templates/${{ matrix.template }}/manifest.json"
if [ ! -f "$manifest_path" ]; then
echo "Error: manifest.json not found in plugin-templates/${{ matrix.template }}"
exit 1
fi
if ! jq empty "$manifest_path" 2>/dev/null; then
echo "Error: manifest.json is not valid JSON"
exit 1
fi
required_fields=("manifest_version" "version" "type" "name.en" "icon")
for field in "${required_fields[@]}"; do
if ! jq -e ".$field" "$manifest_path" > /dev/null; then
echo "Error: Required field '$field' is missing in manifest.json"
exit 1
fi
done
- name: Validate package.json
run: |
package_path="plugin-templates/${{ matrix.template }}/package.json"
if [ ! -f "$package_path" ]; then
echo "Error: package.json not found in plugin-templates/${{ matrix.template }}"
exit 1
fi
if ! jq empty "$package_path" 2>/dev/null; then
echo "Error: package.json is not valid JSON"
exit 1
fi
if ! jq -e '.name' "$package_path" > /dev/null; then
echo "Error: 'name' field is required in package.json"
exit 1
fi
if ! jq -e '.scripts.keygen' "$package_path" > /dev/null; then
echo "Error: scripts.keygen is required in package.json"
exit 1
fi
if ! jq -e '.scripts.build' "$package_path" > /dev/null; then
echo "Error: scripts.build is required in package.json"
exit 1
fi
- name: Install template dependencies
working-directory: plugin-templates/${{ matrix.template }}
run: |
if [ -f "package-lock.json" ]; then
npm ci
else
npm install
fi
- name: Test keygen command
working-directory: plugin-templates/${{ matrix.template }}
run: |
npm run keygen
if [ ! -f "private.ppk" ]; then
echo "Error: private.ppk was not generated by keygen command"
exit 1
fi
- name: Test build command
working-directory: plugin-templates/${{ matrix.template }}
run: |
npm run build