-
Notifications
You must be signed in to change notification settings - Fork 60
244 lines (207 loc) · 8.78 KB
/
Copy pathvalidate.yml
File metadata and controls
244 lines (207 loc) · 8.78 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
name: Reusable Validation Workflow
"on":
workflow_call:
inputs:
working_directory:
required: false
type: string
default: "./gsd-opencode"
jobs:
validate_code:
name: Validate Code Quality
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
cache: "npm"
cache-dependency-path: "${{ inputs.working_directory }}/package.json"
- name: Install dependencies
working-directory: ${{ inputs.working_directory }}
run: npm install
- name: Check Node.js syntax
working-directory: ${{ inputs.working_directory }}
run: |
node -c bin/gsd-install.js
echo "✓ JavaScript syntax validation passed"
- name: Validate package.json
working-directory: ${{ inputs.working_directory }}
run: |
node -e "console.log('✓ package.json is valid JSON'); JSON.parse(require('fs').readFileSync('package.json', 'utf8'))"
- name: Check for common issues
working-directory: ${{ inputs.working_directory }}
run: |
echo "Checking for console.log statements in production code..."
if grep -r "console\.log" bin/ --exclude-dir=node_modules; then
echo "⚠️ Warning: console.log found in bin/gsd-install.js"
else
echo "✓ No console.log statements found"
fi
echo "Checking file permissions..."
if [ -x bin/gsd-install.js ]; then
echo "✓ bin/gsd-install.js is executable"
else
echo "❌ bin/gsd-install.js is not executable"
exit 1
fi
validate_gsd:
name: Validate GSD Compliance
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
- name: Install dependencies
working-directory: ${{ inputs.working_directory }}
run: npm install
- name: Validate command structure
run: |
echo "Checking command files..."
command_dir="${{ inputs.working_directory }}/commands"
if [ -d "$command_dir" ]; then
for cmd_file in "$command_dir"/gsd/*.md; do
if [ -f "$cmd_file" ]; then
echo "Checking $cmd_file..."
# Check for required YAML frontmatter
if ! grep -q "^name:" "$cmd_file"; then
echo "❌ Missing 'name:' in $cmd_file"
exit 1
fi
if ! grep -q "^description:" "$cmd_file"; then
echo "❌ Missing 'description:' in $cmd_file"
exit 1
fi
# Check for required sections
if ! grep -q "<objective>" "$cmd_file"; then
echo "❌ Missing <objective> section in $cmd_file"
exit 1
fi
echo "✓ $cmd_file structure valid"
fi
done
else
echo "⚠️ No commands directory found"
fi
- name: Validate workflow structure
run: |
echo "Checking workflow files..."
workflows_dir="${{ inputs.working_directory }}/get-shit-done/workflows"
if [ -d "$workflows_dir" ]; then
for workflow_file in "$workflows_dir"/*.md; do
if [ -f "$workflow_file" ]; then
echo "Checking $workflow_file..."
# Check for semantic XML tags (not generic ones)
if grep -q "<section>" "$workflow_file" || grep -q "<item>" "$workflow_file"; then
echo "❌ Found generic XML tags in $workflow_file"
exit 1
fi
# Check for proper semantic tags
if grep -E "<(purpose|when_to_use|process|step)>" "$workflow_file" > /dev/null || \
grep -E "<(objective|context|execution_context)>" "$workflow_file" > /dev/null; then
echo "✓ $workflow_file uses semantic XML tags"
else
echo "⚠️ $workflow_file may need semantic XML tags"
fi
fi
done
else
echo "❌ Workflows directory not found"
exit 1
fi
- name: Validate file naming conventions
run: |
echo "Checking file naming conventions..."
# Check for kebab-case in markdown files
naming_violations=0
find ${{ inputs.working_directory }} -name "*.md" -type f | while read file; do
basename=$(basename "$file" .md)
if [[ ! "$basename" =~ ^[a-z0-9-]+$ ]] && [[ "$basename" != "README" ]] && [[ "$basename" != "GSD-STYLE" ]] && [[ "$basename" != "DEBUG" ]]; then
echo "⚠️ File name should be kebab-case: $file"
naming_violations=$((naming_violations + 1))
fi
done
if [ $naming_violations -eq 0 ]; then
echo "✓ File naming follows kebab-case convention"
else
echo "⚠️ Found $naming_violations files with naming convention violations"
echo "ℹ️ Consider renaming these files to follow kebab-case format"
fi
- name: Check for anti-patterns
run: |
echo "Checking for banned patterns..."
# Check for enterprise patterns
if grep -r -i "story point\|sprint\|raci\|knowledge transfer" ${{ inputs.working_directory }} --exclude-dir=node_modules --exclude="*.md"; then
echo "⚠️ Found enterprise patterns - check manually"
fi
# Check for temporal language in implementation docs
for file in ${{ inputs.working_directory }}/workflows/*.md; do
if [ -f "$file" ]; then
if grep -E "(previously|no longer|instead of|we changed)" "$file" > /dev/null; then
echo "❌ Found temporal language in $file"
exit 1
fi
fi
done
echo "✓ No temporal language found in workflows"
- name: Validate template structure
run: |
echo "Checking template files..."
templates_dir="${{ inputs.working_directory }}/templates"
if [ -d "$templates_dir" ]; then
for template_file in "$templates_dir"/*.md; do
if [ -f "$template_file" ]; then
basename=$(basename "$template_file" .md)
# Check for proper template header
if ! grep -q "# \[.*\] Template\|# $basename Template\|# $basename" "$template_file"; then
echo "⚠️ $template_file may need proper template header"
fi
# Check for placeholder conventions
if grep -q "\[.*\]" "$template_file" || grep -q "{.*}" "$template_file"; then
echo "✓ $template_file uses proper placeholder conventions"
fi
fi
done
fi
- name: Validate reference structure
run: |
echo "Checking reference files..."
refs_dir="${{ inputs.working_directory }}/references"
if [ -d "$refs_dir" ]; then
for ref_file in "$refs_dir"/*.md; do
if [ -f "$ref_file" ]; then
basename=$(basename "$ref_file" .md)
# Check for semantic outer containers
if grep -E "<$basename>" "$ref_file" > /dev/null || \
grep -E "<(overview|core_principle|checkpoint_types|principles)>" "$ref_file" > /dev/null; then
echo "✓ $ref_file uses semantic containers"
else
echo "⚠️ $ref_file may need semantic outer containers"
fi
fi
done
fi
- name: Check forbidden strings in antipatterns
run: |
echo "Checking forbidden strings from antipatterns.toml..."
# Run from repo root with NODE_PATH set to find gsd-opencode dependencies
NODE_PATH="${{ inputs.working_directory }}/node_modules" node assets/bin/check-forbidden-strings.js
- name: Final validation summary
run: |
echo "=== GSD Validation Summary ==="
echo "✓ Command structure validated"
echo "✓ Workflow structure validated"
echo "✓ File naming conventions followed"
echo "✓ Anti-patterns check passed"
echo "✓ Template structure validated"
echo "✓ Reference structure validated"
echo ""
echo "🎉 GSD compliance validation completed successfully!"