-
Notifications
You must be signed in to change notification settings - Fork 1
242 lines (195 loc) · 7.04 KB
/
Copy pathvalidate.yml
File metadata and controls
242 lines (195 loc) · 7.04 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
name: GABP Schema Validation
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
validate-schemas:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.2
- name: Setup Node.js
uses: actions/setup-node@v6.3.0
with:
node-version: '18'
- name: Install dependencies for validation
run: |
npm install -g ajv-cli@latest
pip install jsonschema
- name: Validate JSON syntax of all files
run: |
echo "Validating JSON syntax..."
find . -name "*.json" -type f | while read -r file; do
echo "Checking $file..."
python3 -c "import json; json.load(open('$file'))" || exit 1
done
- name: Basic schema structure validation
run: |
echo "Validating that schemas are well-formed..."
python3 -c "
import json
import sys
# Check envelope schema structure
with open('SCHEMA/1.0/envelope.schema.json') as f:
envelope = json.load(f)
assert '\$id' in envelope
assert 'type' in envelope
assert envelope['type'] == 'object'
print('✅ Envelope schema structure OK')
# Check example message structure
with open('EXAMPLES/1.0/handshake/001_session-hello.json') as f:
msg = json.load(f)
assert 'v' in msg and msg['v'] == 'gabp/1'
assert 'type' in msg and msg['type'] == 'request'
assert 'method' in msg
print('✅ Example message structure OK')
"
- name: Validate message format compliance
run: |
echo "Checking GABP message format compliance..."
python3 -c "
import json
import glob
import os
def check_gabp_message(file_path):
with open(file_path) as f:
msg = json.load(f)
# Check required fields
assert 'v' in msg, f'Missing v field in {file_path}'
assert msg['v'] == 'gabp/1', f'Wrong version in {file_path}'
assert 'id' in msg, f'Missing id field in {file_path}'
assert 'type' in msg, f'Missing type field in {file_path}'
assert msg['type'] in ['request', 'response', 'event'], f'Invalid type in {file_path}'
# Type-specific checks
if msg['type'] == 'request':
assert 'method' in msg, f'Request missing method in {file_path}'
elif msg['type'] == 'response':
has_result = 'result' in msg
has_error = 'error' in msg
assert has_result != has_error, f'Response must have exactly one of result or error in {file_path}'
elif msg['type'] == 'event':
assert 'channel' in msg, f'Event missing channel in {file_path}'
assert 'seq' in msg, f'Event missing seq in {file_path}'
assert 'payload' in msg, f'Event missing payload in {file_path}'
return True
# Check all example files
for pattern in ['EXAMPLES/1.0/**/*.json', 'CONFORMANCE/1.0/valid/*.json']:
for file_path in glob.glob(pattern, recursive=True):
try:
check_gabp_message(file_path)
print(f'✅ {file_path}')
except Exception as e:
print(f'❌ {file_path}: {e}')
exit(1)
"
validate-json-syntax:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.2
- name: Validate JSON syntax
run: |
echo "Checking JSON syntax for all .json files..."
find . -name "*.json" -type f | while read -r file; do
echo "Validating $file..."
if ! python3 -m json.tool "$file" > /dev/null; then
echo "❌ Invalid JSON syntax in $file"
exit 1
else
echo "✅ Valid JSON syntax in $file"
fi
done
validate-markdown:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.2
- name: Setup Node.js
uses: actions/setup-node@v6.3.0
with:
node-version: '18'
- name: Install markdownlint
run: npm install -g markdownlint-cli
- name: Lint Markdown files
run: |
echo "Linting Markdown files..."
markdownlint README.md SPEC/1.0/*.md --config .markdownlint.json || true
check-file-structure:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.2
- name: Verify required directories exist
run: |
echo "Checking required directory structure..."
# Check required directories
for dir in "SPEC/1.0" "SCHEMA/1.0" "EXAMPLES/1.0" "CONFORMANCE/1.0" "LICENSES"; do
if [ ! -d "$dir" ]; then
echo "❌ Missing required directory: $dir"
exit 1
else
echo "✅ Directory exists: $dir"
fi
done
# Check required files
for file in "README.md" "LICENSES/SPEC-LICENSE.txt" "LICENSES/CODE-LICENSE.txt" "SCHEMA/1.0/envelope.schema.json"; do
if [ ! -f "$file" ]; then
echo "❌ Missing required file: $file"
exit 1
else
echo "✅ File exists: $file"
fi
done
echo "✅ All required files and directories are present"
verify-gabp-schemas-package:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/js/gabp-schemas
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.2
- name: Setup Node.js
uses: actions/setup-node@v6.3.0
with:
node-version: '24'
cache: npm
cache-dependency-path: packages/js/gabp-schemas/package-lock.json
- name: Install package dependencies
run: npm ci
- name: Run package tests
run: npm test
- name: Verify publishable tarball
run: npm pack --dry-run --json
verify-dotnet-schema-package:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/dotnet/Gabp.Schemas
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.2
- name: Setup .NET
uses: actions/setup-dotnet@v5.0.0
with:
dotnet-version: '8.0.x'
- name: Pack .NET schema package
run: dotnet pack Gabp.Schemas.csproj --configuration Release
verify-go-schema-package:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/go/schemas
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.2
- name: Setup Go
uses: actions/setup-go@v6.0.0
with:
go-version-file: packages/go/schemas/go.mod
- name: Refresh embedded schema copy
run: ./sync.sh
- name: Build Go schema package
run: go test ./...